[Git][haskell-team/haskell-devscripts][master] 2 commits: Move CDBS-specific commands from the build recipes to the CDBS module hlibrary.mk.

Felix Lechner (@lechner) gitlab at salsa.debian.org
Fri Apr 8 20:24:34 BST 2022



Felix Lechner pushed to branch master at Debian Haskell Group / haskell-devscripts


Commits:
6244c243 by Felix Lechner at 2022-04-08T10:55:01-07:00
Move CDBS-specific commands from the build recipes to the CDBS module hlibrary.mk.

- - - - -
82f4f1ac by Felix Lechner at 2022-04-08T11:35:26-07:00
Integrate dh_haskell_extra_depends into dh_haskell_depends.

- - - - -


6 changed files:

- Dh_Haskell.sh
- debian/manpages
- dh_haskell_depends
- − dh_haskell_extra_depends
- hlibrary.mk
- lib/Debian/Debhelper/Buildsystem/Haskell/Recipes.pm


Changes:

=====================================
Dh_Haskell.sh
=====================================
@@ -30,10 +30,6 @@ hashed_dependency(){
 }
 
 # the ones below are only used in the CDBS module hlibrary.mk
-extra_depends_recipe(){
-    recipe "${FUNCNAME[0]}" "$@"
-}
-
 install_dev_recipe(){
     recipe "${FUNCNAME[0]}" "$@"
 }


=====================================
debian/manpages
=====================================
@@ -1,5 +1,4 @@
 dh_haskell_provides.1
 dh_haskell_depends.1
 dh_haskell_shlibdeps.1
-dh_haskell_extra_depends.1
 dh_haskell_blurbs.1


=====================================
dh_haskell_depends
=====================================
@@ -33,8 +33,9 @@ use Unicode::UTF8 qw(encode_utf8);
 use Debian::Debhelper::Buildsystem::Haskell::Recipes qw(
   run
   package_ext
-  package_hc
+  packages_hc
   find_config_for_ghc
+  cabal_depends
   depends_for_ghc
   depends_for_ghc_prof
   depends_for_hugs
@@ -73,23 +74,28 @@ $ENV{DH_EXCLUDES} = join($SPACE, @excludes);
 die encode_utf8('grep-dctrl is missing')
   unless system('command -v grep-dctrl > /dev/null') == 0;
 
-my $output = run('dh_listpackages', @args_bytes);
-chomp $output;
+my $haskell_compiler = packages_hc();
 
-my @installables = split($SPACE, $output);
+my @extra_depends = get_extra_depends($haskell_compiler);
 
+my $package_list = run('dh_listpackages', @args_bytes);
+chomp $package_list;
+
+my @installables = split($SPACE, $package_list);
 for my $installable (@installables) {
 
     my $substvars_path = "debian/$installable.substvars";
 
-    my $compiler = package_hc($installable);
+    replace_line($substvars_path, 'haskell:Extra-Depends',
+        join($COMMA . $SPACE, @extra_depends));
+
     my $extension = package_ext($installable);
 
     my @depends;
     my @recommends;
     my @suggests;
 
-    if (any { $compiler eq $_ } qw{ghc ghcjs}) {
+    if (any { $haskell_compiler eq $_ } qw{ghc ghcjs}) {
 
         if (any { $extension eq $_ } qw{dev prof}) {
 
@@ -105,7 +111,8 @@ for my $installable (@installables) {
                 push(
                     @depends,
                     split(
-                        m{ \s* , \s* }x,depends_for_ghc($compiler, @configs)));
+                        m{ \s* , \s* }x,
+                        depends_for_ghc($haskell_compiler, @configs)));
 
                 my $prof = $installable;
                 $prof =~ s{ - [^-]+ $}{-prof}x;
@@ -132,7 +139,7 @@ for my $installable (@installables) {
                     @depends,
                     split(
                         m{ \s* , \s* }x,
-                        depends_for_ghc_prof($compiler, @configs)));
+                        depends_for_ghc_prof($haskell_compiler, @configs)));
             }
         }
 
@@ -206,7 +213,7 @@ for my $installable (@installables) {
         }
     }
 
