[Pkg-haskell-commits] r824 - in /packages/haskell-devscripts/trunk: dh_haskell dh_haskell_build dh_haskell_buildinst

arjan at users.alioth.debian.org arjan at users.alioth.debian.org
Sun Dec 30 18:09:20 UTC 2007


Author: arjan
Date: Sun Dec 30 18:09:20 2007
New Revision: 824

URL: http://svn.debian.org/wsvn/pkg-haskell/?sc=1&rev=824
Log:
[project @ profiling support from Jeremy Shaw]

Original author: John Goerzen <jgoerzen at complete.org>
Date: 2006-07-12 01:56:36+00:00

Modified:
    packages/haskell-devscripts/trunk/dh_haskell
    packages/haskell-devscripts/trunk/dh_haskell_build
    packages/haskell-devscripts/trunk/dh_haskell_buildinst

Modified: packages/haskell-devscripts/trunk/dh_haskell
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-devscripts/trunk/dh_haskell?rev=824&op=diff
==============================================================================
--- packages/haskell-devscripts/trunk/dh_haskell (original)
+++ packages/haskell-devscripts/trunk/dh_haskell Sun Dec 30 18:09:20 2007
@@ -104,12 +104,27 @@
     }
 }
 
+sub is_handled_profiling {
+    my $pkgname = shift;
+    if ($pkgname =~ m/^lib(ghc5|ghc6|nhc98|hugs)-.+-prof$/) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+sub dev_name {
+    my $package = shift;
+    my @pn = ($package =~ m/^lib(ghc5|ghc6|nhc98|hugs)-(.+)-prof$/);
+    return "lib$pn[0]-$pn[1]-dev";
+}
+
 sub type_of_package {
     my $pkgname = shift;
     if ($pkgname =~ m/^libhugs-.+$/) {
         return "hugs";
     } else {
-        my @pn = ($pkgname =~ m/^lib(ghc5|ghc6|nhc98|hugs)-.+-dev$/);
+        my @pn = ($pkgname =~ m/^lib(ghc5|ghc6|nhc98|hugs)-.+-(dev|prof)$/);
         return $pn[0];
     }
 }
@@ -173,7 +188,9 @@
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp = tmpdir($package);
 
+
         if (is_handled_package($package)) {
+	    # substitute ${haskell:Depends}
             my $pkgtype = type_of_package($package);
             delsubstvar($package, "haskell:Depends");
             addsubstvar($package, "haskell:Depends", 
@@ -182,7 +199,8 @@
                 addsubstvar($package, "haskell:Depends",
                             $pkgtype, "<< " . upstream_version(version_of_type($pkgtype)) . "-999");
             }
-            
+
+	    # add postinst/prerm scripts
             if ($pkgtype eq "ghc5" || $pkgtype eq "ghc6") {
                 # Build scripts
                 my $ghcver = "ghc-" . upstream_version(version_of_type($pkgtype));
@@ -198,6 +216,20 @@
             }
         }
 
+        if (is_handled_profiling($package)) {
+	    # substitute ${haskell:Depends} for profiling package
+	    my $pkgtype = type_of_package($package);
+	    delsubstvar($package, "haskell:Depends");
+	    addsubstvar($package, "haskell:Depends", 
+			$pkgtype, ">= " . upstream_version(version_of_type($pkgtype)));
+	    addsubstvar($package, "haskell:Depends",
+			$pkgtype, "<< " . upstream_version(version_of_type($pkgtype)) . "-999");
+	    # Call isnative becuase it sets $dh{VERSION}
+	    # as a side effect.
+	    isnative($package);
+	    addsubstvar($package, "haskell:Depends",
+			dev_name($package), "= " . $dh{VERSION});
+	}
 }
 
 =head1 BUGS

