> > This corresponds to the
> > 
> >     $(MAKE_DIR) $(TMPDIR)/usr/lib
> > 
> > line in debian/rules. Here MAKE_DIR expands to
> > 
> >     install -p -d -o root -g root -m 755
> > 
> > which fails due to insufficient permissions.
> > 
> > Omitting the -o and -g options would likely fix the problem, but
> > that might cause other issues because then all installed files and
> > directories will be owned by the UID/GID that invoked make.
> > 
> > What do you suggest?
> > 
> > Thanks
> > Andre
> 
> Ideally, in the case of liblopsub, the *Debian* build would have the
> expanded $(MAKE_DIR) resolve **without** `-o root -g root`. Based on the
> code, I think you can pretty much just remove `INST_OWN` from `debian/rules`
> and it should work.
> 
> For this to fully work, you should also have a call to `dh_fixperms` at the
> right place. In this case, adding it just before `dh_makeshlibs` should be
> fine. Double check it does not change any mode that is important in your
> case (in most cases, it will not).
> 
> With these two changes in place, liblopsub should be able to build without
> requiring any form of root during the `binary` target. You can test this by
> adding `Rules-Requires-Root: no` to the source stanza of `debian/control`
> (e.g., just before the `Standards-Versions` field).

Thanks for the detailed instructions, very much appreciated. I've
implemented your suggestions as per the patch below. With the patch
applied, building as an unprivileged user works for me.

If you prefer git over applying patches manually, you may fetch and
check out the `pu` branch of the public repo. This branch contains
the patch as a single commit on top of the current `debian` branch.

Please let me know whether this works for you as well, and whether
you are OK with the commit message.

Best
Andre
---
commit d074816e0cf35974d23ec1c5cf6410b0f4480901
Author: Andre Noll <m...@tuebingen.mpg.de>
Date:   Mon Dec 9 19:29:01 2024 +0100

    debian: Enable `Rules-Requires-Root: no`.
    
    During a test rebuild for building packages with `Rules-Requires-Root:
    no` as the default in `dpkg`, liblopsub failed to rebuild.
    
    The problem is the rule of the `binary` target in `debian/rules` which
    runs `install(1)` with -o root -g root to set the owner and group ID of
    the files and directories being installed. With `Rules-Requires-Root:
    no`, this fails due to insufficient permissions. This commit removes
    the problematic options in favor of running `dh_fixperms(1)` just
    before `dh_makeshlibs(1)`.
    
    With these changes in place, the build no longer requires any form of
    root during the `binary` target. Consequently, we may enable rootless
    builds in `debian/control`.
    
    Reported-by: Niels Thykier <ni...@thykier.net>
    Suggested-by: Niels Thykier <ni...@thykier.net>

diff --git a/debian/control b/debian/control
index 668fbd9..b349eba 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Standards-Version: 4.6.2
 Homepage: https://people.tuebingen.mpg.de/maan/lopsub
 Vcs-Browser: https://git.tuebingen.mpg.de/lopsub.git
 Vcs-Git: https://git.tuebingen.mpg.de/lopsub.git
+Rules-Requires-Root: no
 
 Package: liblopsub1t64
 Section: libs
diff --git a/debian/rules b/debian/rules
index 4f5f5ca..9801fe6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,9 +36,8 @@ clean:
        $(MAKE) distclean
        dh_clean
 
-INST_OWN = -o root -g root
-MAKE_DIR = install -p -d $(INST_OWN) -m 755
-INST_FILE = install -c $(INST_OWN) -m 644
+MAKE_DIR = install -p -d -m 755
+INST_FILE = install -c -m 644
 
 binary: build
        $(checkdir)
@@ -59,6 +58,7 @@ binary: build
        $(INST_FILE) debian/changelog $(DEVDOCS_DIR)/changelog.Debian
        gzip -fn9 $(DOCS_DIR)/changelog.Debian
        gzip -fn9 $(DEVDOCS_DIR)/changelog.Debian
+       dh_fixperms
        dh_makeshlibs
        dh_shlibdeps
        dh_strip
-- 
Max Planck Institute for Biology
Tel: (+49) 7071 601 829
Max-Planck-Ring 5, 72076 Tübingen, Germany
http://people.tuebingen.mpg.de/maan/

Reply via email to