-    if ($compiler eq 'hugs') {
+    if ($haskell_compiler eq 'hugs') {
 
         push(@depends,split(m{ \s* , \s* }x,depends_for_hugs()));
     }
@@ -219,15 +226,51 @@ for my $installable (@installables) {
         join($COMMA . $SPACE, (sort +uniq @recommends)));
     replace_line($substvars_path, 'haskell:Suggests',
         join($COMMA . $SPACE, (sort +uniq @suggests)));
-
-    my $extra_depends = path("debian/extra-depends-$compiler")->slurp_utf8;
-    chomp $extra_depends;
-
-    replace_line($substvars_path, 'haskell:Extra-Depends', $extra_depends);
 }
 
 exit;
 
+sub get_extra_depends {
+    my ($compiler) = @_;
+
+    local $ENV{LC_ALL} = 'C.UTF-8';
+
+    $ENV{DEB_SETUP_BIN_NAME} //= 'debian/hlibrary.setup';
+
+    my $output = run($ENV{DEB_SETUP_BIN_NAME},
+        'register', "--builddir=dist-$compiler",
+        qw{--gen-pkg-config --verbose=verbose+nowrap});
+
+    die encode_utf8('Cannot get name of package registration file.')
+      unless $output
+      =~ m{^Creating \s package \s registration \s file: \s+ (\S+) $}mx;
+
+    my $pkg_config = $1;
+
+    my @hackages = cabal_depends($pkg_config);
+
+    run(qw{rm -f}, $pkg_config);
+
+    my @prerequisites;
+    for my $hackage (@hackages) {
+
+        next
+          unless $hackage =~ m{^ ([^-]+) - ([0-9.]+) - [0-9a-f]{32} $}x;
+
+        my $name = $1;
+        my $version = $2;
+
+        my $extra_packages_file
+          = "/usr/lib/haskell-packages/extra-packages/$name-$version";
+
+        push(@prerequisites,
+            split(m{ \s* , \s* }x, path($extra_packages_file)->slurp_utf8))
+          if -e $extra_packages_file;
+    }
+
+    return @prerequisites;
+}
+
 sub replace_line {
     my ($path, $field, $value) = @_;
 
@@ -288,7 +331,6 @@ not yet support nhc98.
 
 L<dh_haskell_provides(1)>
 L<dh_haskell_shlibdeps(1)>
-L<dh_haskell_extra_depends(1)>
 L<debhelper(7)>
 
 =head1 AUTHOR


=====================================
dh_haskell_extra_depends deleted
=====================================
@@ -1,142 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright © 2022 Felix Lechner <felix.lechner at lease-up.com>
-#
-# based on a shell script by the same name
-#     by Giovanni Mascellani <gio at debian.org>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-use v5.20;
-use warnings;
-use utf8;
-
-use Const::Fast;
-use File::Basename;
-use Getopt::Long ();
-use Path::Tiny;
-use Unicode::UTF8 qw(encode_utf8);
-
-use Debian::Debhelper::Buildsystem::Haskell::Recipes qw(
-  cabal_depends
-);
-
-const my $SPACE => q{ };
-const my $COMMA => q{,};
-
-my $program_name = basename($0);
-
-my @excludes;
-
-my %options = (
-    'exclude|X=s' => \@excludes,
-    'help|h' => \&show_help,
-);
-
-Getopt::Long::Configure('gnu_getopt', 'pass_through');
-Getopt::Long::GetOptions(%options)
-  or die encode_utf8("error parsing options\n");
-
-my @args_bytes = grep { /^-/ } @ARGV;
-my ($compiler, @configs) = grep { !/^-/ } @ARGV;
-
-die encode_utf8("Installed package description file $_ can not be found")
-  for grep { !-e } @configs;
-
-$ENV{DH_EXCLUDES} = join($SPACE, @excludes);
-
-my @extra_depends;
-
-my @prerequisites = cabal_depends(@configs);
-for my $prerequisite (@prerequisites) {
-
-    next
-      unless $prerequisite =~ m{^ ([^-]+) - ([0-9.]+) - [0-9a-f]{32} $}x;
-
-    my $name = $1;
-    my $version = $2;
-
-    my $extra_packages_file
-      = "/usr/lib/haskell-packages/extra-packages/$name-$version";
-
-    push(@extra_depends,
-        split(m{ \s* , \s* }x, path($extra_packages_file)->slurp_utf8))
-      if -e $extra_packages_file;
-}
-
-path("debian/extra-depends-$compiler")
-  ->spew_utf8(join($COMMA . $SPACE, @extra_depends));
-
-exit;
-
-sub show_help {
-    my $message =<<"EOT";
-Usage: $program_name [options] cabal-file ...
-
-Options:
-    -X, --exclude INSTALLABLE    exclude INSTALLABLE from processing
-EOT
-
-    print encode_utf8($message);
-
-    exit;
-}
-
-=head1 NAME
-
-dh_haskell_extra_depends - generate the extra-depends file in Haskell packages
-
-=head1 SYNOPSIS
-
-B<dh_extra_haskell_depends> [S<I<debhelper options>>]
-[B<-X>I<package>]
-[B<--exclude=>I<package>]
-[S<I<file>> ...]
-
-=head1 DESCRIPTION
-
-dh_haskell_extra_depends is a debhelper program that helps with calculating dependencies
-for building Haskell libraries.
-
-Since Haskell libraries are statically linked, packagers that use Haskell
-libraries cannot rely on the fact that dynamical libraries are dependencies
-of their packages to be sure that possible runtime data packages are installed
-at execution time. The extra dependencies mechanism allows libraries
-to declare some packages that are to be added to the dependency list of
-each package that uses them to build.
-
-This script scans the Haskell dependencies and harvest extra dependencies
-information, putting them in the file debian/extra-depends, which is later
-used by dh_haskell_depends to be included in the substvars file.
-
-=head1 BUGS
-
-None, as far as we know. :-)
-
-=head1 SEE ALSO
-
-L<dh_haskell_depends(1)>
-L<debhelper(7)>
-
-=head1 AUTHOR
-
-Giovanni Mascellani <gio at debian.org>
-
-=cut
-
-# Local Variables:
-# indent-tabs-mode: nil
-# cperl-indent-level: 4
-# End:
-# vim: syntax=perl sw=4 sts=4 sr et


