[Git][haskell-team/haskell-devscripts][master] Get name-version from the config file instead of its filename

Clint Adams (@clint) gitlab at salsa.debian.org
Mon Jan 5 04:02:35 GMT 2026



Clint Adams pushed to branch master at Debian Haskell Group / haskell-devscripts


Commits:
d8b27931 by Clint Adams at 2026-01-04T23:01:44-05:00
Get name-version from the config file instead of its filename

This handles the mismatch with happy-lib

- - - - -


1 changed file:

- lib/Debian/Debhelper/Buildsystem/Haskell/Recipes.pm


Changes:

=====================================
lib/Debian/Debhelper/Buildsystem/Haskell/Recipes.pm
=====================================
@@ -422,7 +422,30 @@ sub own_cabal_prerequisites {
         my $ghc_pkg = ghc_pkg_command();
         load_ghc_database($ghc_pkg, $tmp_db, $pkg_config);
 
-        my $name = path($pkg_config)->basename(qr{ [.]conf $}x);
+	# This should be factored out into a helper function
+        my $name;
+        my $path_namever = path($pkg_config)->basename(qr { [.]conf $}x);
+        $path_namever =~ m/^([^ ]*?)-(\d[\d.]*)(-\S+)?$/;
+        my $path_name = $1;
+        $path_namever = "$1-$2";
+
+        open(CONFIG, '<', $pkg_config);
+
+        my $config_name;
+        my $config_version;
+
+        while(<CONFIG>) {
+            if ($_ =~ /^name:\s+(\S+)/) { $config_name = $1; }
+            elsif ($_ =~ /^version:\s+(\S+)/) { $config_version = $1; }
+        }
+
+        if (defined $config_name && defined $config_version) {
+            $name = "$config_name-$config_version";
+            warn encode_utf8('Name value does not match filename.') if ($name != $path_namever);
+        } else {
+            $name = $path_namever;
+        }
+
         my $depends
           = run($ghc_pkg, '--package-db', $tmp_db, qw{--simple-output field},
             $name, 'depends');
@@ -512,10 +535,29 @@ sub hashed_id_to_virtual_installable {
 sub config_to_package_id {
     my ($config, $ghc_pkg, $package_db) = @_;
 
-    my $name = path($config)->basename(qr { [.]conf $}x);
+    # This should be factored out into a helper function
+    my $name;
+    my $path_namever = path($config)->basename(qr { [.]conf $}x);
+    $path_namever =~ m/^([^ ]*?)-(\d[\d.]*)(-\S+)?$/;
+    my $path_name = $1;
+    $path_namever = "$1-$2";
+
+    open(CONFIG, '<', $config);
 
-    $name =~ m/^([^ ]*?)-(\d[\d.]*)(-\S+)?$/;
-    $name = "$1-$2";
+    my $config_name;
+    my $config_version;
+
+    while(<CONFIG>) {
+	if ($_ =~ /^name:\s+(\S+)/) { $config_name = $1; }
+	elsif ($_ =~ /^version:\s+(\S+)/) { $config_version = $1; }
+    }
+
+    if (defined $config_name && defined $config_version) {
+        $name = "$config_name-$config_version";
+        warn encode_utf8('Name value does not match filename.') if ($name != $path_namever);
+    } else {
+	$name = $path_namever;
+    }
 
     my $package_id = run($ghc_pkg, '--package-db', $package_db,
         qw{--simple-output field}, $name, 'id');



View it on GitLab: https://salsa.debian.org/haskell-team/haskell-devscripts/-/commit/d8b27931da841bb14ae84bd2d856d8c950cc8aaf

-- 
View it on GitLab: https://salsa.debian.org/haskell-team/haskell-devscripts/-/commit/d8b27931da841bb14ae84bd2d856d8c950cc8aaf
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/20260105/ef959208/attachment-0001.htm>


More information about the Pkg-haskell-commits mailing list