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";
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
2007-11-06 00:59:55 +01:00
|
|
|
$pcMap{"gettext"} = "gettext";
|
|
|
|
|
|
|
|
$pcMap{"\$PIXMAN"} = "pixman";
|
|
|
|
$pcMap{"\$RENDERPROTO"} = "renderproto";
|
2006-01-08 21:32:34 +01:00
|
|
|
|
|
|
|
|
2008-01-28 20:31:59 +01:00
|
|
|
$extraAttrs{"xorgserver"} = " mesaSrc = mesa.src; x11BuildHook = ./xorgserver.sh; patches = [./xorgserver-dri-path.patch ./xorgserver-xkbcomp-path.patch ./xorgserver-xkb-leds.patch ]; ";
|
2007-02-26 18:05:27 +01:00
|
|
|
|
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
|
|
|
|
2008-01-28 20:31:59 +01:00
|
|
|
$extraAttrs{"setxkbmap"} = " postInstall = \"ensureDir \$out/share; ln -sfn \${xkeyboard_config}/etc/X11 \$out/share/X11\";";
|
2007-03-30 01:02:07 +02: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\"; ";
|
|
|
|
|
2008-01-28 20:31:59 +01:00
|
|
|
$extraAttrs{"xf86inputevdev"} = "
|
|
|
|
preBuild = \"
|
|
|
|
sed -e '/motion_history_proc/d; /history_size/d;' -i src/*.c
|
|
|
|
\";";
|
|
|
|
|
2006-01-09 20:34:26 +01:00
|
|
|
|
2007-11-06 00:59:55 +01:00
|
|
|
my $downloadCache = "./download-cache";
|
|
|
|
$ENV{'NIX_DOWNLOAD_CACHE'} = $downloadCache;
|
|
|
|
mkdir $downloadCache, 0755;
|
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;
|
2007-11-06 00:59:55 +01:00
|
|
|
#next unless $pkg eq "xorgserver";
|
|
|
|
#print "$pkg\n";
|
2005-11-02 16:34:48 +01:00
|
|
|
|
2006-06-24 22:31:10 +02:00
|
|
|
$tarball =~ /\/([^\/]*)\.tar\.bz2$/;
|
|
|
|
my $pkgName = $1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2007-11-06 00:59:55 +01:00
|
|
|
my ($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball'`;
|
2005-11-02 16:34:48 +01:00
|
|
|
chomp $hash;
|
|
|
|
chomp $path;
|
|
|
|
$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;
|
|
|
|
$s =~ s/\[/\ /g;
|
|
|
|
$s =~ s/\]/\ /g;
|
|
|
|
$s =~ s/\,/\ /g;
|
|
|
|
foreach my $req (split / /, $s) {
|
2006-01-16 16:07:03 +01:00
|
|
|
next if $req eq ">=";
|
2007-11-06 00:59:55 +01:00
|
|
|
#next if $req =~ /^\$/;
|
2006-01-16 16:07:03 +01:00
|
|
|
next if $req =~ /^[0-9]/;
|
2006-01-17 15:11:43 +01:00
|
|
|
next if $req =~ /^\s*$/;
|
2007-11-06 00:59:55 +01:00
|
|
|
next if $req eq '$REQUIRED_MODULES';
|
|
|
|
next if $req eq '$REQUIRED_LIBS';
|
|
|
|
next if $req eq '$XDMCP_MODULES';
|
|
|
|
next if $req eq '$XORG_MODULES';
|
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-11-06 00:59:55 +01:00
|
|
|
#process \@requires, $1 while $file =~ /PKG_CHECK_MODULES\([^,]*,\s*[\[]?([^\)\[]*)/g;
|
|
|
|
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;
|
2007-11-06 00:59:55 +01:00
|
|
|
process \@requires, $1 while $file =~ /REQUIRED_MODULES=\"(.*)\"/g;
|
2006-01-16 16:07:03 +01:00
|
|
|
process \@requires, $1 while $file =~ /REQUIRES=\"(.*)\"/g;
|
2007-11-06 00:59:55 +01:00
|
|
|
process \@requires, $1 while $file =~ /XDMCP_MODULES=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /XORG_MODULES=\"(.*)\"/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-27 00:10:25 +01:00
|
|
|
push @requires, "glproto", "mesaHeaders" if $pkg =~ /xf86videoi810/;
|
2008-01-28 20:31:59 +01:00
|
|
|
push @requires, "glproto", "mesaHeaders" if $pkg =~ /xf86videosis/;
|
2007-04-18 17:46:58 +02:00
|
|
|
push @requires, "glproto", "mesaHeaders" if $pkg =~ /xf86videointel/;
|
2006-01-16 16:07:03 +01:00
|
|
|
push @requires, "zlib" if $pkg =~ /xorgserver/;
|
2007-11-06 00:59:55 +01:00
|
|
|
push @requires, "xf86bigfontproto" if $pkg =~ /xorgserver/;
|
2007-02-26 17:32:27 +01:00
|
|
|
push @requires, "libxslt" if $pkg =~ /libxcb/;
|
2007-11-06 00:59:55 +01:00
|
|
|
push @requires, "gettext" if $pkg =~ /libXpm/;
|
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
|
2007-11-06 00:59:55 +01:00
|
|
|
, xkeyboard_config, gettext
|
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;
|