This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=309fa5573291d9c2862b1e389d6273ae0e33d9c8

commit 309fa5573291d9c2862b1e389d6273ae0e33d9c8
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Dec 20 20:10:22 2025 +0100

    Dpkg::Shlibs::SymbolFile: Add support for #CURVER#
    
    This new metavariable can be used for internal symbols with unstable
    ABIs, that require a strict dependency against the current package
    version. But without the need to hardcode that variable version in
    the symbols file, or having to pre-process it during the build.
    
    Closes: #615940
---
 man/deb-src-symbols.pod              | 13 +++++++++++++
 scripts/Dpkg/Shlibs/SymbolFile.pm    |  3 +++
 scripts/Makefile.am                  |  1 +
 scripts/dpkg-gensymbols.pl           |  4 ++++
 scripts/t/Dpkg_Shlibs.t              | 32 +++++++++++++++++++++++++++++++-
 scripts/t/Dpkg_Shlibs/symbols.fake-4 |  5 +++++
 6 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/man/deb-src-symbols.pod b/man/deb-src-symbols.pod
index 3e76b7337..feb9c2332 100644
--- a/man/deb-src-symbols.pod
+++ b/man/deb-src-symbols.pod
@@ -64,6 +64,19 @@ you can use the I<#PACKAGE#> metavariable.
 It will be replaced by the real package name during installation of the
 symbols files.
 
+=head2 Using the #CURVER# metavariable
+
+In some cases,
+a symbol with an unstable ABI will require a strict dependency on the
+current package version.
+To avoid hardcoding the current version in the symbols file,
+you can use the I<#CURVER#> metavariable.
+It will be replaced by a dependency version constraint in the form of
+“(= I<binary-version>)”,
+where this would be generally be used in combination with I<#PACKAGE#>.
+
+Supported since dpkg 1.23.4.
+
 =head2 Using symbol tags
 
 Symbol tagging is useful for marking symbols that are special in some way.
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm 
b/scripts/Dpkg/Shlibs/SymbolFile.pm
index 6d25fdf06..2e210f795 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -302,6 +302,9 @@ sub replace_metavars($self, $var, %opts)
     if (exists $opts{package}) {
         $var->$* =~ s/#PACKAGE#/$opts{package}/g;
     }
+    if (exists $opts{version}) {
+        $var->$* =~ s/#CURVER#/(= $opts{version})/g;
+    }
 }
 
 sub output {
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 3dc479814..be385d913 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -355,6 +355,7 @@ test_data = \
        t/Dpkg_Shlibs/symbols.fake-1 \
        t/Dpkg_Shlibs/symbols.fake-2 \
        t/Dpkg_Shlibs/symbols.fake-3 \
+       t/Dpkg_Shlibs/symbols.fake-4 \
        t/Dpkg_Shlibs/symbols.include-1 \
        t/Dpkg_Shlibs/symbols.include-2 \
        t/Dpkg_Shlibs/symbols.include-3 \
diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl
index 4c0f6d99e..718125264 100755
--- a/scripts/dpkg-gensymbols.pl
+++ b/scripts/dpkg-gensymbols.pl
@@ -251,6 +251,7 @@ if ($stdout) {
     $output = g_('<standard output>');
     $symfile->output(\*STDOUT,
         package => $oppackage,
+        version => $sourceversion,
         template_mode => $template_mode,
         with_pattern_matches => $verbose_output,
         with_deprecated => $verbose_output,
@@ -266,6 +267,7 @@ if ($stdout) {
         debug(1, "Storing symbols in $output.");
         $symfile->save($output,
             package => $oppackage,
+            version => $sourceversion,
             template_mode => $template_mode,
             with_pattern_matches => $verbose_output,
             with_deprecated => $verbose_output,
@@ -328,10 +330,12 @@ unless ($quiet) {
     }
     $ref_symfile->output($before,
         package => $oppackage,
+        version => $sourceversion,
         template_mode => 1,
     );
     $symfile->output($after,
         package => $oppackage,
+        version => $sourceversion,
         template_mode => 1,
     );
 
diff --git a/scripts/t/Dpkg_Shlibs.t b/scripts/t/Dpkg_Shlibs.t
index 3576a0ba8..0db67ce6a 100644
--- a/scripts/t/Dpkg_Shlibs.t
+++ b/scripts/t/Dpkg_Shlibs.t
@@ -27,7 +27,7 @@ use Dpkg::ErrorHandling;
 if (! defined $Config{bin_ELF} || $Config{bin_ELF} ne 'define') {
     plan skip_all => 'only ELF is currently supported';
 }
-plan tests => 150;
+plan tests => 152;
 
 use_ok('Dpkg::Shlibs');
 use_ok('Dpkg::Shlibs::Objdump');
@@ -517,6 +517,36 @@ is($io_data,
 ', "Dump of $datadir/symbols.include-2");
 
 
+$sym_file = Dpkg::Shlibs::SymbolFile->new(
+    filename => "$datadir/symbols.fake-4",
+);
+
+$sym = $sym_file->lookup_symbol('symbol1_fake2@Base', 'libfake.so.1');
+is_deeply($sym,
+    Dpkg::Shlibs::Symbol->new(
+        symbol => 'symbol1_fake2@Base',
+        minver => '1.0',
+        dep_id => 1,
+        deprecated => 0,
+    ),
+    'symbol definition with alternative dep id using #CURVER#',
+);
+
+# Check dump output.
+open $io, '>', \$io_data or die "cannot open io string\n";
+$sym_file->output($io,
+    package => 'libfake1',
+    version => '4.0-1',
+);
+is($io_data,
+'libfake.so.1 libfake1 #MINVER#
+| libfake1 (= 4.0-1)
+ symbol1_fake2@Base 1.0 1
+ symbol2_fake2@Base 1.0
+ symbol3_fake2@Base 1.1
+', "Dump of $datadir/symbols.fake-4");
+
+
 # Check parsing of objdump output on ia64 (local symbols without versions
 # and with visibility attribute).
 $obj = load_objdump_obj('glib-ia64');
diff --git a/scripts/t/Dpkg_Shlibs/symbols.fake-4 
b/scripts/t/Dpkg_Shlibs/symbols.fake-4
new file mode 100644
index 000000000..b77f8d7b3
--- /dev/null
+++ b/scripts/t/Dpkg_Shlibs/symbols.fake-4
@@ -0,0 +1,5 @@
+libfake.so.1 #PACKAGE# #MINVER#
+| #PACKAGE# #CURVER#
+ symbol1_fake2@Base 1.0 1
+ symbol2_fake2@Base 1.0
+ symbol3_fake2@Base 1.1

-- 
Dpkg.Org's dpkg

Reply via email to