Modified: packages/haskell-devscripts/trunk/dh_haskell_build
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-devscripts/trunk/dh_haskell_build?rev=824&op=diff
==============================================================================
--- packages/haskell-devscripts/trunk/dh_haskell_build (original)
+++ packages/haskell-devscripts/trunk/dh_haskell_build Sun Dec 30 18:09:20 2007
@@ -95,7 +95,7 @@
 
 sub is_handled_package {
     my $pkgname = shift;
-    if ($pkgname =~ m/^lib(ghc5|ghc6|nhc98|hugs)-.+-dev$/) {
+    if ($pkgname =~ m/^lib(ghc5|ghc6|nhc98|hugs)-.+-(dev|prof)$/) {
         return 1;
     } elsif ($pkgname =~ m/libhugs-.+$/) {
         return 1;

Modified: packages/haskell-devscripts/trunk/dh_haskell_buildinst
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-devscripts/trunk/dh_haskell_buildinst?rev=824&op=diff
==============================================================================
--- packages/haskell-devscripts/trunk/dh_haskell_buildinst (original)
+++ packages/haskell-devscripts/trunk/dh_haskell_buildinst Sun Dec 30 18:09:20 2007
@@ -161,6 +161,25 @@
     return getcabalbasepath($pkgtype) . "/lib/" . getcabalnameversion();
 }
 
+sub profiling_name {
+    my $package = shift;
+    my @pn = ($package =~ m/^lib(ghc5|ghc6|nhc98|hugs)-(.+)-dev$/);
+    return "lib$pn[0]-$pn[1]-prof";
+}
+
+sub is_profiling_enabled {
+    my $package = shift;
+    my $packages = shift;
+    my $profname = profiling_name($package);
+
+    foreach my $p (@{$packages}) {
+	if ($p =~ m/^$profname$/) {
+	    return 1;
+	}
+    }
+    return 0;
+}
+
 sub safesystem {
     my $program = shift;
     print "Running: $program\n";
@@ -177,6 +196,21 @@
 die unless -e $setup;
 safesystem("ghc6 -package Cabal $setup -o setup");
 
+# Cabal currently has no way to build the -dev and -prof libraries
+# seperately. So the handling of -prof is a bit awkward. The below
+# loop handles each paragraph debian/control individually. To handle
+# -prof we:
+#
+# 1) skip over -prof paragraphs
+# 2) if we encounter a -dev paragraph we check if there is a 
+#    corresponding -prof package
+# 3) if so, we run configure with --enable-library-profiling
+# 4) build and install the libraries
+# 5) use find/tar to move the profiling libraries into
+#    -prof deb
+#
+# One side-effect is that you can not build a -prof unless you also
+# build a -dev. But you probably should not do that anyway?
 foreach my $package (@{$dh{DOPACKAGES}}) {
     my $tmp = tmpdir($package);
     if (is_handled_package($package)) {
@@ -196,7 +230,11 @@
             print "Running: ./setup build\n";
             system("./setup build");
         } else {
-            safesystem("./setup configure --prefix=" . getcabalbasepath($pkgtype)
+	    my $profiling_option = "";
+	    if (is_profiling_enabled($package,$dh{DOPACKAGES})) {
+		$profiling_option = " --enable-library-profiling ";
+	    }
+            safesystem("./setup configure " . $profiling_option . " --prefix=" . getcabalbasepath($pkgtype)
                        . " --with-compiler=/usr/bin/$pkgtype");
             safesystem("./setup build");
         }
@@ -207,6 +245,17 @@
             safesystem("mkdir -p $tmp/usr/share/doc/$package");
             safesystem("mkdir -p $tmp" . getcabalbasepath($pkgtype));
             safesystem("./setup copy --copy-prefix=$tmp" . getcabalbasepath($pkgtype));
+	    if (is_profiling_enabled($package, $dh{DOPACKAGES})) {
+		# Have to move all the profiling libraries into a
+		# seperate package. This seems a bit hackish though.
+		my $proftmp=tmpdir(profiling_name($package));
+		safesystem("mkdir -p $proftmp");
+		# NOTE: you might think you can using the -C option to
+		# tar instead using 'cd', but the --null disables -C
+		safesystem("find $tmp \\( -name \"*_p.a\" -o -name \"*.p_hi\" -o -name \"*.p_o\" \\) -printf \"%P\\0\" | " .
+			   "(cd $tmp ; tar -c --null --preserve --remove-files -T - ) | " .
+			   "tar -C $proftmp -x");
+	    }
             safesystem("cp .installed-pkg-config $tmp" . getcabalpkglibpath($pkgtype) . "/installed-pkg-config");
         }
     }




More information about the Pkg-haskell-commits mailing list