=====================================
hlibrary.mk
=====================================
@@ -132,6 +132,9 @@ export GHC_HAS_SMP
 
 clean::
 	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ -E 'clean_recipe'
+	rm -f configure-ghc-stamp configure-ghcjs-stamp
+	rm -f build-ghc-stamp build-ghcjs-stamp build-hugs-stamp build-haddock-stamp
+	rm -rf debian/tmp-inst-ghc debian/tmp-inst-ghcjs
 
 $(DEB_SETUP_BIN_NAME):
 	perl -d:Confess -MDebian::Debhelper::Buildsystem::Haskell::Recipes=/.*/ -E 'make_setup_recipe'
@@ -184,41 +187,33 @@ debian/tmp-inst-ghc: $(DEB_SETUP_BIN_NAME) build-ghc-stamp
 debian/tmp-inst-ghcjs: $(DEB_SETUP_BIN_NAME) build-ghc-stamp
 	$(DEB_SETUP_BIN_NAME) copy --builddir=dist-ghcjs --destdir=debian/tmp-inst-ghcjs
 
-debian/extra-depends-ghc: debian/tmp-inst-ghc
-	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
-	extra_depends_recipe ghc
-
-debian/extra-depends-ghcjs: debian/tmp-inst-ghcjs
-	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
-	extra_depends_recipe ghcjs
-
 DEB_LINTIAN_OVERRIDES_FILE = debian/libghc-$(CABAL_PACKAGE)-dev.lintian-overrides
 
-install/libghc-$(CABAL_PACKAGE)-dev:: debian/tmp-inst-ghc debian/extra-depends-ghc
+install/libghc-$(CABAL_PACKAGE)-dev:: debian/tmp-inst-ghc
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_dev_recipe "$(notdir $@)"
 
-install/libghcjs-$(CABAL_PACKAGE)-dev:: debian/tmp-inst-ghcjs debian/extra-depends-ghcjs
+install/libghcjs-$(CABAL_PACKAGE)-dev:: debian/tmp-inst-ghcjs
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_dev_recipe "$(notdir $@)"
 
-install/libghc-$(CABAL_PACKAGE)-prof:: debian/tmp-inst-ghc install/libghc-$(CABAL_PACKAGE)-dev debian/extra-depends-ghc
+install/libghc-$(CABAL_PACKAGE)-prof:: debian/tmp-inst-ghc install/libghc-$(CABAL_PACKAGE)-dev
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_prof_recipe "$(notdir $@)"
 
