2005-11-02 15:34:48 +00:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
# Typical command to generate the list of tarballs:
|
2006-06-24 21:31:10 +01:00
|
|
|
|
|
|
|
# export i="http://mirror.switch.ch/ftp/mirror/X11/pub/X11R7.1/src/everything/"; curl $i | perl -e 'while (<>) { if (/href="([^"]*.bz2)"/) { print "$ENV{'i'}$1\n"; }; }' >list
|
|
|
|
# export i="http://mirror.switch.ch/ftp/mirror/X11/pub/X11R7.0/src/everything/"; curl $i | perl -e 'while (<>) { if (/href="([^"]*.bz2)"/) { print "$ENV{'i'}$1\n"; }; }' >>list
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $tmpDir = "/tmp/xorg-unpack";
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
my $version = "X11R7"; # will be removed from package names
|
2006-06-24 21:31:10 +01:00
|
|
|
my $version2 = "X11R7\\.\\d"; # will be removed from package names
|
2006-01-08 20:32:34 +00:00
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
my %pkgURLs;
|
|
|
|
my %pkgHashes;
|
|
|
|
my %pkgNames;
|
|
|
|
my %pkgRequires;
|
|
|
|
|
|
|
|
my %pcMap;
|
|
|
|
|
2006-01-09 19:34:26 +00:00
|
|
|
my %extraAttrs;
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
$pcMap{"freetype2"} = "freetype";
|
|
|
|
$pcMap{"fontconfig"} = "fontconfig";
|
|
|
|
$pcMap{"libpng12"} = "libpng";
|
|
|
|
$pcMap{"libdrm"} = "libdrm";
|
2006-01-09 12:49:21 +00:00
|
|
|
$pcMap{"libXaw"} = "libXaw";
|
2006-01-16 12:46:20 +00:00
|
|
|
$pcMap{"zlib"} = "zlib";
|
2006-01-16 15:07:03 +00:00
|
|
|
$pcMap{"perl"} = "perl";
|
|
|
|
$pcMap{"mesa"} = "mesa";
|
2006-01-08 20:32:34 +00:00
|
|
|
|
|
|
|
|
2006-01-11 00:21:52 +00:00
|
|
|
$extraAttrs{"imake"} = " inherit xorgcffiles; x11BuildHook = ./imake.sh; patches = [./imake.patch]; ";
|
2006-01-09 19:34:26 +00:00
|
|
|
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
if (-e "cache") {
|
|
|
|
open CACHE, "<cache";
|
|
|
|
while (<CACHE>) {
|
|
|
|
/^(\S+)\s+(\S+)$/ or die;
|
|
|
|
$pkgHashes{$1} = $2;
|
|
|
|
}
|
|
|
|
close CACHE;
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
chomp;
|
2006-06-24 21:31:10 +01:00
|
|
|
my $tarball = "$_";
|
|
|
|
print "\nDOING TARBALL $tarball\n";
|
2005-11-02 15:34:48 +00: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 15:07:03 +00:00
|
|
|
# next unless $pkg eq "xorgserverX11R7";
|
2006-06-24 21:31:10 +01:00
|
|
|
# print "$pkg\n";
|
2006-01-08 20:32:34 +00:00
|
|
|
$pkg =~ s/$version//g if $version ne "";
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2006-06-24 21:31:10 +01: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 21:44:19 +01:00
|
|
|
$pkgURLs{$pkg} = $tarball;
|
2006-06-24 21:31:10 +01: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 15:34:48 +00:00
|
|
|
chomp $hash;
|
|
|
|
chomp $path;
|
2006-01-08 20:32:34 +00:00
|
|
|
if (!defined $pkgHashes{$pkg}) {
|
|
|
|
open CACHE, ">>cache";
|
|
|
|
print CACHE "$pkg $hash\n";
|
|
|
|
close CACHE;
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
$pkgHashes{$pkg} = $hash;
|
|
|
|
|
|
|
|
print "\nunpacking $path\n";
|
|
|
|
system "rm -rf '$tmpDir'";
|
|
|
|
mkdir $tmpDir, 0700;
|
2006-06-24 21:31:10 +01:00
|
|
|
system "cd '$tmpDir' && tar xfj '$path'";
|
2005-11-02 15:34:48 +00: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 15:07:03 +00: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";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub process {
|
|
|
|
my $requires = shift;
|
|
|
|
foreach my $req (split / /, $1) {
|
|
|
|
next if $req eq ">=";
|
|
|
|
next if $req =~ /^\$/;
|
|
|
|
next if $req =~ /^[0-9]/;
|
|
|
|
$req =~ s/\[//g;
|
|
|
|
$req =~ s/\]//g;
|
2006-01-17 14:11:43 +00:00
|
|
|
next if $req =~ /^\s*$/;
|
2006-01-16 15:07:03 +00:00
|
|
|
print "REQUIRE: $req\n";
|
|
|
|
push @{$requires}, $req;
|
2005-11-02 15:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-16 15:07:03 +00:00
|
|
|
|
|
|
|
process \@requires, $1 while $file =~ /PKG_CHECK_MODULES\([^,]*,\s*\[?([^\),\]]*)/g;
|
|
|
|
process \@requires, $1 while $file =~ /MODULES=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /REQUIRED_LIBS=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /REQUIRES=\"(.*)\"/g;
|
2006-01-17 12:41:27 +00:00
|
|
|
process \@requires, $1 while $file =~ /XORG_DRIVER_CHECK_EXT\([^,]*,([^\)]*)\)/g;
|
2006-01-16 15:07:03 +00:00
|
|
|
|
2006-01-17 14:11:43 +00:00
|
|
|
push @requires, "mesa" if $pkg =~ /xorgserver/ or $pkg =~ /xf86videoi810/;
|
|
|
|
push @requires, "glproto" if $pkg =~ /xf86videoi810/;
|
2006-01-16 15:07:03 +00:00
|
|
|
push @requires, "zlib" if $pkg =~ /xorgserver/;
|
|
|
|
|
|
|
|
print "REQUIRES @requires => $pkg\n";
|
2005-11-02 15:34:48 +00:00
|
|
|
$pkgRequires{$pkg} = \@requires;
|
|
|
|
|
|
|
|
print "done\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "\nWRITE OUT\n";
|
|
|
|
|
2006-06-24 21:31:10 +01:00
|
|
|
open OUT, ">default2.nix";
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
print OUT "";
|
|
|
|
print OUT <<EOF;
|
|
|
|
# This is a generated file. Do not edit!
|
|
|
|
{ stdenv, fetchurl, pkgconfig, freetype, fontconfig
|
2006-01-08 20:32:34 +00:00
|
|
|
, expat, libdrm, libpng, zlib, perl, mesa
|
2005-11-02 15:34:48 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
rec {
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
foreach my $pkg (sort (keys %pkgURLs)) {
|
2005-11-02 15:34:48 +00:00
|
|
|
print "$pkg\n";
|
|
|
|
|
2006-01-09 21:39:47 +00:00
|
|
|
my %requires = ();
|
2005-11-02 15:34:48 +00:00
|
|
|
my $inputs = "";
|
2006-01-09 21:39:47 +00:00
|
|
|
foreach my $req (sort @{$pkgRequires{$pkg}}) {
|
2005-11-02 15:34:48 +00:00
|
|
|
if (defined $pcMap{$req}) {
|
2006-01-09 21:39:47 +00:00
|
|
|
if (!defined $requires{$pcMap{$req}}) {
|
|
|
|
$inputs .= "$pcMap{$req} ";
|
|
|
|
$requires{$pcMap{$req}} = 1;
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
} else {
|
|
|
|
print " NOT FOUND: $req\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 19:34:26 +00:00
|
|
|
my $extraAttrs = $extraAttrs{"$pkg"};
|
|
|
|
$extraAttrs = "" unless defined $extraAttrs;
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
print OUT <<EOF
|
2006-01-09 21:39:47 +00:00
|
|
|
$pkg = (stdenv.mkDerivation {
|
2005-11-02 15:34:48 +00:00
|
|
|
name = "$pkgNames{$pkg}";
|
2006-01-08 22:09:44 +00:00
|
|
|
builder = ./builder.sh;
|
2005-11-02 15:34:48 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = $pkgURLs{$pkg};
|
|
|
|
md5 = "$pkgHashes{$pkg}";
|
|
|
|
};
|
2006-01-09 19:34:26 +00:00
|
|
|
buildInputs = [pkgconfig $inputs];$extraAttrs
|
2006-01-09 21:39:47 +00:00
|
|
|
}) // {inherit $inputs;};
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT "}\n";
|
|
|
|
|
|
|
|
close OUT;
|