2005-11-02 16:34:48 +01:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
# Typical command to generate the list of tarballs:
|
2006-06-24 22:31:10 +02:00
|
|
|
|
2007-02-26 17:32:27 +01:00
|
|
|
# export i="http://mirror.switch.ch/ftp/mirror/X11/pub/X11R7.2/src/everything/"; curl $i | perl -e 'while (<>) { if (/href="([^"]*.bz2)"/) { print "$ENV{'i'}$1\n"; }; }' > tarballs
|
|
|
|
# manually added xcb tarballs from http://xcb.freedesktop.org/dist/
|
|
|
|
# then run: perl ./generate-expr-from-tarballs.pl < tarballs
|
2006-06-24 22:31:10 +02:00
|
|
|
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $tmpDir = "/tmp/xorg-unpack";
|
|
|
|
|
2006-01-08 21:32:34 +01:00
|
|
|
my $version = "X11R7"; # will be removed from package names
|
2006-06-24 22:31:10 +02:00
|
|
|
my $version2 = "X11R7\\.\\d"; # will be removed from package names
|
2006-01-08 21:32:34 +01:00
|
|
|
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
my %pkgURLs;
|
|
|
|
my %pkgHashes;
|
|
|
|
my %pkgNames;
|
|
|
|
my %pkgRequires;
|
|
|
|
|
|
|
|
my %pcMap;
|
|
|
|
|
2006-01-09 20:34:26 +01:00
|
|
|
my %extraAttrs;
|
|
|
|
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
$pcMap{"freetype2"} = "freetype";
|
|
|
|
$pcMap{"fontconfig"} = "fontconfig";
|
|
|
|
$pcMap{"libpng12"} = "libpng";
|
|
|
|
$pcMap{"libdrm"} = "libdrm";
|
2006-01-09 13:49:21 +01:00
|
|
|
$pcMap{"libXaw"} = "libXaw";
|
2006-01-16 13:46:20 +01:00
|
|
|
$pcMap{"zlib"} = "zlib";
|
2006-01-16 16:07:03 +01:00
|
|
|
$pcMap{"perl"} = "perl";
|
|
|
|
$pcMap{"mesa"} = "mesa";
|
2007-02-27 00:10:25 +01:00
|
|
|
$pcMap{"mesaHeaders"} = "mesaHeaders";
|
2007-02-26 17:32:27 +01:00
|
|
|
$pcMap{"mkfontscale"} = "mkfontscale";
|
|
|
|
$pcMap{"mkfontdir"} = "mkfontdir";
|
|
|
|
$pcMap{"bdftopcf"} = "bdftopcf";
|
|
|
|
$pcMap{"libxslt"} = "libxslt";
|
2006-01-08 21:32:34 +01:00
|
|
|
|
|
|
|
|
2007-02-26 18:05:27 +01:00
|
|
|
$extraAttrs{"xorgserver"} = " mesaSrc = mesa.src; x11BuildHook = ./xorgserver.sh; ";
|
|
|
|
|
2006-01-11 01:21:52 +01:00
|
|
|
$extraAttrs{"imake"} = " inherit xorgcffiles; x11BuildHook = ./imake.sh; patches = [./imake.patch]; ";
|
2006-01-09 20:34:26 +01:00
|
|
|
|
2007-02-26 17:32:27 +01:00
|
|
|
$extraAttrs{"fontmiscmisc"} = " postInstall = \"ln -s \${fontalias}/lib/X11/fonts/misc/fonts.alias \$out/lib/X11/fonts/misc/fonts.alias\"; ";
|
|
|
|
|
|
|
|
$extraAttrs{"mkfontdir"} = " preBuild = \"substituteInPlace mkfontdir.cpp --replace BINDIR \${mkfontscale}/bin\"; ";
|
|
|
|
|
2006-01-09 20:34:26 +01:00
|
|
|
|
2006-01-08 21:32:34 +01:00
|
|
|
if (-e "cache") {
|
|
|
|
open CACHE, "<cache";
|
|
|
|
while (<CACHE>) {
|
|
|
|
/^(\S+)\s+(\S+)$/ or die;
|
|
|
|
$pkgHashes{$1} = $2;
|
|
|
|
}
|
|
|
|
close CACHE;
|
|
|
|
}
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
chomp;
|
2006-06-24 22:31:10 +02:00
|
|
|
my $tarball = "$_";
|
|
|
|
print "\nDOING TARBALL $tarball\n";
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
$tarball =~ /\/((?:(?:[A-Za-z0-9]|(?:-[^0-9])|(?:-[0-9]*[a-z]))+))[^\/]*$/;
|
|
|
|
die unless defined $1;
|
|
|
|
my $pkg = $1;
|
|
|
|
$pkg =~ s/-//g;
|
2006-01-16 16:07:03 +01:00
|
|
|
# next unless $pkg eq "xorgserverX11R7";
|
2006-06-24 22:31:10 +02:00
|
|
|
# print "$pkg\n";
|
2006-01-08 21:32:34 +01:00
|
|
|
$pkg =~ s/$version//g if $version ne "";
|
2005-11-02 16:34:48 +01:00
|
|
|
|
2006-06-24 22:31:10 +02:00
|
|
|
$tarball =~ /\/([^\/]*)\.tar\.bz2$/;
|
|
|
|
my $pkgName = $1;
|
|
|
|
$pkgName =~ s/-$version2//g if $version2 ne "";
|
|
|
|
|
|
|
|
print " $pkg $pkgName\n";
|
|
|
|
|
|
|
|
if (defined $pkgNames{$pkg}) {
|
|
|
|
print " SKIPPING\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2006-06-24 22:44:19 +02:00
|
|
|
$pkgURLs{$pkg} = $tarball;
|
2006-06-24 22:31:10 +02:00
|
|
|
$pkgNames{$pkg} = $pkgName;
|
|
|
|
|
|
|
|
my $maybeHash = $pkgHashes{$pkg};
|
|
|
|
$maybeHash = "" unless defined $maybeHash;
|
|
|
|
my ($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball' $maybeHash`;
|
2005-11-02 16:34:48 +01:00
|
|
|
chomp $hash;
|
|
|
|
chomp $path;
|
2006-01-08 21:32:34 +01:00
|
|
|
if (!defined $pkgHashes{$pkg}) {
|
|
|
|
open CACHE, ">>cache";
|
|
|
|
print CACHE "$pkg $hash\n";
|
|
|
|
close CACHE;
|
|
|
|
}
|
2005-11-02 16:34:48 +01:00
|
|
|
$pkgHashes{$pkg} = $hash;
|
|
|
|
|
|
|
|
print "\nunpacking $path\n";
|
|
|
|
system "rm -rf '$tmpDir'";
|
|
|
|
mkdir $tmpDir, 0700;
|
2006-06-24 22:31:10 +02:00
|
|
|
system "cd '$tmpDir' && tar xfj '$path'";
|
2005-11-02 16:34:48 +01:00
|
|
|
die "cannot unpack `$path'" if $? != 0;
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
my $provides = `cd '$tmpDir'/* && ls *.pc.in`;
|
|
|
|
my @provides2 = split '\n', $provides;
|
|
|
|
print "PROVIDES @provides2\n\n";
|
|
|
|
foreach my $pc (@provides2) {
|
|
|
|
$pc =~ s/.pc.in//;
|
|
|
|
die "collission with $pcMap{$pc}" if defined $pcMap{$pc};
|
|
|
|
$pcMap{$pc} = $pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @requires = ();
|
2006-01-16 16:07:03 +01:00
|
|
|
my $file;
|
|
|
|
{
|
|
|
|
local $/;
|
|
|
|
open FOO, "cd '$tmpDir'/* && cat configure.ac |";
|
|
|
|
$file = <FOO>;
|
|
|
|
close FOO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /XAW_CHECK_XPRINT_SUPPORT/) {
|
|
|
|
push @requires, "libXaw";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /zlib is required/ || $file =~ /AC_CHECK_LIB\(z\,/) {
|
|
|
|
push @requires, "zlib";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /Perl is required/) {
|
|
|
|
push @requires, "perl";
|
|
|
|
}
|
|
|
|
|
2007-02-26 17:32:27 +01:00
|
|
|
if ($file =~ /AC_PATH_PROG\(BDFTOPCF/) {
|
|
|
|
push @requires, "bdftopcf";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /AC_PATH_PROG\(MKFONTSCALE/) {
|
|
|
|
push @requires, "mkfontscale";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /AC_PATH_PROG\(MKFONTDIR/) {
|
|
|
|
push @requires, "mkfontdir";
|
|
|
|
}
|
|
|
|
|
2007-02-26 21:46:56 +01:00
|
|
|
if ($file =~ /AC_PATH_PROG\(FCCACHE/) {
|
2007-02-26 22:04:36 +01:00
|
|
|
# Don't run fc-cache.
|
|
|
|
die if defined $extraAttrs{$pkg};
|
|
|
|
$extraAttrs{$pkg} = " preInstall = \"installFlags=(FCCACHE=true)\"; ";
|
2007-02-26 21:46:56 +01:00
|
|
|
}
|
|
|
|
|
2006-01-16 16:07:03 +01:00
|
|
|
sub process {
|
|
|
|
my $requires = shift;
|
2007-02-26 17:32:27 +01:00
|
|
|
my $s = shift;
|
|
|
|
print "LOOK IN $s\n";
|
|
|
|
$s =~ s/\[/\ /g;
|
|
|
|
$s =~ s/\]/\ /g;
|
|
|
|
$s =~ s/\,/\ /g;
|
|
|
|
print "AFTER $s\n";
|
|
|
|
foreach my $req (split / /, $s) {
|
2006-01-16 16:07:03 +01:00
|
|
|
next if $req eq ">=";
|
|
|
|
next if $req =~ /^\$/;
|
|
|
|
next if $req =~ /^[0-9]/;
|
2006-01-17 15:11:43 +01:00
|
|
|
next if $req =~ /^\s*$/;
|
2006-01-16 16:07:03 +01:00
|
|
|
print "REQUIRE: $req\n";
|
|
|
|
push @{$requires}, $req;
|
2005-11-02 16:34:48 +01:00
|
|
|
}
|
|
|
|
}
|
2006-01-16 16:07:03 +01:00
|
|
|
|
2007-02-26 17:32:27 +01:00
|
|
|
process \@requires, $1 while $file =~ /PKG_CHECK_MODULES\([^,]*,([^\)]*)/g;
|
2006-01-16 16:07:03 +01:00
|
|
|
process \@requires, $1 while $file =~ /MODULES=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /REQUIRED_LIBS=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /REQUIRES=\"(.*)\"/g;
|
2007-02-26 17:32:27 +01:00
|
|
|
process \@requires, $1 while $file =~ /NEEDED=\"(.*)\"/g;
|
2006-01-17 13:41:27 +01:00
|
|
|
process \@requires, $1 while $file =~ /XORG_DRIVER_CHECK_EXT\([^,]*,([^\)]*)\)/g;
|
2006-01-16 16:07:03 +01:00
|
|
|
|
2007-02-26 18:05:27 +01:00
|
|
|
#push @requires, "mesa" if $pkg =~ /xorgserver/ or $pkg =~ /xf86videoi810/;
|
2007-02-27 00:10:25 +01:00
|
|
|
push @requires, "glproto", "mesaHeaders" if $pkg =~ /xf86videoi810/;
|
2006-01-16 16:07:03 +01:00
|
|
|
push @requires, "zlib" if $pkg =~ /xorgserver/;
|
2007-02-26 17:32:27 +01:00
|
|
|
push @requires, "libxslt" if $pkg =~ /libxcb/;
|
2006-01-16 16:07:03 +01:00
|
|
|
|
|
|
|
print "REQUIRES @requires => $pkg\n";
|
2005-11-02 16:34:48 +01:00
|
|
|
$pkgRequires{$pkg} = \@requires;
|
|
|
|
|
|
|
|
print "done\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "\nWRITE OUT\n";
|
|
|
|
|
2006-06-24 22:31:10 +02:00
|
|
|
open OUT, ">default2.nix";
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
print OUT "";
|
|
|
|
print OUT <<EOF;
|
|
|
|
# This is a generated file. Do not edit!
|
|
|
|
{ stdenv, fetchurl, pkgconfig, freetype, fontconfig
|
2007-02-27 00:10:25 +01:00
|
|
|
, libxslt, expat, libdrm, libpng, zlib, perl, mesa, mesaHeaders
|
2005-11-02 16:34:48 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
rec {
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2006-01-08 21:32:34 +01:00
|
|
|
foreach my $pkg (sort (keys %pkgURLs)) {
|
2005-11-02 16:34:48 +01:00
|
|
|
print "$pkg\n";
|
|
|
|
|
2006-01-09 22:39:47 +01:00
|
|
|
my %requires = ();
|
2005-11-02 16:34:48 +01:00
|
|
|
my $inputs = "";
|
2006-01-09 22:39:47 +01:00
|
|
|
foreach my $req (sort @{$pkgRequires{$pkg}}) {
|
2005-11-02 16:34:48 +01:00
|
|
|
if (defined $pcMap{$req}) {
|
2006-01-09 22:39:47 +01:00
|
|
|
if (!defined $requires{$pcMap{$req}}) {
|
|
|
|
$inputs .= "$pcMap{$req} ";
|
|
|
|
$requires{$pcMap{$req}} = 1;
|
|
|
|
}
|
2005-11-02 16:34:48 +01:00
|
|
|
} else {
|
|
|
|
print " NOT FOUND: $req\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 20:34:26 +01:00
|
|
|
my $extraAttrs = $extraAttrs{"$pkg"};
|
|
|
|
$extraAttrs = "" unless defined $extraAttrs;
|
|
|
|
|
2005-11-02 16:34:48 +01:00
|
|
|
print OUT <<EOF
|
2006-01-09 22:39:47 +01:00
|
|
|
$pkg = (stdenv.mkDerivation {
|
2005-11-02 16:34:48 +01:00
|
|
|
name = "$pkgNames{$pkg}";
|
2006-01-08 23:09:44 +01:00
|
|
|
builder = ./builder.sh;
|
2005-11-02 16:34:48 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = $pkgURLs{$pkg};
|
2007-02-26 17:32:27 +01:00
|
|
|
sha256 = "$pkgHashes{$pkg}";
|
2005-11-02 16:34:48 +01:00
|
|
|
};
|
2006-01-09 20:34:26 +01:00
|
|
|
buildInputs = [pkgconfig $inputs];$extraAttrs
|
2006-01-09 22:39:47 +01:00
|
|
|
}) // {inherit $inputs;};
|
2005-11-02 16:34:48 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT "}\n";
|
|
|
|
|
|
|
|
close OUT;
|
2007-02-27 00:10:25 +01:00
|
|
|
>
|