2018-03-17 17:59:46 +00:00
|
|
|
#! /usr/bin/env perl
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2018-12-30 19:23:39 +00:00
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# manually update tarballs.list
|
|
|
|
# then run: cat tarballs.list | perl ./generate-expr-from-tarballs.pl
|
2011-12-31 15:37:51 +00:00
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
use strict;
|
2018-03-17 17:59:46 +00:00
|
|
|
use warnings;
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2018-08-20 15:11:28 +01:00
|
|
|
use File::Basename;
|
|
|
|
use File::Spec::Functions;
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
my $tmpDir = "/tmp/xorg-unpack";
|
|
|
|
|
|
|
|
|
|
|
|
my %pkgURLs;
|
|
|
|
my %pkgHashes;
|
|
|
|
my %pkgNames;
|
|
|
|
my %pkgRequires;
|
2018-11-04 21:16:49 +00:00
|
|
|
my %pkgNativeRequires;
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
my %pcMap;
|
|
|
|
|
2006-01-09 19:34:26 +00:00
|
|
|
my %extraAttrs;
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2018-03-17 17:59:46 +00:00
|
|
|
my @missingPCs = ("fontconfig", "libdrm", "libXaw", "zlib", "perl", "python", "mkfontscale", "mkfontdir", "bdftopcf", "libxslt", "openssl", "gperf", "m4");
|
2008-10-14 15:46:56 +01:00
|
|
|
$pcMap{$_} = $_ foreach @missingPCs;
|
2005-11-02 15:34:48 +00:00
|
|
|
$pcMap{"freetype2"} = "freetype";
|
|
|
|
$pcMap{"libpng12"} = "libpng";
|
2011-02-08 17:39:28 +00:00
|
|
|
$pcMap{"libpng"} = "libpng";
|
2008-02-02 20:42:55 +00:00
|
|
|
$pcMap{"dbus-1"} = "dbus";
|
2009-06-15 17:45:48 +01:00
|
|
|
$pcMap{"uuid"} = "libuuid";
|
2011-02-08 17:39:28 +00:00
|
|
|
$pcMap{"libudev"} = "udev";
|
2018-03-17 17:59:46 +00:00
|
|
|
$pcMap{"gl"} = "libGL";
|
2018-05-19 21:40:04 +01:00
|
|
|
$pcMap{"gbm"} = "mesa_noglu";
|
2007-11-05 23:59:55 +00:00
|
|
|
$pcMap{"\$PIXMAN"} = "pixman";
|
2018-12-31 03:40:47 +00:00
|
|
|
$pcMap{"\$RENDERPROTO"} = "xorgproto";
|
|
|
|
$pcMap{"\$DRI3PROTO"} = "xorgproto";
|
|
|
|
$pcMap{"\$DRI2PROTO"} = "xorgproto";
|
2006-01-08 20:32:34 +00:00
|
|
|
|
|
|
|
|
2007-11-05 23:59:55 +00:00
|
|
|
my $downloadCache = "./download-cache";
|
|
|
|
mkdir $downloadCache, 0755;
|
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
|
|
|
|
2011-12-31 06:07:32 +00:00
|
|
|
my $pkg;
|
|
|
|
if ($tarball =~ s/:([a-zA-Z0-9_]+)$//) {
|
|
|
|
$pkg = $1;
|
|
|
|
} else {
|
|
|
|
$tarball =~ /\/((?:(?:[A-Za-z0-9]|(?:-[^0-9])|(?:-[0-9]*[a-z]))+))[^\/]*$/;
|
|
|
|
die unless defined $1;
|
|
|
|
$pkg = $1;
|
|
|
|
$pkg =~ s/-//g;
|
|
|
|
#next unless $pkg eq "xcbutil";
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2018-12-31 15:00:53 +00:00
|
|
|
$tarball =~ /\/([^\/]*)\.(tar\.(bz2|gz|xz)|tgz)$/;
|
2006-06-24 21:31:10 +01:00
|
|
|
my $pkgName = $1;
|
|
|
|
|
|
|
|
print " $pkg $pkgName\n";
|
|
|
|
|
|
|
|
if (defined $pkgNames{$pkg}) {
|
2013-06-14 13:53:36 +01:00
|
|
|
print " SKIPPING\n";
|
|
|
|
next;
|
2006-06-24 21:31:10 +01:00
|
|
|
}
|
|
|
|
|
2006-06-24 21:44:19 +01:00
|
|
|
$pkgURLs{$pkg} = $tarball;
|
2006-06-24 21:31:10 +01:00
|
|
|
$pkgNames{$pkg} = $pkgName;
|
|
|
|
|
2018-08-20 15:11:28 +01:00
|
|
|
my $cachePath = catdir($downloadCache, basename($tarball));
|
|
|
|
my $hash;
|
|
|
|
my $path;
|
|
|
|
if (-e $cachePath) {
|
|
|
|
$path = readlink($cachePath);
|
|
|
|
$hash = `nix-hash --type sha256 --base32 --flat $cachePath`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
($hash, $path) = `PRINT_PATH=1 QUIET=1 nix-prefetch-url '$tarball'`;
|
|
|
|
`nix-store --realise --add-root $cachePath --indirect $path`;
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
chomp $hash;
|
|
|
|
chomp $path;
|
|
|
|
$pkgHashes{$pkg} = $hash;
|
|
|
|
|
|
|
|
print "\nunpacking $path\n";
|
|
|
|
system "rm -rf '$tmpDir'";
|
|
|
|
mkdir $tmpDir, 0700;
|
2015-10-19 09:08:16 +01:00
|
|
|
system "cd '$tmpDir' && tar xf '$path'";
|
2005-11-02 15:34:48 +00:00
|
|
|
die "cannot unpack `$path'" if $? != 0;
|
|
|
|
print "\n";
|
|
|
|
|
2009-04-20 17:02:50 +01:00
|
|
|
my $pkgDir = `echo $tmpDir/*`;
|
|
|
|
chomp $pkgDir;
|
|
|
|
|
2010-07-19 09:59:05 +01:00
|
|
|
my $provides = `find $pkgDir -name "*.pc.in"`;
|
2005-11-02 15:34:48 +00:00
|
|
|
my @provides2 = split '\n', $provides;
|
2009-04-20 17:02:50 +01:00
|
|
|
my @requires = ();
|
2018-11-04 21:16:49 +00:00
|
|
|
my @nativeRequires = ();
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2009-04-20 17:02:50 +01:00
|
|
|
foreach my $pcFile (@provides2) {
|
|
|
|
my $pc = $pcFile;
|
2010-07-19 09:59:05 +01:00
|
|
|
$pc =~ s/.*\///;
|
2005-11-02 15:34:48 +00:00
|
|
|
$pc =~ s/.pc.in//;
|
2010-07-19 09:59:05 +01:00
|
|
|
print "PROVIDES $pc\n";
|
|
|
|
die "collision with $pcMap{$pc}" if defined $pcMap{$pc};
|
2005-11-02 15:34:48 +00:00
|
|
|
$pcMap{$pc} = $pkg;
|
2009-04-20 17:02:50 +01:00
|
|
|
|
2010-07-19 09:59:05 +01:00
|
|
|
open FOO, "<$pcFile" or die;
|
2009-04-20 17:02:50 +01:00
|
|
|
while (<FOO>) {
|
|
|
|
if (/Requires:(.*)/) {
|
|
|
|
my @reqs = split ' ', $1;
|
|
|
|
foreach my $req (@reqs) {
|
|
|
|
next unless $req =~ /^[a-z]+$/;
|
2010-07-19 09:59:05 +01:00
|
|
|
print "REQUIRE (from $pc): $req\n";
|
2009-04-20 17:02:50 +01:00
|
|
|
push @requires, $req;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close FOO;
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-16 15:07:03 +00:00
|
|
|
my $file;
|
|
|
|
{
|
|
|
|
local $/;
|
2008-02-02 20:42:55 +00:00
|
|
|
open FOO, "cd '$tmpDir'/* && grep -v '^ *#' configure.ac |";
|
2006-01-16 15:07:03 +00:00
|
|
|
$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";
|
|
|
|
}
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2006-01-16 15:07:03 +00:00
|
|
|
if ($file =~ /Perl is required/) {
|
|
|
|
push @requires, "perl";
|
|
|
|
}
|
|
|
|
|
2007-02-26 16:32:27 +00: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";
|
|
|
|
}
|
|
|
|
|
2008-10-08 18:02:48 +01:00
|
|
|
if ($file =~ /AM_PATH_PYTHON/) {
|
2018-11-04 21:16:49 +00:00
|
|
|
push @nativeRequires, "python";
|
2008-10-08 18:02:48 +01:00
|
|
|
}
|
|
|
|
|
2007-02-26 20:46:56 +00:00
|
|
|
if ($file =~ /AC_PATH_PROG\(FCCACHE/) {
|
2013-06-14 13:53:36 +01:00
|
|
|
# Don't run fc-cache.
|
|
|
|
die if defined $extraAttrs{$pkg};
|
2018-08-20 16:08:34 +01:00
|
|
|
push @{$extraAttrs{$pkg}}, "preInstall = \"installFlags=(FCCACHE=true)\";";
|
2007-02-26 20:46:56 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 08:20:03 +00:00
|
|
|
my $isFont;
|
|
|
|
|
|
|
|
if ($file =~ /XORG_FONT_BDF_UTILS/) {
|
|
|
|
push @requires, "bdftopcf", "mkfontdir";
|
|
|
|
$isFont = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /XORG_FONT_SCALED_UTILS/) {
|
|
|
|
push @requires, "mkfontscale", "mkfontdir";
|
|
|
|
$isFont = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file =~ /XORG_FONT_UCS2ANY/) {
|
2012-10-15 16:52:11 +01:00
|
|
|
push @requires, "fontutil", "mkfontscale";
|
2009-10-30 08:20:03 +00:00
|
|
|
$isFont = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($isFont) {
|
2018-08-20 16:08:34 +01:00
|
|
|
push @{$extraAttrs{$pkg}}, "configureFlags = [ \"--with-fontrootdir=\$(out)/lib/X11/fonts\" ];";
|
2009-10-30 08:20:03 +00:00
|
|
|
}
|
|
|
|
|
2006-01-16 15:07:03 +00:00
|
|
|
sub process {
|
|
|
|
my $requires = shift;
|
2013-06-14 13:53:36 +01:00
|
|
|
my $s = shift;
|
|
|
|
$s =~ s/\[/\ /g;
|
|
|
|
$s =~ s/\]/\ /g;
|
|
|
|
$s =~ s/\,/\ /g;
|
2007-02-26 16:32:27 +00:00
|
|
|
foreach my $req (split / /, $s) {
|
2006-01-16 15:07:03 +00:00
|
|
|
next if $req eq ">=";
|
2007-11-05 23:59:55 +00:00
|
|
|
#next if $req =~ /^\$/;
|
2006-01-16 15:07:03 +00:00
|
|
|
next if $req =~ /^[0-9]/;
|
2006-01-17 14:11:43 +00:00
|
|
|
next if $req =~ /^\s*$/;
|
2007-11-05 23:59:55 +00: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 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
|
|
|
|
2007-11-05 23:59:55 +00:00
|
|
|
#process \@requires, $1 while $file =~ /PKG_CHECK_MODULES\([^,]*,\s*[\[]?([^\)\[]*)/g;
|
|
|
|
process \@requires, $1 while $file =~ /PKG_CHECK_MODULES\([^,]*,([^\)\,]*)/g;
|
2006-01-16 15:07:03 +00:00
|
|
|
process \@requires, $1 while $file =~ /MODULES=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /REQUIRED_LIBS=\"(.*)\"/g;
|
2007-11-05 23:59:55 +00:00
|
|
|
process \@requires, $1 while $file =~ /REQUIRED_MODULES=\"(.*)\"/g;
|
2006-01-16 15:07:03 +00:00
|
|
|
process \@requires, $1 while $file =~ /REQUIRES=\"(.*)\"/g;
|
2010-07-18 22:51:13 +01:00
|
|
|
process \@requires, $1 while $file =~ /X11_REQUIRES=\'(.*)\'/g;
|
2007-11-05 23:59:55 +00:00
|
|
|
process \@requires, $1 while $file =~ /XDMCP_MODULES=\"(.*)\"/g;
|
|
|
|
process \@requires, $1 while $file =~ /XORG_MODULES=\"(.*)\"/g;
|
2007-02-26 16:32:27 +00:00
|
|
|
process \@requires, $1 while $file =~ /NEEDED=\"(.*)\"/g;
|
2014-12-18 06:34:20 +00:00
|
|
|
process \@requires, $1 while $file =~ /ivo_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
|
|
|
|
2007-02-26 16:32:27 +00:00
|
|
|
push @requires, "libxslt" if $pkg =~ /libxcb/;
|
2018-12-31 03:40:47 +00:00
|
|
|
push @requires, "gperf", "m4", "xorgproto" if $pkg =~ /xcbutil/;
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2009-04-20 17:02:50 +01:00
|
|
|
print "REQUIRES $pkg => @requires\n";
|
2018-11-04 21:16:49 +00:00
|
|
|
print "NATIVE_REQUIRES $pkg => @nativeRequires\n";
|
2005-11-02 15:34:48 +00:00
|
|
|
$pkgRequires{$pkg} = \@requires;
|
2018-11-04 21:16:49 +00:00
|
|
|
$pkgNativeRequires{$pkg} = \@nativeRequires;
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
print "done\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "\nWRITE OUT\n";
|
|
|
|
|
2008-10-09 13:12:58 +01:00
|
|
|
open OUT, ">default.nix";
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
print OUT "";
|
|
|
|
print OUT <<EOF;
|
2009-04-28 14:58:35 +01:00
|
|
|
# THIS IS A GENERATED FILE. DO NOT EDIT!
|
2018-08-20 16:08:34 +01:00
|
|
|
{ lib, newScope, pixman }:
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2018-08-20 16:08:34 +01:00
|
|
|
lib.makeScope newScope (self: with self; {
|
2005-11-02 15:34:48 +00:00
|
|
|
|
2013-06-14 13:53:36 +01:00
|
|
|
inherit pixman;
|
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
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";
|
|
|
|
|
2018-11-04 21:16:49 +00:00
|
|
|
my %nativeRequires = ();
|
|
|
|
my @nativeBuildInputs;
|
|
|
|
foreach my $req (sort @{$pkgNativeRequires{$pkg}}) {
|
|
|
|
if (defined $pcMap{$req}) {
|
|
|
|
# Some packages have .pc that depends on itself.
|
|
|
|
next if $pcMap{$req} eq $pkg;
|
|
|
|
if (!defined $nativeRequires{$pcMap{$req}}) {
|
|
|
|
push @nativeBuildInputs, $pcMap{$req};
|
|
|
|
$nativeRequires{$pcMap{$req}} = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print " NOT FOUND: $req\n";
|
|
|
|
}
|
|
|
|
}
|
2006-01-09 21:39:47 +00:00
|
|
|
my %requires = ();
|
2018-08-19 11:55:08 +01:00
|
|
|
my @buildInputs;
|
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}) {
|
2009-04-20 17:02:50 +01:00
|
|
|
# Some packages have .pc that depends on itself.
|
|
|
|
next if $pcMap{$req} eq $pkg;
|
2006-01-09 21:39:47 +00:00
|
|
|
if (!defined $requires{$pcMap{$req}}) {
|
2018-08-19 11:55:08 +01:00
|
|
|
push @buildInputs, $pcMap{$req};
|
2006-01-09 21:39:47 +00:00
|
|
|
$requires{$pcMap{$req}} = 1;
|
|
|
|
}
|
2005-11-02 15:34:48 +00:00
|
|
|
} else {
|
|
|
|
print " NOT FOUND: $req\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-04 21:16:49 +00:00
|
|
|
my $nativeBuildInputsStr = join "", map { $_ . " " } @nativeBuildInputs;
|
2018-08-19 11:55:08 +01:00
|
|
|
my $buildInputsStr = join "", map { $_ . " " } @buildInputs;
|
|
|
|
|
|
|
|
my @arguments = @buildInputs;
|
2018-11-04 21:16:49 +00:00
|
|
|
push @arguments, @nativeBuildInputs;
|
2018-08-20 16:08:34 +01:00
|
|
|
unshift @arguments, "stdenv", "pkgconfig", "fetchurl";
|
2018-08-19 11:55:08 +01:00
|
|
|
my $argumentsStr = join ", ", @arguments;
|
|
|
|
|
2018-08-20 16:08:34 +01:00
|
|
|
my $extraAttrsStr = "";
|
|
|
|
if (defined $extraAttrs{$pkg}) {
|
|
|
|
$extraAttrsStr = join "", map { "\n " . $_ } @{$extraAttrs{$pkg}};
|
|
|
|
}
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
print OUT <<EOF
|
2018-08-19 11:55:08 +01:00
|
|
|
$pkg = callPackage ({ $argumentsStr }: 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};
|
2007-02-26 16:32:27 +00:00
|
|
|
sha256 = "$pkgHashes{$pkg}";
|
2005-11-02 15:34:48 +00:00
|
|
|
};
|
2018-08-19 11:55:08 +01:00
|
|
|
hardeningDisable = [ "bindnow" "relro" ];
|
2018-11-04 21:16:49 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig $nativeBuildInputsStr];
|
2018-08-20 16:08:34 +01:00
|
|
|
buildInputs = [ $buildInputsStr];$extraAttrsStr
|
2015-12-30 09:40:18 +00:00
|
|
|
meta.platforms = stdenv.lib.platforms.unix;
|
2018-08-19 11:55:08 +01:00
|
|
|
}) {};
|
2013-06-14 13:53:36 +01:00
|
|
|
|
2005-11-02 15:34:48 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2018-08-20 16:08:34 +01:00
|
|
|
print OUT "})\n";
|
2005-11-02 15:34:48 +00:00
|
|
|
|
|
|
|
close OUT;
|