unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#55608] [PATCH] gnu: Add pbuilder.
@ 2022-05-24  7:59 Efraim Flashner
  2022-05-24 10:09 ` Maxime Devos
  0 siblings, 1 reply; 4+ messages in thread
From: Efraim Flashner @ 2022-05-24  7:59 UTC (permalink / raw)
  To: 55608; +Cc: Vagrant Cascadian, Efraim Flashner

* gnu/packages/debian.scm (pbuilder): New variable.
---
 gnu/packages/debian.scm | 145 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)

With this I was able to use `sudo -E pbuilder create` to create a new base
chroot for building packages and I was able to download the source
packages for hello to run `sudo -E pbuilder build ~/hello_2.10-2.dsc` to
actually build a hello binary.

For reproducing:
(on Guix System, in ~/.pbuilderrc, as a minimum:
PBUILDERROOTCMD="/run/setuid-programs/sudo -E")

wget https://ftp.debian.org/debian/pool/main/h/hello/hello_2.10-2.debian.tar.xz
wget https://ftp.debian.org/debian/pool/main/h/hello/hello_2.10-2.dsc
wget https://ftp.debian.org/debian/pool/main/h/hello/hello_2.10.orig.tar.gz

guix shell pbuilder -- sudo -E pbuilder create
guix shell pbuilder -- sudo -E pbuilder build /path/to/hello_2.10-2.dsc

---

diff --git a/gnu/packages/debian.scm b/gnu/packages/debian.scm
index 2efd8114be..737ff9b892 100644
--- a/gnu/packages/debian.scm
+++ b/gnu/packages/debian.scm
@@ -36,6 +36,8 @@ (define-module (gnu packages debian)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
@@ -417,6 +419,149 @@ (define-public dpkg
 handling the installation and removal of Debian software packages.")
     (license license:gpl2+)))
 
+(define-public pbuilder
+  (package
+    (name "pbuilder")
+    (version "0.231")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://salsa.debian.org/pbuilder-team/pbuilder.git/")
+               (commit version)))
+        (file-name (git-file-name name version))
+        (sha256
+         (base32 "0z6f1fgcrkfql9ayc3d0nxra2y6cn91xd5lvr0hd8gdlp9xdvxbc"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+       #:phases
+       #~(modify-phases %standard-phases
+           (delete 'configure)          ; no configure script
+           (add-after 'unpack 'patch-source
+             (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
+
+               ;; Documentation requires tldp-one-page.xsl
+               (substitute* "Makefile"
+                 ((".*-C Documentation.*") ""))
+
+               ;; Don't create #$output/var/cache/pbuilder/...
+               (substitute* '("Makefile"
+                              "pbuildd/Makefile")
+                 ((".*/var/cache/pbuilder.*") ""))
+
+               ;; Find the correct fallback location.
+               (substitute* '("pbuilder-checkparams"
+                              "pbuilder-loadconfig"
+                              "pbuilder-satisfydepends-apt"
+                              "pbuilder-satisfydepends-aptitude"
+                              "pbuilder-satisfydepends-classic"
+                              "t/test_pbuilder-satisfydepends-classic")
+                 (("\\$PBUILDER_ROOT(/usr)?") #$output))
+
+               ;; Some hardcoded paths
+               (substitute* '("debuild-pbuilder"
+                              "pbuilder"
+                              "pbuilder-buildpackage"
+                              "pbuilderrc"
+                              "pdebuild"
+                              "pdebuild-checkparams"
+                              "pdebuild-internal")
+                 (("/usr/lib/pbuilder")
+                  (string-append #$output "/lib/pbuilder")))
+               (substitute* "pbuildd/buildd-config.sh"
+                 (("/usr/share/doc/pbuilder")
+                  (string-append #$output "/share/doc/pbuilder")))
+               (substitute* "pbuilder-unshare-wrapper"
+                 (("/(s)?bin/ifconfig") "ifconfig")
+                 (("/(s)?bin/ip")
+                  (search-input-file (or native-inputs inputs) "/sbin/ip")))
+               (substitute* "Documentation/Makefile"
+                 (("/usr") ""))
+
+               ;; Ensure PATH works both in Guix and within the Debian chroot.
+               (substitute* "pbuilderrc"
+                 (("PATH=\"/usr/sbin:/usr/bin:/sbin:/bin")
+                  "PATH=\"$PATH:/usr/sbin:/usr/bin:/sbin:/bin"))))
+           (add-after 'install 'create-etc-pbuilderrc
+             (lambda* (#:key outputs #:allow-other-keys)
+               (with-output-to-file (string-append #$output "/etc/pbuilderrc")
+                 (lambda ()
+                   (format #t "# A couple of presets to make this work more smoothly.~@
+                           MIRRORSITE=\"http://deb.debian.org/debian\"~@
+                           PBUILDERSATISFYDEPENDSCMD=\"~a/lib/pbuilder/pbuilder-satisfydepends-apt\"~%"
+                           #$output)))))
+           (add-after 'install 'install-manpages
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((man (string-append #$output "/share/man/")))
+                 (install-file "debuild-pbuilder.1" (string-append man "man1"))
+                 (install-file "pdebuild.1" (string-append man "man1"))
+                 (install-file "pbuilder.8" (string-append man "man8"))
+                 (install-file "pbuilderrc.5" (string-append man "man5")))))
+           (add-after 'install-more 'wrap-programs
+             (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
+               (for-each
+                 (lambda (file)
+                   (wrap-script file
+                    `("PATH" ":" prefix
+                      (,(dirname (search-input-file (or native-inputs inputs) "/bin/cut"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/dpkg"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/grep"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/perl"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/sed"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/which"))
+                       ,(dirname (search-input-file (or native-inputs inputs) "/sbin/debootstrap"))))))
+                 (cons*
+                   (string-append #$output "/bin/pdebuild")
+                   (string-append #$output "/sbin/pbuilder")
+                   (find-files (string-append #$output "/lib/pbuilder"))))))
+           ;; Move the 'check phase to after 'install.
+           (delete 'check)
+           (add-after 'wrap-programs 'check
+             (assoc-ref %standard-phases 'check)))
+         #:make-flags
+         ;; No PREFIX, use DESTDIR instead.
+         #~(list (string-append "DESTDIR=" #$output)
+                 (string-append "SYSCONFDIR=" #$output "/etc")
+                 (string-append "BINDIR=" #$output "/bin")
+                 (string-append "PKGLIBDIR=" #$output "/lib/pbuilder")
+                 (string-append "SBINDIR=" #$output "/sbin")
+                 (string-append "PKGDATADIR=" #$output "/share/pbuilder")
+                 (string-append "EXAMPLEDIR=" #$output "/share/doc/pbuilder/examples")
+                 "PBUILDDDIR=/share/doc/pbuilder/examples/pbuildd/")))
+    (inputs
+     (list dpkg
+           debootstrap
+           grep
+           guile-3.0            ; for wrap-script
+           iproute
+           perl
+           which))
+    (native-inputs
+     (list man-db
+           util-linux))
+    (home-page "https://pbuilder-team.pages.debian.net/pbuilder/")
+    (synopsis "Personal package builder for Debian packages")
+    (description
+     "@code{pbuilder} is a personal package builder for Debian packages.
+@itemize
+@item@code{pbuilder} constructs a chroot system, and builds a package inside the
+chroot.  It is an ideal system to use to check that a package has correct
+build-dependencies.  It uses @code{apt} extensively, and a local mirror, or a
+fast connection to a Debian mirror is ideal, but not necessary.
+@item@code{pbuilder create} uses debootstrap to create a chroot image.
+@item@code{pbuilder update} updates the image to the current state of
+testing/unstable/whatever.
+@item@code{pbuilder build} takes a @code{*.dsc} file and builds a binary in the
+chroot image.
+@item@code{pdebuild} is a wrapper for Debian Developers, to allow running
+@code{pbuilder} just like @code{debuild}, as a normal user.
+@end itemize
+NOTE: For Guix System it is recommended to put
+@code{PBUILDERROOTCMD=\"/run/setuid-programs/sudo -E\"} inside of your
+@file{~/.pbuilderrc}.")
+    (license license:gpl2+)))
+
 (define-public reprepro
   (package
     (name "reprepro")

base-commit: 1a1f9e7050a9b787b2111cb5af677510a0122e2b
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#55608] [PATCH] gnu: Add pbuilder.
  2022-05-24  7:59 [bug#55608] [PATCH] gnu: Add pbuilder Efraim Flashner
@ 2022-05-24 10:09 ` Maxime Devos
  2022-05-25  8:41   ` [bug#55608] [PATCH v2] " Efraim Flashner
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Devos @ 2022-05-24 10:09 UTC (permalink / raw)
  To: Efraim Flashner, 55608; +Cc: Vagrant Cascadian

[-- Attachment #1: Type: text/plain, Size: 1546 bytes --]

Efraim Flashner schreef op di 24-05-2022 om 10:59 [+0300]:
> +           (add-after 'install-more 'wrap-programs
> +             (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
> +               (for-each
> +                 (lambda (file)
> +                   (wrap-script file
> +                    `("PATH" ":" prefix
> +                      (,(dirname (search-input-file (or native-inputs inputs) "/bin/cut"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/dpkg"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/grep"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/perl"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/sed"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/which"))
> +                       ,(dirname (search-input-file (or native-inputs inputs) "/sbin/debootstrap"))))))

Shouldn't these be inputs instead of native-inputs, because they will
end up being run when pbuilder is run?  Likewise for'patch-source'.
Also, can be simplified to

[...] "PATH" ":" prefix ,(map (compose dirname (cut search-input-file inputs <>)) '("/bin/cut" "/bin/dpkg" ...)) [...]



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#55608] [PATCH v2] gnu: Add pbuilder.
  2022-05-24 10:09 ` Maxime Devos
@ 2022-05-25  8:41   ` Efraim Flashner
  2022-05-29 13:03     ` bug#55608: " Efraim Flashner
  0 siblings, 1 reply; 4+ messages in thread
From: Efraim Flashner @ 2022-05-25  8:41 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Vagrant Cascadian, 55608


[-- Attachment #1.1: Type: text/plain, Size: 2415 bytes --]

On Tue, May 24, 2022 at 12:09:36PM +0200, Maxime Devos wrote:
> Efraim Flashner schreef op di 24-05-2022 om 10:59 [+0300]:
> > +           (add-after 'install-more 'wrap-programs
> > +             (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
> > +               (for-each
> > +                 (lambda (file)
> > +                   (wrap-script file
> > +                    `("PATH" ":" prefix
> > +                      (,(dirname (search-input-file (or native-inputs inputs) "/bin/cut"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/dpkg"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/grep"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/perl"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/sed"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/bin/which"))
> > +                       ,(dirname (search-input-file (or native-inputs inputs) "/sbin/debootstrap"))))))
> 
> Shouldn't these be inputs instead of native-inputs, because they will
> end up being run when pbuilder is run?  Likewise for'patch-source'.

I figured using (or native-inputs inputs) would help with
cross-building, but I've changed it to just inputs. Also in the other
spot where I used that. I tried cross building it before but got stuck
in one of the dependencies.

> Also, can be simplified to
> 
> [...] "PATH" ":" prefix ,(map (compose dirname (cut search-input-file inputs <>)) '("/bin/cut" "/bin/dpkg" ...)) [...]

Thanks, I knew there was some way to make it much cleaner.

I've made the changes you've suggested and also adjusted
#$output/etc/pbuilderrc to use /run/setuid-programs/sudo if it's
available and removed the note from the bottom of the package
description since it's no longer necessary.



-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #1.2: v2-0001-gnu-Add-pbuilder.patch --]
[-- Type: text/plain, Size: 8602 bytes --]

From 2daaaacb03652c53891bc95306e6d5cc8a07ab90 Mon Sep 17 00:00:00 2001
Message-Id: <2daaaacb03652c53891bc95306e6d5cc8a07ab90.1653467875.git.efraim@flashner.co.il>
From: Efraim Flashner <efraim@flashner.co.il>
Date: Tue, 24 May 2022 10:52:20 +0300
Subject: [PATCH v2] gnu: Add pbuilder.

* gnu/packages/debian.scm (pbuilder): New variable.
---
 gnu/packages/debian.scm | 151 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 150 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/debian.scm b/gnu/packages/debian.scm
index 2efd8114be..05440d9444 100644
--- a/gnu/packages/debian.scm
+++ b/gnu/packages/debian.scm
@@ -36,10 +36,13 @@ (define-module (gnu packages debian)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages wget))
+  #:use-module (gnu packages wget)
+  #:use-module (srfi srfi-26))
 
 (define-public debian-archive-keyring
   (package
@@ -417,6 +420,152 @@ (define-public dpkg
 handling the installation and removal of Debian software packages.")
     (license license:gpl2+)))
 
+(define-public pbuilder
+  (package
+    (name "pbuilder")
+    (version "0.231")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://salsa.debian.org/pbuilder-team/pbuilder.git/")
+               (commit version)))
+        (file-name (git-file-name name version))
+        (sha256
+         (base32 "0z6f1fgcrkfql9ayc3d0nxra2y6cn91xd5lvr0hd8gdlp9xdvxbc"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+       #:modules `((guix build gnu-build-system)
+                   (guix build utils)
+                   (srfi srfi-26))
+       #:phases
+       #~(modify-phases %standard-phases
+           (delete 'configure)          ; no configure script
+           (add-after 'unpack 'patch-source
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+
+               ;; Documentation requires tldp-one-page.xsl
+               (substitute* "Makefile"
+                 ((".*-C Documentation.*") ""))
+
+               ;; Don't create #$output/var/cache/pbuilder/...
+               (substitute* '("Makefile"
+                              "pbuildd/Makefile")
+                 ((".*/var/cache/pbuilder.*") ""))
+
+               ;; Find the correct fallback location.
+               (substitute* '("pbuilder-checkparams"
+                              "pbuilder-loadconfig"
+                              "pbuilder-satisfydepends-apt"
+                              "pbuilder-satisfydepends-aptitude"
+                              "pbuilder-satisfydepends-classic"
+                              "t/test_pbuilder-satisfydepends-classic")
+                 (("\\$PBUILDER_ROOT(/usr)?") #$output))
+
+               ;; Some hardcoded paths
+               (substitute* '("debuild-pbuilder"
+                              "pbuilder"
+                              "pbuilder-buildpackage"
+                              "pbuilderrc"
+                              "pdebuild"
+                              "pdebuild-checkparams"
+                              "pdebuild-internal")
+                 (("/usr/lib/pbuilder")
+                  (string-append #$output "/lib/pbuilder")))
+               (substitute* "pbuildd/buildd-config.sh"
+                 (("/usr/share/doc/pbuilder")
+                  (string-append #$output "/share/doc/pbuilder")))
+               (substitute* "pbuilder-unshare-wrapper"
+                 (("/(s)?bin/ifconfig") "ifconfig")
+                 (("/(s)?bin/ip") (search-input-file inputs "/sbin/ip")))
+               (substitute* "Documentation/Makefile"
+                 (("/usr") ""))
+
+               ;; Ensure PATH works both in Guix and within the Debian chroot.
+               (substitute* "pbuilderrc"
+                 (("PATH=\"/usr/sbin:/usr/bin:/sbin:/bin")
+                  "PATH=\"$PATH:/usr/sbin:/usr/bin:/sbin:/bin"))))
+           (add-after 'install 'create-etc-pbuilderrc
+             (lambda* (#:key outputs #:allow-other-keys)
+               (with-output-to-file (string-append #$output "/etc/pbuilderrc")
+                 (lambda ()
+                   (format #t "# A couple of presets to make this work more smoothly.~@
+                           MIRRORSITE=\"http://deb.debian.org/debian\"~@
+                           if [ -r /run/setuid-programs/sudo ]; then~@
+                               PBUILDERROOTCMD=\"/run/setuid-programs/sudo -E\"~@
+                           fi~@
+                           PBUILDERSATISFYDEPENDSCMD=\"~a/lib/pbuilder/pbuilder-satisfydepends-apt\"~%"
+                           #$output)))))
+           (add-after 'install 'install-manpages
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((man (string-append #$output "/share/man/")))
+                 (install-file "debuild-pbuilder.1" (string-append man "man1"))
+                 (install-file "pdebuild.1" (string-append man "man1"))
+                 (install-file "pbuilder.8" (string-append man "man8"))
+                 (install-file "pbuilderrc.5" (string-append man "man5")))))
+           (add-after 'install 'wrap-programs
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (for-each
+                 (lambda (file)
+                   (wrap-script file
+                    `("PATH" ":" prefix
+                      ,(map (compose dirname (cut search-input-file inputs <>))
+                            (list "/bin/cut"
+                                  "/bin/dpkg"
+                                  "/bin/grep"
+                                  "/bin/perl"
+                                  "/bin/sed"
+                                  "/bin/which"
+                                  "/sbin/debootstrap")))))
+                 (cons*
+                   (string-append #$output "/bin/pdebuild")
+                   (string-append #$output "/sbin/pbuilder")
+                   (find-files (string-append #$output "/lib/pbuilder"))))))
+           ;; Move the 'check phase to after 'install.
+           (delete 'check)
+           (add-after 'validate-runpath 'check
+             (assoc-ref %standard-phases 'check)))
+         #:make-flags
+         ;; No PREFIX, use DESTDIR instead.
+         #~(list (string-append "DESTDIR=" #$output)
+                 (string-append "SYSCONFDIR=" #$output "/etc")
+                 (string-append "BINDIR=" #$output "/bin")
+                 (string-append "PKGLIBDIR=" #$output "/lib/pbuilder")
+                 (string-append "SBINDIR=" #$output "/sbin")
+                 (string-append "PKGDATADIR=" #$output "/share/pbuilder")
+                 (string-append "EXAMPLEDIR=" #$output "/share/doc/pbuilder/examples")
+                 "PBUILDDDIR=/share/doc/pbuilder/examples/pbuildd/")))
+    (inputs
+     (list dpkg
+           debootstrap
+           grep
+           guile-3.0            ; for wrap-script
+           iproute
+           perl
+           which))
+    (native-inputs
+     (list man-db
+           util-linux))
+    (home-page "https://pbuilder-team.pages.debian.net/pbuilder/")
+    (synopsis "Personal package builder for Debian packages")
+    (description
+     "@code{pbuilder} is a personal package builder for Debian packages.
+@itemize
+@item@code{pbuilder} constructs a chroot system, and builds a package inside the
+chroot.  It is an ideal system to use to check that a package has correct
+build-dependencies.  It uses @code{apt} extensively, and a local mirror, or a
+fast connection to a Debian mirror is ideal, but not necessary.
+@item@code{pbuilder create} uses debootstrap to create a chroot image.
+@item@code{pbuilder update} updates the image to the current state of
+testing/unstable/whatever.
+@item@code{pbuilder build} takes a @code{*.dsc} file and builds a binary in the
+chroot image.
+@item@code{pdebuild} is a wrapper for Debian Developers, to allow running
+@code{pbuilder} just like @code{debuild}, as a normal user.
+@end itemize")
+    (license license:gpl2+)))
+
 (define-public reprepro
   (package
     (name "reprepro")

base-commit: d129d962e437fd215c5e9428fc1b26e2d72ffbda
-- 
2.36.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#55608: [PATCH v2] gnu: Add pbuilder.
  2022-05-25  8:41   ` [bug#55608] [PATCH v2] " Efraim Flashner
@ 2022-05-29 13:03     ` Efraim Flashner
  0 siblings, 0 replies; 4+ messages in thread
From: Efraim Flashner @ 2022-05-29 13:03 UTC (permalink / raw)
  To: 55608-done

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

Patch pushed. Thanks for the review!

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-29 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-24  7:59 [bug#55608] [PATCH] gnu: Add pbuilder Efraim Flashner
2022-05-24 10:09 ` Maxime Devos
2022-05-25  8:41   ` [bug#55608] [PATCH v2] " Efraim Flashner
2022-05-29 13:03     ` bug#55608: " Efraim Flashner

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).