unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Marius Bakke <mbakke@fastmail.com>
To: Efraim Flashner <efraim@flashner.co.il>, 30709@debbugs.gnu.org
Subject: [bug#30709] [PATCH 4/4] gnu: Add debootstrap.
Date: Sat, 10 Mar 2018 10:48:32 +0100	[thread overview]
Message-ID: <87a7vgjm6n.fsf@fastmail.com> (raw)
In-Reply-To: <20180305092907.1191-4-efraim@flashner.co.il>


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

Efraim Flashner <efraim@flashner.co.il> writes:

> * gnu/packages/debian.scm (debootstrap): New variable.

Thanks for packaging this!  I've worked on this too, and actually
packaged 'dpkg' separately.  Yet somehow I did not need to package the
keyrings (I guess it is necessary to work offline?).

Some comments inline, and my dpkg and debootstrap patches attached for
comparison.  Feel free to take inspiration from both.

> +(define-public debootstrap
> +  (package
> +    (name "debootstrap")
> +    (version "1.0.93")
> +    (source
> +      (origin
> +        (method git-fetch)
> +        (uri (git-reference
> +               (url "https://anonscm.debian.org/cgit/d-i/debootstrap.git")
> +               (commit version)))
> +        (file-name (git-file-name name version))

Why use the git downloader here?

> +        (sha256
> +         (base32
> +          "1jxq91602a152c56l2f8kzkiszp26cziqddcs4v695bcif72kfz6"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:phases
> +       (modify-phases %standard-phases
> +         (delete 'configure)
> +         (delete 'build)
> +         (add-after 'unpack 'patch-source
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let ((out    (assoc-ref outputs "out"))
> +                   (debian (assoc-ref %build-inputs "debian"))
> +                   (ubuntu (assoc-ref %build-inputs "ubuntu")))

Use (assoc-ref inputs "debian") instead of accessing the global
%build-inputs.  I'd also call them "debian-keyring" and "ubuntu-keyring"
to make it clearer what's going on down below.

> +               (substitute* "scripts/sid"
> +                 (("/usr") debian))
> +               (substitute* "scripts/gutsy"
> +                 (("/usr") ubuntu))
> +               (substitute* "debootstrap"
> +                 (("=/usr") (string-append "=" out))
> +                 (("@VERSION@") ,version))

If you don't delete the build phase, @VERSION@ should be automatically
expanded to the correct value, methinks.

> +               (substitute* "functions"
> +                 (("wget ") (string-append (which "wget") " ")))
> +               #t)))
> +         (replace 'install
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (copy-recursively "scripts"
> +                                 (string-append out "/share/debootstrap/scripts"))
> +               (install-file "functions" (string-append out "/share/debootstrap"))
> +               (install-file "debootstrap" (string-append out "/sbin"))
> +               (install-file "debootstrap.8" (string-append out "/share/man/man8"))
> +               #t))))

Similarly, passing DESTDIR in #:make-flags should make this unnecessary.

> +       #:tests? #f)) ; no tests
> +    (inputs
> +     `(("debian" ,debian-archive-keyring)
> +       ("ubuntu" ,ubuntu-keyring)
> +       ("wget" ,wget)))
> +    ;; The following are required for debootstrap to work correctly
> +    (propagated-inputs
> +     `(("binutils" ,binutils)
> +       ("gnupg" ,gnupg)
> +       ("perl" ,perl)))
> +    (home-page "https://anonscm.debian.org/cgit/d-i/debootstrap.git")
> +    (synopsis "Bootstrap a basic Debian system")
> +    (description "Debootstrap is used to create a Debian base system from
> +scratch, without requiring the availability of @code{dpkg} or @code{apt}.
> +It does this by downloading .deb files from a mirror site, and carefully
> +unpacking them into a directory which can eventually be chrooted into.")
> +    (license license:gpl2)))

I have not tried this debootstrap, but when testing the attached patch,
I found that debootstrap would fail on the first attempt, but simply
trying again made everything work.  Did you experience this?  Note that
I did not propagate binutils, perhaps that was the problem.

Or the confusion between Guix dpkg and the debootstrapped dpkg.

Behold...


[-- Attachment #1.2: 0001-gnu-Add-dpkg.patch --]
[-- Type: text/x-patch, Size: 2159 bytes --]

From 62795e10a95f393ab3a65d649ef3a30ccd8fece2 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Fri, 5 Jan 2018 15:58:45 +0100
Subject: [PATCH] gnu: Add dpkg.

* gnu/packages/package-management.scm (dpkg): New public variable.
---
 gnu/packages/package-management.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 7eba74e96..451af238c 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -46,6 +47,7 @@
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages lisp)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages nettle)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages perl-check)
@@ -349,6 +351,28 @@ out) and returning a package that uses that as its 'source'."
 ;;; Other tools.
 ;;;
 
+(define-public dpkg
+  (package
+    (name "dpkg")
+    (version "1.19.0.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://debian/pool/main/d/dpkg/dpkg_"
+                                  version ".tar.xz"))
+              (sha256
+               (base32 "02lrwrkl2g1jwj71088rwswx07a1zq1jkq7193lbvy8jj2qnp9lq"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("ncurses" ,ncurses)
+       ("perl" ,perl)))
+    (home-page "https://wiki.debian.org/Teams/Dpkg")
+    (synopsis "Debian package manager")
+    (description
+     "@command{dpkg} is a low-level package management tool, primarily developed
+for use in Debian.  It can install, remove and show information about @file{.deb}
+packages.")
+    (license gpl2+)))
+
 (define-public nix
   (package
     (name "nix")
-- 
2.16.2


[-- Attachment #1.3: 0002-gnu-Add-debootstrap.patch --]
[-- Type: text/x-patch, Size: 4889 bytes --]

From 7e4ec4b1e8ad602c797d192dc6c5f573664c50d4 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Fri, 5 Jan 2018 16:45:19 +0100
Subject: [PATCH] gnu: Add debootstrap.

* gnu/packages/debootstrap.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
---
 gnu/local.mk                 |  1 +
 gnu/packages/debootstrap.scm | 81 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 gnu/packages/debootstrap.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index fb4babfdb..cf4e23117 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -119,6 +119,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/dav.scm				\
   %D%/packages/dc.scm				\
   %D%/packages/debug.scm			\
+  %D%/packages/debootstrap.scm			\
   %D%/packages/dejagnu.scm			\
   %D%/packages/dico.scm				\
   %D%/packages/dictionaries.scm			\
diff --git a/gnu/packages/debootstrap.scm b/gnu/packages/debootstrap.scm
new file mode 100644
index 000000000..e2a19ba2b
--- /dev/null
+++ b/gnu/packages/debootstrap.scm
@@ -0,0 +1,81 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages debootstrap)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages package-management)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages wget)
+  #:use-module (gnu packages))
+
+(define-public debootstrap
+  (package
+    (name "debootstrap")
+    (version "1.0.93")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://debian/pool/main/d/debootstrap/"
+                                  "debootstrap_" version ".tar.gz"))
+              (sha256
+               (base32
+                "1nyp9fwb7xrk1vin81dmgx2g9rb52yg4gwz4rcx97gamw4mlvbfd"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out")))
+       #:tests? #f                    ;no tests
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'fix-Makefile
+                    (lambda _
+                      (substitute* "Makefile"
+                        (("/usr") "")
+                        (("-o root -g root") "")
+                        (("chown root.*") "\n"))
+                      #t))
+                  (add-after 'fix-Makefile 'patch-paths
+                    (lambda* (#:key inputs outputs #:allow-other-keys)
+                      (let ((out (assoc-ref outputs "out"))
+                            (dpkg (assoc-ref inputs "dpkg"))
+                            (wget (assoc-ref inputs "wget")))
+                      (substitute* "debootstrap"
+                        (("/usr/share/debootstrap")
+                         (string-append out "/share/debootstrap"))
+                        (("/usr/bin/dpkg") (string-append dpkg "/bin/dpkg")))
+                      (substitute* "functions"
+                        (("wget ") (string-append wget "/bin/wget ")))
+                      #t)))
+                  (delete 'configure))))
+    (inputs
+     `(("wget" ,wget)))
+    ;; The bootstrapping scripts contain many references to these packages, some
+    ;; of which referring to the target system.  For simplicity just propagate them
+    ;; instead of adding absolute references.
+    (propagated-inputs
+     `(("dpkg" ,dpkg)
+       ("perl" ,perl)))
+    (home-page "https://wiki.debian.org/Debootstrap")
+    (synopsis "Bootstrap a Debian or Ubuntu system")
+    (description
+     "@command{debootstrap} is a tool which will install a Debian base system
+into a subdirectory of another, already installed system.  It does not require
+an installation CD, just access to a Debian repository.  It can also be used to
+create a rootfs for a machine of a different architecture, which is known as
+\"cross-debootstrapping\".")
+    (license license:gpl2+)))
-- 
2.16.2


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

  reply	other threads:[~2018-03-10  9:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05  9:26 [bug#30709] [PATCH 0/4] Add debootstrap Efraim Flashner
2018-03-05  9:29 ` [bug#30709] [PATCH 1/4] gnu: Add jetring Efraim Flashner
2018-03-05  9:29   ` [bug#30709] [PATCH 2/4] gnu: Add debian-archive-keyring Efraim Flashner
2018-03-10  9:30     ` Marius Bakke
2018-03-05  9:29   ` [bug#30709] [PATCH 3/4] gnu: Add ubuntu-keyring Efraim Flashner
2018-03-10  9:33     ` Marius Bakke
2018-03-12 18:42       ` Efraim Flashner
2018-03-05  9:29   ` [bug#30709] [PATCH 4/4] gnu: Add debootstrap Efraim Flashner
2018-03-10  9:48     ` Marius Bakke [this message]
2018-03-10  9:29   ` [bug#30709] [PATCH 1/4] gnu: Add jetring Marius Bakke
2018-03-11 10:11     ` Efraim Flashner
2018-03-22 12:45 ` bug#30709: patch pushed Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a7vgjm6n.fsf@fastmail.com \
    --to=mbakke@fastmail.com \
    --cc=30709@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).