-install/libghcjs-$(CABAL_PACKAGE)-prof:: debian/tmp-inst-ghcjs install/libghcjs-$(CABAL_PACKAGE)-dev debian/extra-depends-ghcjs
+install/libghcjs-$(CABAL_PACKAGE)-prof:: debian/tmp-inst-ghcjs install/libghcjs-$(CABAL_PACKAGE)-dev
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_prof_recipe "$(notdir $@)"
 
-install/libghc-$(CABAL_PACKAGE)-doc:: debian/tmp-inst-ghc build-haddock-stamp debian/extra-depends-ghc
+install/libghc-$(CABAL_PACKAGE)-doc:: debian/tmp-inst-ghc build-haddock-stamp
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_doc_recipe "$(notdir $@)"
 
-install/libghcjs-$(CABAL_PACKAGE)-doc:: debian/tmp-inst-ghcjs build-haddock-stamp debian/extra-depends-ghcjs
+install/libghcjs-$(CABAL_PACKAGE)-doc:: debian/tmp-inst-ghcjs build-haddock-stamp
 	. /usr/share/haskell-devscripts/Dh_Haskell.sh && \
 	install_doc_recipe "$(notdir $@)"
 
-install/libhugs-$(CABAL_PACKAGE):: $(DEB_SETUP_BIN_NAME) dist-hugs debian/extra-depends-hugs
+install/libhugs-$(CABAL_PACKAGE):: $(DEB_SETUP_BIN_NAME) dist-hugs
 	$(DEB_SETUP_BIN_NAME) copy --destdir=debian/libhugs-$(CABAL_PACKAGE) --builddir=dist-hugs
 	rm -rf debian/libhugs-$(CABAL_PACKAGE)/usr/share/doc/*
 	dh_haskell_depends -p$(notdir $@)


=====================================
lib/Debian/Debhelper/Buildsystem/Haskell/Recipes.pm
=====================================
@@ -71,7 +71,6 @@ BEGIN {
       build_recipe
       check_recipe
       haddock_recipe
-      extra_depends_recipe
       install_dev_recipe
       install_prof_recipe
       install_doc_recipe
@@ -863,11 +862,6 @@ sub clean_recipe {
         $ENV{DEB_SETUP_BIN_NAME},
         qw{Setup.hi Setup.ho Setup.o},
         glob('.*config*'));
-    run(
-        qw{rm -f configure-ghc-stamp configure-ghcjs-stamp build-ghc-stamp build-ghcjs-stamp build-hugs-stamp build-haddock-stamp}
-    );
-    run(qw{rm -rf debian/tmp-inst-ghc debian/tmp-inst-ghcjs});
-    run(qw{rm -f debian/extra-depends-ghc debian/extra-depends-ghcjs});
 
     if (-e $ENV{DEB_LINTIAN_OVERRIDES_FILE}) {
         run(
@@ -1063,31 +1057,6 @@ sub haddock_recipe {
     return;
 }
 
-=item extra_depends_recipe
-
-=cut
-
-sub extra_depends_recipe {
-    my ($compiler) = @_;
-
-    local $ENV{LC_ALL} = 'C.UTF-8';
-
-    my $output = run($ENV{DEB_SETUP_BIN_NAME},
-        'register', "--builddir=dist-$compiler",
-        qw{--gen-pkg-config --verbose=verbose+nowrap});
-
-    die encode_utf8('Cannot get name of package registration file.')
-      unless $output
-      =~ m{^Creating \s package \s registration \s file: \s+ (\S+) $}mx;
-
-    my $pkg_config = $1;
-
-    run('dh_haskell_extra_depends', $compiler, $pkg_config);
-    run(qw{rm -f}, $pkg_config);
-
-    return;
-}
-
 =item install_dev_recipe
 
 =cut



View it on GitLab: https://salsa.debian.org/haskell-team/haskell-devscripts/-/compare/d533666c789e3b2ee02247b2ba10e2cc8fba77c6...82f4f1ac484d51cd40de05dc384f49493cd72aab

-- 
View it on GitLab: https://salsa.debian.org/haskell-team/haskell-devscripts/-/compare/d533666c789e3b2ee02247b2ba10e2cc8fba77c6...82f4f1ac484d51cd40de05dc384f49493cd72aab
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-haskell-commits/attachments/20220408/2bf273ae/attachment-0001.htm>


More information about the Pkg-haskell-commits mailing list