5 use File::Path 'rmtree';
9 my @tarballs = glob("libraries/tarballs/*");
15 for $tarball (@tarballs) {
17 $package =~ s#^libraries/tarballs/##;
18 $package =~ s/-[0-9.]*(-snapshot)?\.tar\.gz$//;
20 # Sanity check, so we don't rmtree the wrong thing below
21 if (($package eq "") || ($package =~ m#[/.\\]#)) {
22 die "Bad package name: $package";
25 if (-d "libraries/$package/_darcs") {
26 print "Ignoring libraries/$package as it looks like a darcs checkout\n"
29 $stamp = "libraries/stamp/$package";
30 if ((! -d "libraries/$package") || (! -f "$stamp")
31 || ((-M "libraries/stamp/$package") > (-M $tarball))) {
32 print "Unpacking $package\n";
33 if (-d "libraries/$package") {
34 &rmtree("libraries/$package")
35 or die "Can't remove libraries/$package: $!";
37 mkdir "libraries/$package";
38 system ("sh", "-c", "cd 'libraries/$package' && { cat ../../$tarball | gzip -d | tar xf - ; } && mv */* .") == 0
39 or die "Failed to unpack $package";
40 open STAMP, "> $stamp";
46 for $package (glob "libraries/*/") {
48 my $pkgs = "$package/ghc-packages";
54 push @library_dirs, "$package/$_";
59 push @library_dirs, $package;
63 for $package (@library_dirs) {
64 my $dir = &basename($package);
65 my @cabals = glob("$package/*.cabal");
67 die "Too many .cabal file in $package\n";
70 my $cabal = $cabals[0];
78 if (-f "$package/ghc-stage") {
79 open STAGE, "< $package/ghc-stage";
80 $stage = int(<STAGE>);
89 print "Creating $package/ghc.mk\n";
90 open GHCMK, "> $package/ghc.mk";
91 print GHCMK "${package}_PACKAGE = ${pkg}\n";
92 print GHCMK "${package}_dist-install_GROUP = libraries\n";
93 print GHCMK "\$(eval \$(call build-package,${package},dist-install,${stage}))\n";
96 print "Creating $package/GNUmakefile\n";
97 open GNUMAKEFILE, "> $package/GNUmakefile";
98 print GNUMAKEFILE "dir = ${package}\n";
99 print GNUMAKEFILE "TOP = ${top}\n";
100 print GNUMAKEFILE "include \$(TOP)/mk/sub-makefile.mk\n";