2005-11-02 15:34:48 +00:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
# Typical command to generate the list of tarballs:
|
2006-01-08 20:32:34 +00:00
|
|
|
# curl http://mirror.switch.ch/ftp/mirror/X11/pub/X11R7.0/src/everything/ | perl -e 'while (<>) { if (/href="([^"]*.bz2)"/) { print "$1\n"; }; }' > list
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
my $baseURL = "http://mirror.switch.ch/ftp/mirror/X11/pub/X11R7.0/src/everything";
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
my $tmpDir = "/tmp/xorg-unpack";
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
my $version = "X11R7"; # will be removed from package names
|
2006-01-08 21:19:56 +00:00
|
|
|
my $version2 = "X11R7.0"; # 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;
|
|
|
|
|
|
|
|
|
|
|
|
$pcMap{"freetype2"} = "freetype";
|
|
|
|
$pcMap{"fontconfig"} = "fontconfig";
|
|
|
|
$pcMap{"libpng12"} = "libpng";
|
|
|
|
$pcMap{"libdrm"} = "libdrm";
|
2006-01-08 20:32:34 +00:00
|
|
|
$pcMap{"libdrm"} = "libdrm";
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
my $tarball = "$baseURL/$_";
|
|
|
|
print "DOING TARBALL $tarball\n\n";
|
|
|
|
|
|
|
|
$tarball =~ /\/((?:(?:[A-Za-z0-9]|(?:-[^0-9])|(?:-[0-9]*[a-z]))+))[^\/]*$/;
|
|
|
|
die unless defined $1;
|
|
|
|
my $pkg = $1;
|
|
|
|
$pkg =~ s/-//g;
|
2006-01-08 21:19:56 +00: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
|
|
|
$pkgURLs{$pkg} = $tarball;
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
my ($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball' $pkgHashes{$pkg}`;
|
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;
|
|
|
|
|
|
|
|
$tarball =~ /\/([^\/]*)\.tar\.bz2$/;
|
2006-01-08 20:32:34 +00:00
|
|
|
my $pkgName = $1;
|
2006-01-08 21:19:56 +00:00
|
|
|
$pkgName =~ s/-$version2//g if $version2 ne "";
|
2006-01-08 20:32:34 +00:00
|
|
|
$pkgNames{$pkg} = $pkgName;
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
print "\nunpacking $path\n";
|
|
|
|
system "rm -rf '$tmpDir'";
|
|
|
|
mkdir $tmpDir, 0700;
|
|
|
|
system "cd '$tmpDir' && tar xvfj '$path'";
|
|
|
|
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 = ();
|
|
|
|
my %requires = ();
|
2006-01-08 21:19:56 +00:00
|
|
|
open FOO, "cd '$tmpDir'/* && cat configure.ac |";
|
2005-11-02 15:34:48 +00:00
|
|
|
while (<FOO>) {
|
2006-01-08 21:19:56 +00:00
|
|
|
if (/PKG_CHECK_MODULES\([^,]*,\s*\[?([^\),\]]*)/ ||
|
|
|
|
/MODULES=\"(.*)\"/ ||
|
|
|
|
/REQUIRED_LIBS=\"(.*)\"/ ||
|
|
|
|
/REQUIRES=\"(.*)\"/)
|
|
|
|
{
|
|
|
|
print "MATCH: $_\n";
|
2005-11-02 15:34:48 +00:00
|
|
|
foreach my $req (split / /, $1) {
|
|
|
|
next if $req eq ">=";
|
|
|
|
next if $req =~ /^\$/;
|
|
|
|
next if $req =~ /^[0-9]/;
|
|
|
|
$req =~ s/\[//g;
|
|
|
|
$req =~ s/\]//g;
|
|
|
|
if (!defined $requires{$req}) {
|
|
|
|
push @requires, $req;
|
|
|
|
$requires{$req} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print "REQUIRES @requires\n";
|
|
|
|
$pkgRequires{$pkg} = \@requires;
|
|
|
|
|
|
|
|
print "done\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "\nWRITE OUT\n";
|
|
|
|
|
2006-01-08 20:32:34 +00:00
|
|
|
open OUT, ">default.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";
|
|
|
|
|
|
|
|
my $inputs = "";
|
|
|
|
foreach my $req (@{$pkgRequires{$pkg}}) {
|
|
|
|
if (defined $pcMap{$req}) {
|
|
|
|
$inputs .= "$pcMap{$req} ";
|
|
|
|
} else {
|
|
|
|
print " NOT FOUND: $req\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT <<EOF
|
|
|
|
$pkg = stdenv.mkDerivation {
|
|
|
|
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}";
|
|
|
|
};
|
|
|
|
buildInputs = [pkgconfig $inputs];
|
|
|
|
};
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT "}\n";
|
|
|
|
|
|
|
|
close OUT;
|