Control: tags -1 + patch

On 2023-01-09 19:46 +0100, Sven Joachim wrote:

> Package: dh-exec
> Version: 0.27
> Severity: important
>
> Looking for solutions to bug #1028202 (install the ncurses-base terminfo
> files into /usr/share/terminfo), the dh-exec documentation seemed
> promising to me, according to its README.md
>
> ,----
> | Additionally, assuming we have two binary packages: `foo-gtk` and 
> `foo-utils`,
> | and we want to include `/usr/bin/foo-gtk` in the former package, the rest of
> | `/usr/bin` in the latter. Our install files would look like these, for 
> `foo-gtk`
> | and `foo-utils` respectively:
> |
> |     #! /usr/bin/dh-exec
> |     => /usr/bin/foo-gtk
> |
> |     #! /usr/bin/dh-exec
> |     /usr/bin/*
> `----
>
> as well as the dh-exec-install manpage:
>
> ,----
> | The second extension follows a simpler syntax: any filename
> | prefixed with "=>" will be moved instead of copied to the package.
> | This allows one to move a file out of a directory to a package,
> | and install the rest of the files in the same dir into another
> | package.
> `----
>
> So I figured out I would use these ncurses-{base,term}.install files:
>
> ,----ncurses-base.install----
> | #! /usr/bin/dh-exec
> | usr/share/tabset
> | etc/terminfo
> | => usr/share/terminfo/E/Eterm
> | => usr/share/terminfo/E/Eterm-color
> | [...] etc.
> `---
>
> ,----ncurses-term.install---
> | usr/share/terminfo
> `----
>
> Unfortunately this did not quite work as expected:
>
> ,----
> | dh_install -i
> | Failed to move 'usr/share/terminfo/E/Eterm': No such file or
> | directory at /usr/share/dh-exec/dh-exec-install-rename line 65, <>
> | line 3.
> | dh_install: error: debian/ncurses-base.install (executable config) returned 
> exit code 127
> `----
>
> The file in question, usr/share/terminfo/E/Eterm, exists in debian/tmp,
> but dh-exec-install-rename does not look there in line 65.  Prefixing
> all the usr/terminfo/*/* files in ncurses-base.install with a leading
> debian/tmp lets the build complete, but then this leading debian/tmp
> also ends up in the resulting ncurses-base*.deb. :-(
>
> The attached patch works for me, but I have not checked whether it
> passes the tests yet.  Writing a new regression test would probably also
> be desirable.

I have done that now, see the attached patch that has been tested
successfully in my sbuild chroot.  I have also created a merge request
on salsa:

https://salsa.debian.org/debian/dh-exec/-/merge_requests/2

The pipeline for my commit is still pending, I guess salsa is rather
busy at the moment.

Cheers,
       Sven


From 42928117d27372abc661c7f4cbb3b4f9528423ff Mon Sep 17 00:00:00 2001
From: Sven Joachim <svenj...@gmx.de>
Date: Mon, 9 Jan 2023 20:14:34 +0100
Subject: [PATCH] Look in debian/tmp for files to move

Commit ef2b851418d0 introduced a new feature where filenames prefixed
with => would be moved rather than copied from the source to the
destination.  Unfortunately it would fail when the files are located
in debian/tmp, which is the most common use case for this feature.

Also add a new test to ensure that this feature works.

Closes: #1028347
---
 lib/dh-exec-install-rename |  2 ++
 t/test_install_move.bats   | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/lib/dh-exec-install-rename b/lib/dh-exec-install-rename
index 7d4d993..d8b0355 100755
--- a/lib/dh-exec-install-rename
+++ b/lib/dh-exec-install-rename
@@ -63,6 +63,8 @@ if (/([^\s]*)\s+=>\s+([^\s]*)/ || /^=>\s+([^\s]*)/) {

         if ($move_this) {
             move ($src, File::Spec->catfile ($debpath, $dstfile)) or
+		move (File::Spec->catfile ("debian/tmp", $src),
+		      File::Spec->catfile ($debpath, $dstfile)) or
                 die "Failed to move '$src': $!";
         } else {
             cp ($src, File::Spec->catfile ($debpath, $dstfile)) or
diff --git a/t/test_install_move.bats b/t/test_install_move.bats
index 93b66e7..298340d 100755
--- a/t/test_install_move.bats
+++ b/t/test_install_move.bats
@@ -25,6 +25,19 @@ EOF
     ! [ -f var/lib/dh-exec/test-output ]
 }

+@test "install: moving from debian/tmp works" {
+    install -d debian/tmp/var/lib/dh-exec
+    echo foo >debian/tmp/var/lib/dh-exec/test-output
+
+    run_dh_exec_with_input .install <<EOF
+#! ${top_builddir}/src/dh-exec-install
+=> var/lib/dh-exec/test-output
+EOF
+
+    expect_file "/var/lib/dh-exec/test-output"
+    ! [ -f debian/tmp/var/lib/dh-exec/test-output ]
+}
+
 @test "install: rename takes priority over move" {
     install -d var/lib/dh-exec
     echo foo >var/lib/dh-exec/test-output
--
2.39.0

Reply via email to