From unknown Wed Jun 18 23:08:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#49348 <49348@debbugs.gnu.org> To: bug#49348 <49348@debbugs.gnu.org> Subject: Status: [PATCH] pack: Allow embedding custom control files in deb packs. Reply-To: bug#49348 <49348@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:08:05 +0000 retitle 49348 [PATCH] pack: Allow embedding custom control files in deb pac= ks. reassign 49348 guix-patches submitter 49348 Maxim Cournoyer severity 49348 normal tag 49348 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 03 02:07:00 2021 Received: (at submit) by debbugs.gnu.org; 3 Jul 2021 06:07:00 +0000 Received: from localhost ([127.0.0.1]:37782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzYnr-0000D2-Qo for submit@debbugs.gnu.org; Sat, 03 Jul 2021 02:07:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:59164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzYnp-0000Cu-FT for submit@debbugs.gnu.org; Sat, 03 Jul 2021 02:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzYnp-0006Gq-8Q for guix-patches@gnu.org; Sat, 03 Jul 2021 02:06:57 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:46895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzYnm-00060C-GQ for guix-patches@gnu.org; Sat, 03 Jul 2021 02:06:56 -0400 Received: by mail-qt1-x836.google.com with SMTP id h2so151628qtq.13 for ; Fri, 02 Jul 2021 23:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=19E8g+775AmkFZmtyprmEQs1UL2ov7DX7S34Z0FA8D8=; b=RPhZUXsvFCt5WAqw+2rH8rZ6rBrF/YNYeqbTd86mpBazS3xzsAwx4V8WuETewAYiKn f4IGhiWEHq8bame9xKQauXtM1DNWrE7NYStOJTq9Ngcs6sGuuepDv/2x4iCyv85GNFZU oFocvcQaUmS6r2ySETG242mbbWf75TfX3NEcahHTMkNLjf+YcU+NF1JvIEhUPhpPU6IL TLvtQcHvICQKqQoHyoVRVqs9Eu8H1bc36ELiwJHndU+ODAvx467dMYS0sAwClcg+ZbPM Mys3iln74KyDVzDbDgbThhcv7BDAsKXN4MTg0tlqNZ6jyjEjzOD0nZrE41xeFegm/NrV 93qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=19E8g+775AmkFZmtyprmEQs1UL2ov7DX7S34Z0FA8D8=; b=NHczTGJ78EACN4/ITF+c8uBqfkVCeS7rYgIKkLavw4h3cDU6deRk9SivdVpnFGYdgK IkKjWqUoUV8QUHmXTnM8m6hRO3vSXhNkztqYkr+hXHrZqNsuCWicK3f7h8/dT4FpD2yS hd4lHALWflosycPM/pZ1AQXZaTs+H8BUrk8zXk1H8HsIGy9eVft8HXDTHvUJTIhwjgEm /5vIJmMoWcwdFvpdFkL8cp0jJ4h2nZ/XqIf0nBQRFZ5LzMKDqWDC55zUQz6KXfVaIg/j brrgwsr17wnCZc1QEYqhRKxsSkSUz3+fKhB4aDwtBEpDzUYGprRe1Vi2/ULIq0DyEs+N SC3Q== X-Gm-Message-State: AOAM5300VDVhYllNb45FEdnXga/thLXVv0r9BcSd23aeSIMmqdibhb+F HK+qjy7Ln7YWQmBeEL5+SPuWYXi6yQTbVQ== X-Google-Smtp-Source: ABdhPJw85KdD0VRAehkDkkwW5R1doeVG1LPHzn4IYu7cy5L8pBuxh5ZqMrGSoibM22pJ4B5N9r7hyw== X-Received: by 2002:ac8:5bc4:: with SMTP id b4mr3135005qtb.180.1625292413110; Fri, 02 Jul 2021 23:06:53 -0700 (PDT) Received: from localhost.localdomain (dsl-10-132-56.b2b2c.ca. [72.10.132.56]) by smtp.gmail.com with ESMTPSA id v15sm2384136qkb.104.2021.07.02.23.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 23:06:52 -0700 (PDT) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH] pack: Allow embedding custom control files in deb packs. Date: Sat, 3 Jul 2021 02:06:42 -0400 Message-Id: <20210703060642.2424-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * guix/scripts/pack.scm (self-contained-tarball/builder) [extra-options]: New argument. (self-contained-tarball, squashfs-image, docker-image) (debian-archive): Likewise. Remove two TODO comments. Document EXTRA-OPTIONS. Use the custom control files when provided. (%deb-format-options): New variable. (show-deb-format-options, show-deb-format-options/detailed): New procedures. (%options): Register new options. (show-help): Augment with new usage. (guix-pack): Validate and propagate new argument values. * doc/guix.texi (Invoking guix pack)[deb]: Document how to list advanced options. Add an example. * tests/pack.scm (deb archive...): Provide extra-options to the debian-archive procedure, and validate that the provided files are embedded in the pack. --- doc/guix.texi | 8 +++ guix/scripts/pack.scm | 121 +++++++++++++++++++++++++++++++++++------- tests/pack.scm | 27 ++++++++-- 3 files changed, 133 insertions(+), 23 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8681645021..4bdc4e4127 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6047,6 +6047,14 @@ such file or directory'' message. This produces a Debian archive (a package with the @samp{.deb} file extension) containing all the specified binaries and symbolic links, that can be installed on top of any dpkg-based GNU(/Linux) distribution. +Advanced options can be revealed via the @option{--help-deb-format} +option. They allow embedding control files for more fine-grained +control, such as activating specific triggers or providing a maintainer +configure script to run arbitrary setup code upon installation. + +@example +guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello +@end example @quotation Note Because archives produced with @command{guix pack} contain a collection diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 6d8b70d1c7..6a8d49e042 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -205,7 +205,8 @@ its source property." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return the G-Expression of the builder used for self-contained-tarball." (define database (and localstatedir? @@ -324,7 +325,8 @@ its source property." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a self-contained tarball containing a store initialized with the closure of PROFILE, a derivation. The tarball contains /gnu/store; if LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db @@ -389,7 +391,8 @@ to the search paths of PROFILE." entry-point localstatedir? (symlinks '()) - (archiver squashfs-tools)) + (archiver squashfs-tools) + (extra-options '())) "Return a squashfs image containing a store initialized with the closure of PROFILE, a derivation. The image contains a subset of /gnu/store, empty mount points for virtual file systems (like procfs), and optional symlinks. @@ -567,7 +570,8 @@ added to the pack." entry-point localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a derivation to construct a Docker image of PROFILE. The image is a tarball conforming to the Docker Image Specification, compressed with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it @@ -654,8 +658,6 @@ the image." ;;; TODO: When relocatable option is selected, install to a unique prefix. ;;; This would enable installation of multiple deb packs with conflicting ;;; files at the same time. -;;; TODO: Allow passing a custom control file from the CLI. -;;; TODO: Allow providing a postinst script. (define* (debian-archive name profile #:key target (profile-name "guix-profile") @@ -664,7 +666,8 @@ the image." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a Debian archive (.deb) containing a store initialized with the closure of PROFILE, a derivation. The archive contains /gnu/store; if LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db @@ -672,7 +675,8 @@ with a properly initialized store database. The supported compressors are \"none\", \"gz\" or \"xz\". SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be -added to the pack." +added to the pack. EXTRA-OPTIONS may contain the CONFIG-FILE, POSTINST-FILE +or TRIGGERS-FILE keyword arguments." ;; For simplicity, limit the supported compressors to the superset of ;; compressors able to compress both the control file (gz or xz) and the ;; data tarball (gz, bz2 or xz). @@ -714,21 +718,23 @@ Valid compressors are: ~a~%") compressor-name %valid-compressors))) (guix build utils) (guix profiles) (ice-9 match) + ((oop goops) #:select (get-keyword)) (srfi srfi-1)) (define machine-type ;; Extract the machine type from the specified target, else from the ;; current system. - (and=> (or #$target %host-type) (lambda (triplet) - (first (string-split triplet #\-))))) + (and=> (or #$target %host-type) + (lambda (triplet) + (first (string-split triplet #\-))))) (define (gnu-machine-type->debian-machine-type type) "Translate machine TYPE from the GNU to Debian terminology." ;; Debian has its own jargon, different from the one used in GNU, for ;; machine types (see data/cputable in the sources of dpkg). (match type - ("i586" "i386") ("i486" "i386") + ("i586" "i386") ("i686" "i386") ("x86_64" "amd64") ("aarch64" "arm64") @@ -773,21 +779,40 @@ Valid compressors are: ~a~%") compressor-name %valid-compressors))) (copy-file #+data-tarball data-tarball-file-name) + ;; Generate the control archive. + (define control-file + (get-keyword #:control-file '#$extra-options)) + + (define postinst-file + (get-keyword #:postinst-file '#$extra-options)) + + (define triggers-file + (get-keyword #:triggers-file '#$extra-options)) + (define control-tarball-file-name (string-append "control.tar" #$(compressor-extension compressor))) ;; Write the compressed control tarball. Only the control file is ;; mandatory (see: 'man deb' and 'man deb-control'). - (call-with-output-file "control" - (lambda (port) - (format port "\ + (if control-file + (copy-file control-file "control") + (call-with-output-file "control" + (lambda (port) + (format port "\ Package: ~a Version: ~a Description: Debian archive generated by GNU Guix. Maintainer: GNU Guix Architecture: ~a -~%" package-name package-version architecture))) +~%" package-name package-version architecture)))) + + (when postinst-file + (copy-file postinst-file "postinst") + (chmod "postinst" #o755)) + + (when triggers-file + (copy-file triggers-file "triggers")) (define tar (string-append #+archiver "/bin/tar")) @@ -796,7 +821,9 @@ Architecture: ~a #:tar tar #:compressor '#+(and=> compressor compressor-command)) "-cvf" ,control-tarball-file-name - "control")) + "control" + ,@(if postinst-file '("postinst") '()) + ,@(if triggers-file '("triggers") '()))) ;; Create the .deb archive using GNU ar. (invoke (string-append #+binutils "/bin/ar") "-rv" #$output @@ -1157,6 +1184,34 @@ last resort for relocation." deb Debian archive installable via dpkg/apt")) (newline)) +(define %deb-format-options + (let ((required-option (lambda (symbol) + (option (list (symbol->string symbol)) #t #f + (lambda (opt name arg result . rest) + (apply values + (alist-cons symbol arg result) + rest)))))) + (list (required-option 'control-file) + (required-option 'postinst-file) + (required-option 'triggers-file)))) + +(define (show-deb-format-options) + (display (G_ " + --help-deb-format list options specific to the deb format"))) + +(define (show-deb-format-options/detailed) + (display (G_ " + --control-file=FILE + Embed the provided control FILE")) + (display (G_ " + --postinst-file=FILE + Embed the provided postinst script")) + (display (G_ " + --triggers-file=FILE + Embed the provided triggers FILE")) + (newline) + (exit 0)) + (define %options ;; Specifications of the command-line options. (cons* (option '(#\h "help") #f #f @@ -1250,7 +1305,12 @@ last resort for relocation." (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) - (append %transformation-options + (option '("help-deb-format") #f #f + (lambda args + (show-deb-format-options/detailed))) + + (append %deb-format-options + %transformation-options %standard-build-options))) (define (show-help) @@ -1260,6 +1320,8 @@ Create a bundle of PACKAGE.\n")) (newline) (show-transformation-options-help) (newline) + (show-deb-format-options) + (newline) (display (G_ " -f, --format=FORMAT build a pack in the given FORMAT")) (display (G_ " @@ -1369,6 +1431,18 @@ Create a bundle of PACKAGE.\n")) (else (packages->manifest packages)))))) + (define (process-file-arg opts name) + ;; Validate that the file exists and return it as a object, + ;; else #f. + (let ((value (assoc-ref opts name))) + (match value + ((and (? string?) (not (? file-exists?))) + (leave (G_ "file provided with option ~a does not exist: ~a~%") + (string-append "--" (symbol->string name)) value)) + ((? string?) + (local-file value)) + (#f #f)))) + (with-error-handling (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) @@ -1401,6 +1475,15 @@ Create a bundle of PACKAGE.\n")) manifest) manifest))) (pack-format (assoc-ref opts 'format)) + (extra-options (match pack-format + ('deb + (list #:control-file + (process-file-arg opts 'control-file) + #:postinst-file + (process-file-arg opts 'postinst-file) + #:triggers-file + (process-file-arg opts 'triggers-file))) + (_ '()))) (target (assoc-ref opts 'target)) (bootstrap? (assoc-ref opts 'bootstrap?)) (compressor (if bootstrap? @@ -1465,7 +1548,9 @@ to your package list."))) #:profile-name profile-name #:archiver - archiver))) + archiver + #:extra-options + extra-options))) (mbegin %store-monad (mwhen derivation? (return (format #t "~a~%" diff --git a/tests/pack.scm b/tests/pack.scm index 9473d4f384..e9b4c36e0e 100644 --- a/tests/pack.scm +++ b/tests/pack.scm @@ -277,17 +277,25 @@ (built-derivations (list check)))) (unless store (test-skip 1)) - (test-assertm "deb archive with symlinks" store + (test-assertm "deb archive with symlinks and control files" store (mlet* %store-monad ((guile (set-guile-for-build (default-guile))) (profile (profile-derivation (packages->manifest (list %bootstrap-guile)) #:hooks '() #:locales? #f)) - (deb (debian-archive "deb-pack" profile - #:compressor %gzip-compressor - #:symlinks '(("/opt/gnu/bin" -> "bin")) - #:archiver %tar-bootstrap)) + (deb (debian-archive + "deb-pack" profile + #:compressor %gzip-compressor + #:symlinks '(("/opt/gnu/bin" -> "bin")) + #:archiver %tar-bootstrap + #:extra-options + (list #:triggers-file + (plain-file "triggers" + "activate-noawait /usr/share/icons/hicolor\n") + #:postinst-file + (plain-file "postinst" + "echo running configure script\n")))) (check (gexp->derivation "check-deb-pack" (with-imported-modules '((guix build utils)) @@ -344,6 +352,15 @@ (unless (null? hard-links) (error "hard links found in data.tar.gz" hard-links)) + ;; Verify the presence of the control files. + (invoke "tar" "-xf" "control.tar.gz") + (assert (file-exists? "control")) + (assert (and (file-exists? "postinst") + (= #o111 ;script is executable + (logand #o111 (stat:perms + (stat "postinst")))))) + (assert (file-exists? "triggers")) + (mkdir #$output)))))) (built-derivations (list check))))) -- 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 06 17:12:12 2021 Received: (at 49348) by debbugs.gnu.org; 6 Jul 2021 21:12:12 +0000 Received: from localhost ([127.0.0.1]:50340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMW-0000te-0N for submit@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:12 -0400 Received: from mail-qk1-f176.google.com ([209.85.222.176]:34671) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMT-0000tS-QC for 49348@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:10 -0400 Received: by mail-qk1-f176.google.com with SMTP id g4so21679645qkl.1 for <49348@debbugs.gnu.org>; Tue, 06 Jul 2021 14:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bx3Fk97oa84BYLDRR2HXWOKM/IvzH6WRlbv0Y/nnfL0=; b=o8mdpHYyN6Yqhwg4pF4EkCgUYtQ2Uo7TG3Iv1JdU6r6IpPp2c8+hb+dr5hZA9m8xVf MSHixfVlwuUNDkCLBpqQK4kFAfeHJjqdZzDb2M/cyxPWwwQbwXglMcfgA1m/Ep/Da2ia ajCjj9wUTNA0/pjFk+Vz6edIoAeE5v+1ZwKTyAvrG/zkdJWo1OHZVznaMA66IK5vPMv+ qPX6P4jqwYLWi22pb0/QhZ6Qvs5+SpdoTxlQzndRf1ckP1AnSumxIKw1M5fx8bj+NAQg 04V9v9ll8DFkwHBXX11I1REfCBOCg0dFwIIx9RXdJ5YUodgD1wcLeS495q04HpKHrXGz rzOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bx3Fk97oa84BYLDRR2HXWOKM/IvzH6WRlbv0Y/nnfL0=; b=Mt10D2SS5dyhnOyrctUMURFFAqbW38/zSFW2YINDI22D/JF0UOxYEt0YcbSmVGm/T0 32W7TVtQe1gjUGcx4fMB+xObDabEU8YPKv5qvEMw6jhmkq035PX3BVUccIKVswmG/NcH Qa1UOXa4voFe2uHeT7vV0abktv4c8P4kKAzaqzzhEYFKi6qZSoPZExy3fp6JZ3Js3x0Q uYFMYbwYOyApYUyWjHGDiecV0KBk/ChFxLQ76+YUMFIq8S6j2P+SgM7wO7czcyf4RUyF TmvDDNnDDY1EbdJ/VK0Imr0fxg5VZMbGYCUVtQMVxtY7KZCPnd/DrlSidQaVd7o0fkql Ze2g== X-Gm-Message-State: AOAM532x0qRH72drT7wShEXLw3TtsBg6A1lUTiz5bSOtTxCFK9vsrXjf BMCUVk3rTGMBn5DLjzga/6grpiH0016Baw== X-Google-Smtp-Source: ABdhPJyN9vqC8CQ+2wjQ18BBS5qwwkLjm6BonbImdogmxy0wDwwgIfNz1hCatfGBKMWFVe2yFsPw5A== X-Received: by 2002:a05:620a:21cd:: with SMTP id h13mr21459393qka.309.1625605923844; Tue, 06 Jul 2021 14:12:03 -0700 (PDT) Received: from localhost.localdomain (dsl-205-233-125-111.b2b2c.ca. [205.233.125.111]) by smtp.gmail.com with ESMTPSA id s19sm7240662qks.77.2021.07.06.14.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 14:12:03 -0700 (PDT) From: Maxim Cournoyer To: 49348@debbugs.gnu.org Subject: [PATCH v2 1/4] pack: Allow embedding custom control files in deb packs. Date: Tue, 6 Jul 2021 17:11:36 -0400 Message-Id: <20210706211139.2806-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703060642.2424-1-maxim.cournoyer@gmail.com> References: <20210703060642.2424-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49348 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/pack.scm (self-contained-tarball/builder) [extra-options]: New argument. (self-contained-tarball, squashfs-image, docker-image) (debian-archive): Likewise. Remove two TODO comments. Document EXTRA-OPTIONS. Use the custom control files when provided. (%deb-format-options): New variable. (show-deb-format-options, show-deb-format-options/detailed): New procedures. (%options): Register new options. (show-help): Augment with new usage. (guix-pack): Validate and propagate new argument values. * doc/guix.texi (Invoking guix pack)[deb]: Document how to list advanced options. Add an example. * tests/pack.scm (deb archive...): Provide extra-options to the debian-archive procedure, and validate that the provided files are embedded in the pack. --- doc/guix.texi | 8 +++ guix/scripts/pack.scm | 121 +++++++++++++++++++++++++++++++++++------- tests/pack.scm | 27 ++++++++-- 3 files changed, 133 insertions(+), 23 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1086d3220b..39d4cb1929 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6047,6 +6047,14 @@ such file or directory'' message. This produces a Debian archive (a package with the @samp{.deb} file extension) containing all the specified binaries and symbolic links, that can be installed on top of any dpkg-based GNU(/Linux) distribution. +Advanced options can be revealed via the @option{--help-deb-format} +option. They allow embedding control files for more fine-grained +control, such as activating specific triggers or providing a maintainer +configure script to run arbitrary setup code upon installation. + +@example +guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello +@end example @quotation Note Because archives produced with @command{guix pack} contain a collection diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 6d8b70d1c7..6a8d49e042 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -205,7 +205,8 @@ its source property." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return the G-Expression of the builder used for self-contained-tarball." (define database (and localstatedir? @@ -324,7 +325,8 @@ its source property." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a self-contained tarball containing a store initialized with the closure of PROFILE, a derivation. The tarball contains /gnu/store; if LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db @@ -389,7 +391,8 @@ to the search paths of PROFILE." entry-point localstatedir? (symlinks '()) - (archiver squashfs-tools)) + (archiver squashfs-tools) + (extra-options '())) "Return a squashfs image containing a store initialized with the closure of PROFILE, a derivation. The image contains a subset of /gnu/store, empty mount points for virtual file systems (like procfs), and optional symlinks. @@ -567,7 +570,8 @@ added to the pack." entry-point localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a derivation to construct a Docker image of PROFILE. The image is a tarball conforming to the Docker Image Specification, compressed with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it @@ -654,8 +658,6 @@ the image." ;;; TODO: When relocatable option is selected, install to a unique prefix. ;;; This would enable installation of multiple deb packs with conflicting ;;; files at the same time. -;;; TODO: Allow passing a custom control file from the CLI. -;;; TODO: Allow providing a postinst script. (define* (debian-archive name profile #:key target (profile-name "guix-profile") @@ -664,7 +666,8 @@ the image." (compressor (first %compressors)) localstatedir? (symlinks '()) - (archiver tar)) + (archiver tar) + (extra-options '())) "Return a Debian archive (.deb) containing a store initialized with the closure of PROFILE, a derivation. The archive contains /gnu/store; if LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db @@ -672,7 +675,8 @@ with a properly initialized store database. The supported compressors are \"none\", \"gz\" or \"xz\". SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be -added to the pack." +added to the pack. EXTRA-OPTIONS may contain the CONFIG-FILE, POSTINST-FILE +or TRIGGERS-FILE keyword arguments." ;; For simplicity, limit the supported compressors to the superset of ;; compressors able to compress both the control file (gz or xz) and the ;; data tarball (gz, bz2 or xz). @@ -714,21 +718,23 @@ Valid compressors are: ~a~%") compressor-name %valid-compressors))) (guix build utils) (guix profiles) (ice-9 match) + ((oop goops) #:select (get-keyword)) (srfi srfi-1)) (define machine-type ;; Extract the machine type from the specified target, else from the ;; current system. - (and=> (or #$target %host-type) (lambda (triplet) - (first (string-split triplet #\-))))) + (and=> (or #$target %host-type) + (lambda (triplet) + (first (string-split triplet #\-))))) (define (gnu-machine-type->debian-machine-type type) "Translate machine TYPE from the GNU to Debian terminology." ;; Debian has its own jargon, different from the one used in GNU, for ;; machine types (see data/cputable in the sources of dpkg). (match type - ("i586" "i386") ("i486" "i386") + ("i586" "i386") ("i686" "i386") ("x86_64" "amd64") ("aarch64" "arm64") @@ -773,21 +779,40 @@ Valid compressors are: ~a~%") compressor-name %valid-compressors))) (copy-file #+data-tarball data-tarball-file-name) + ;; Generate the control archive. + (define control-file + (get-keyword #:control-file '#$extra-options)) + + (define postinst-file + (get-keyword #:postinst-file '#$extra-options)) + + (define triggers-file + (get-keyword #:triggers-file '#$extra-options)) + (define control-tarball-file-name (string-append "control.tar" #$(compressor-extension compressor))) ;; Write the compressed control tarball. Only the control file is ;; mandatory (see: 'man deb' and 'man deb-control'). - (call-with-output-file "control" - (lambda (port) - (format port "\ + (if control-file + (copy-file control-file "control") + (call-with-output-file "control" + (lambda (port) + (format port "\ Package: ~a Version: ~a Description: Debian archive generated by GNU Guix. Maintainer: GNU Guix Architecture: ~a -~%" package-name package-version architecture))) +~%" package-name package-version architecture)))) + + (when postinst-file + (copy-file postinst-file "postinst") + (chmod "postinst" #o755)) + + (when triggers-file + (copy-file triggers-file "triggers")) (define tar (string-append #+archiver "/bin/tar")) @@ -796,7 +821,9 @@ Architecture: ~a #:tar tar #:compressor '#+(and=> compressor compressor-command)) "-cvf" ,control-tarball-file-name - "control")) + "control" + ,@(if postinst-file '("postinst") '()) + ,@(if triggers-file '("triggers") '()))) ;; Create the .deb archive using GNU ar. (invoke (string-append #+binutils "/bin/ar") "-rv" #$output @@ -1157,6 +1184,34 @@ last resort for relocation." deb Debian archive installable via dpkg/apt")) (newline)) +(define %deb-format-options + (let ((required-option (lambda (symbol) + (option (list (symbol->string symbol)) #t #f + (lambda (opt name arg result . rest) + (apply values + (alist-cons symbol arg result) + rest)))))) + (list (required-option 'control-file) + (required-option 'postinst-file) + (required-option 'triggers-file)))) + +(define (show-deb-format-options) + (display (G_ " + --help-deb-format list options specific to the deb format"))) + +(define (show-deb-format-options/detailed) + (display (G_ " + --control-file=FILE + Embed the provided control FILE")) + (display (G_ " + --postinst-file=FILE + Embed the provided postinst script")) + (display (G_ " + --triggers-file=FILE + Embed the provided triggers FILE")) + (newline) + (exit 0)) + (define %options ;; Specifications of the command-line options. (cons* (option '(#\h "help") #f #f @@ -1250,7 +1305,12 @@ last resort for relocation." (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) - (append %transformation-options + (option '("help-deb-format") #f #f + (lambda args + (show-deb-format-options/detailed))) + + (append %deb-format-options + %transformation-options %standard-build-options))) (define (show-help) @@ -1260,6 +1320,8 @@ Create a bundle of PACKAGE.\n")) (newline) (show-transformation-options-help) (newline) + (show-deb-format-options) + (newline) (display (G_ " -f, --format=FORMAT build a pack in the given FORMAT")) (display (G_ " @@ -1369,6 +1431,18 @@ Create a bundle of PACKAGE.\n")) (else (packages->manifest packages)))))) + (define (process-file-arg opts name) + ;; Validate that the file exists and return it as a object, + ;; else #f. + (let ((value (assoc-ref opts name))) + (match value + ((and (? string?) (not (? file-exists?))) + (leave (G_ "file provided with option ~a does not exist: ~a~%") + (string-append "--" (symbol->string name)) value)) + ((? string?) + (local-file value)) + (#f #f)))) + (with-error-handling (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) @@ -1401,6 +1475,15 @@ Create a bundle of PACKAGE.\n")) manifest) manifest))) (pack-format (assoc-ref opts 'format)) + (extra-options (match pack-format + ('deb + (list #:control-file + (process-file-arg opts 'control-file) + #:postinst-file + (process-file-arg opts 'postinst-file) + #:triggers-file + (process-file-arg opts 'triggers-file))) + (_ '()))) (target (assoc-ref opts 'target)) (bootstrap? (assoc-ref opts 'bootstrap?)) (compressor (if bootstrap? @@ -1465,7 +1548,9 @@ to your package list."))) #:profile-name profile-name #:archiver - archiver))) + archiver + #:extra-options + extra-options))) (mbegin %store-monad (mwhen derivation? (return (format #t "~a~%" diff --git a/tests/pack.scm b/tests/pack.scm index 9473d4f384..e9b4c36e0e 100644 --- a/tests/pack.scm +++ b/tests/pack.scm @@ -277,17 +277,25 @@ (built-derivations (list check)))) (unless store (test-skip 1)) - (test-assertm "deb archive with symlinks" store + (test-assertm "deb archive with symlinks and control files" store (mlet* %store-monad ((guile (set-guile-for-build (default-guile))) (profile (profile-derivation (packages->manifest (list %bootstrap-guile)) #:hooks '() #:locales? #f)) - (deb (debian-archive "deb-pack" profile - #:compressor %gzip-compressor - #:symlinks '(("/opt/gnu/bin" -> "bin")) - #:archiver %tar-bootstrap)) + (deb (debian-archive + "deb-pack" profile + #:compressor %gzip-compressor + #:symlinks '(("/opt/gnu/bin" -> "bin")) + #:archiver %tar-bootstrap + #:extra-options + (list #:triggers-file + (plain-file "triggers" + "activate-noawait /usr/share/icons/hicolor\n") + #:postinst-file + (plain-file "postinst" + "echo running configure script\n")))) (check (gexp->derivation "check-deb-pack" (with-imported-modules '((guix build utils)) @@ -344,6 +352,15 @@ (unless (null? hard-links) (error "hard links found in data.tar.gz" hard-links)) + ;; Verify the presence of the control files. + (invoke "tar" "-xf" "control.tar.gz") + (assert (file-exists? "control")) + (assert (and (file-exists? "postinst") + (= #o111 ;script is executable + (logand #o111 (stat:perms + (stat "postinst")))))) + (assert (file-exists? "triggers")) + (mkdir #$output)))))) (built-derivations (list check))))) -- 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 06 17:12:19 2021 Received: (at 49348) by debbugs.gnu.org; 6 Jul 2021 21:12:19 +0000 Received: from localhost ([127.0.0.1]:50343 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMd-0000u1-Mw for submit@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:19 -0400 Received: from mail-qv1-f49.google.com ([209.85.219.49]:41569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMc-0000to-F8 for 49348@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:18 -0400 Received: by mail-qv1-f49.google.com with SMTP id f5so10810qvu.8 for <49348@debbugs.gnu.org>; Tue, 06 Jul 2021 14:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yCDFClnsXps007VfbqnHkoftLhuH0UQP5OWJ3CxtjF0=; b=Lnill5ux24E4fX3eb8jq7tvq3DXDvJki6beln+6YzNu4JbG+l9dpJbAf/KN4xppvmN mjYdW0UcvzSn5i48gMtGvxIY6WwDU75Wad+lCINfY6pr4bA96Lu0vpRJl9urzaJgZ/QR prY7vHPVZGsEdecLdm5PCnJ2RXO4QmfRPapCRQyQNp1koRm9b/VXv8wKLI8e3cSzoBvP 00vt3g97KyGHFNTC90FihsNL5xQUvaOuaC004IfzS/nfGXNe72DgPo4bIy0JvlxRdY6n CwMzzEWdkKJPyQwwbtvtdgU48xYKQdnd4umeiFpqtJGoulLItNwV6ONTgx3xRda4uNIs IVqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yCDFClnsXps007VfbqnHkoftLhuH0UQP5OWJ3CxtjF0=; b=Q4q9OUrd4nS5tTCM0qoCXFCBR3RCZe8IoiNE6bDOcBt1v6OIUzfv2EnTOrpNASvUsd NZBkzzZkCSDos5HDqXsevTk6321q/pv/3CgXIsTRI7iaabnIC5cOEcmpMj7XKPwgWJcT GC9yVxxTCc7gPWsHlZShfouPXK5n8v/ZhL+O6uFS5SAzeo8s3hF12qxTmhsXHQfEe0n9 7zOJ8EWmsvvX0T9vdNT2skunYnH+rcs/0jZeGyHvEqfIRrYmTx02aKQsHkt1NQJ4LTRw 8JUnDD+SFhUMsFBP+9erdyt0eJiYKt3CMwOrqmrwLRrgA/Jo7GKOkQnNh2LHYA3hE+hs SSDw== X-Gm-Message-State: AOAM533CgEGNQw4iiRjHgr93LtC0m9KjsDjvh4jlLBM1U37xLzamypNU we4m83UdJDT2JbmhS5wZaFgNstXXERaMkg== X-Google-Smtp-Source: ABdhPJzezcmbmMAj6ZU7PWK436SWFpzdCF2UFX6Y/zqQ4M4vBN+f08mRVt04E9bddi5+O4/zA7sy6g== X-Received: by 2002:a0c:f682:: with SMTP id p2mr20220667qvn.17.1625605932908; Tue, 06 Jul 2021 14:12:12 -0700 (PDT) Received: from localhost.localdomain (dsl-205-233-125-111.b2b2c.ca. [205.233.125.111]) by smtp.gmail.com with ESMTPSA id s19sm7240662qks.77.2021.07.06.14.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 14:12:12 -0700 (PDT) From: Maxim Cournoyer To: 49348@debbugs.gnu.org Subject: [PATCH v2 2/4] pack/deb: Add default section and priority fields to the control file. Date: Tue, 6 Jul 2021 17:11:37 -0400 Message-Id: <20210706211139.2806-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706211139.2806-1-maxim.cournoyer@gmail.com> References: <20210703060642.2424-1-maxim.cournoyer@gmail.com> <20210706211139.2806-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49348 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) These fields, while optional per dpkg, are required by other tools such as reprepro, commonly used to generate apt repositories. * guix/scripts/pack.scm (debian-archive): Set the control file section field to 'misc' and the priority field to 'optional'. --- guix/scripts/pack.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 6a8d49e042..78201d6f5f 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -805,6 +805,8 @@ Version: ~a Description: Debian archive generated by GNU Guix. Maintainer: GNU Guix Architecture: ~a +Priority: optional +Section: misc ~%" package-name package-version architecture)))) (when postinst-file -- 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 06 17:12:24 2021 Received: (at 49348) by debbugs.gnu.org; 6 Jul 2021 21:12:24 +0000 Received: from localhost ([127.0.0.1]:50346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMh-0000uI-TJ for submit@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:24 -0400 Received: from mail-qk1-f180.google.com ([209.85.222.180]:34701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMg-0000tt-7e for 49348@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:22 -0400 Received: by mail-qk1-f180.google.com with SMTP id g4so21680247qkl.1 for <49348@debbugs.gnu.org>; Tue, 06 Jul 2021 14:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+E/D2n4BtSsH4nDSrF7X05HXdKWSrJuummj3isbdtJs=; b=LlD+MWAAsuqTjux/4A8eTCrMNmkJpzJhgT6v1CBbpGnoEiHa5mowwF+JJESJq8omsM RLo8WyHq6R/cU8SGEkDZmxFYx/2LcWUVj+vTRthXHT2Do5RXCOBA93PpOiHqbMKwqQFi gGsF3Y4Pn2eLKaIqeJnPRV/n7B4+vX90fAEVc13V/PeFf/hRDiAHcw4I1/h7gQDTBjMJ Azq3wJTJy51ZeQGdrrG5EncqsBSww0b3doRxpvwsTOLHlPTZ75Mtj0v2QBwIcJRlkfVU LDSiJwnKr/53Hr53PL5MoORuwgaQbdVeNtNYACpDAnx/zKH7RVYvh+iajUoq4z7Kg+mc zjWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+E/D2n4BtSsH4nDSrF7X05HXdKWSrJuummj3isbdtJs=; b=Vjb/N9i/i0OYiUeRS2SY0FRKiMpTkl3yl4DHl9o+YChW8TYlRg01n2OspYLZQxsN1l U3omrkOo6kZIRmX6hStUFx20/W7fenLxaRkyISm5rkmY16wlCfh4JJ2Mpsb6Vn//m7ih LT0WJtcdS5Wx68p+DAz7ziNaNurGeKCClbN6Qb09c/FXqjBEsKGLdZoPvMLDDXIrv6hc 6CzVyFIPSZ9XzwacJGn22/xZyCanJN8NSIjB7o27uyNy00W5gLTjjwMyh4K+3iFHPn2W xc4roKcUUzIP0i5su9Mo/+bJV4ELZoWsn6AZ0MCRGArVz/5jWGp7pkO9w33UhM/cxa8Q /IDg== X-Gm-Message-State: AOAM533tn3XXet3KRDaFGSiqWs/uB0w8z4/NsNwE54ANmyFQM48d+zxW 1Vz1YOFE02ISlXHG96Ef9G5EhrCVTM4zEQ== X-Google-Smtp-Source: ABdhPJxl32FbsIIaDbgKCB5oGDqqucE9pw+yDPgpHoCF5QFBM+cjBceDDgsN1yXRSCpkZacnGrvbmQ== X-Received: by 2002:a37:64c1:: with SMTP id y184mr15294947qkb.273.1625605936727; Tue, 06 Jul 2021 14:12:16 -0700 (PDT) Received: from localhost.localdomain (dsl-205-233-125-111.b2b2c.ca. [205.233.125.111]) by smtp.gmail.com with ESMTPSA id s19sm7240662qks.77.2021.07.06.14.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 14:12:16 -0700 (PDT) From: Maxim Cournoyer To: 49348@debbugs.gnu.org Subject: [PATCH v2 3/4] pack: Streamline how files are included in tarballs. Date: Tue, 6 Jul 2021 17:11:38 -0400 Message-Id: <20210706211139.2806-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706211139.2806-1-maxim.cournoyer@gmail.com> References: <20210703060642.2424-1-maxim.cournoyer@gmail.com> <20210706211139.2806-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49348 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thanks to Guillem Jover on the OFTC's #debian-dpkg channel for helping with troubleshooting. Letting GNU Tar recursively walk the complete files hierarchy side-steps the risks associated with providing a list of file names: 1. Duplicated files in the archive (recorded as hard links by GNU Tar) 2. Missing parent directories. The above would cause dpkg to malfunction, for example by aborting early and skipping triggers when there are missing parent directories. * guix/scripts/pack.scm (self-contained-tarball/builder): Do not call POPULATE-SINGLE-PROFILE-DIRECTORY, which creates extraneous files such as /root. Instead, call POPULATE-STORE and INSTALL-DATABASE-AND-GC-ROOTS individually to more precisely generate the file system. Replace the list of files by the current directory, "." and streamline the way options are passed. * gnu/system/file-systems.scm (reduce-directories): Remove procedure. * tests/file-systems.scm ("reduce-directories"): Remove test. --- gnu/system/file-systems.scm | 22 ----------------- guix/scripts/pack.scm | 49 ++++++++++++------------------------- tests/file-systems.scm | 7 +----- 3 files changed, 17 insertions(+), 61 deletions(-) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 4a3c1fe008..b9eda80958 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -55,7 +55,6 @@ file-system-dependencies file-system-location - reduce-directories file-system-type-predicate btrfs-subvolume? btrfs-store-subvolume-file-name @@ -266,27 +265,6 @@ For example: (define (file-name-depth file-name) (length (string-tokenize file-name %not-slash))) -(define (reduce-directories file-names) - "Eliminate entries in FILE-NAMES that are children of other entries in -FILE-NAMES. This is for example useful when passing a list of files to GNU -tar, which would otherwise descend into each directory passed and archive the -duplicate files as hard links, which can be undesirable." - (let* ((file-names/sorted - ;; Ascending sort by file hierarchy depth, then by file name length. - (stable-sort (delete-duplicates file-names) - (lambda (f1 f2) - (let ((depth1 (file-name-depth f1)) - (depth2 (file-name-depth f2))) - (if (= depth1 depth2) - (string< f1 f2) - (< depth1 depth2))))))) - (reverse (fold (lambda (file-name results) - (if (find (cut file-prefix? <> file-name) results) - results ;parent found -- skipping - (cons file-name results))) - '() - file-names/sorted)))) - (define* (file-system-device->string device #:key uuid-type) "Return the string representations of the DEVICE field of a record. When the device is a UUID, its representation is chosen depending on diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 78201d6f5f..9e1f270dfb 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -231,17 +231,17 @@ its source property." (with-imported-modules (source-module-closure `((guix build pack) + (guix build store-copy) (guix build utils) (guix build union) - (gnu build install) - (gnu system file-systems)) + (gnu build install)) #:select? import-module?) #~(begin (use-modules (guix build pack) + (guix build store-copy) (guix build utils) ((guix build union) #:select (relative-file-name)) (gnu build install) - ((gnu system file-systems) #:select (reduce-directories)) (srfi srfi-1) (srfi srfi-26) (ice-9 match)) @@ -279,11 +279,11 @@ its source property." ;; Furthermore GNU tar < 1.30 sometimes fails to extract tarballs ;; with hard links: ;; . - (populate-single-profile-directory %root - #:profile #$profile - #:profile-name #$profile-name - #:closure "profile" - #:database #+database) + (populate-store (list "profile") %root #:deduplicate? #f) + + (when #+localstatedir? + (install-database-and-gc-roots %root #+database #$profile + #:profile-name #$profile-name)) ;; Create SYMLINKS. (for-each (cut evaluate-populate-directive <> %root) @@ -291,31 +291,14 @@ its source property." ;; Create the tarball. (with-directory-excursion %root - (apply invoke tar - `(,@(tar-base-options - #:tar tar - #:compressor '#+(and=> compressor compressor-command)) - "-cvf" ,#$output - ;; Avoid adding / and /var to the tarball, so - ;; that the ownership and permissions of those - ;; directories will not be overwritten when - ;; extracting the archive. Do not include /root - ;; because the root account might have a - ;; different home directory. - ,#$@(if localstatedir? - '("./var/guix") - '()) - - ,(string-append "." (%store-directory)) - - ,@(reduce-directories - (filter-map (match-lambda - (('directory directory) - (string-append "." directory)) - ((source '-> _) - (string-append "." source)) - (_ #f)) - directives)))))))) + ;; GNU Tar recurses directories by default. Simply add the whole + ;; current directory, which contains all the generated files so far. + ;; This avoids creating duplicate files in the archives that would + ;; be stored as hard links by GNU Tar. + (apply invoke tar "-cvf" #$output "." + (tar-base-options + #:tar tar + #:compressor '#+(and=> compressor compressor-command))))))) (define* (self-contained-tarball name profile #:key target diff --git a/tests/file-systems.scm b/tests/file-systems.scm index 80acb6d5b9..7f7c373884 100644 --- a/tests/file-systems.scm +++ b/tests/file-systems.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2017 Ludovic Courtès -;;; Copyright © 2020, 2021 Maxim Cournoyer +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,11 +50,6 @@ (device "/foo") (flags '(bind-mount read-only))))))))) -(test-equal "reduce-directories" - '("./opt/gnu/" "./opt/gnuism" "a/b/c") - (reduce-directories '("./opt/gnu/etc" "./opt/gnu/" "./opt/gnu/bin" - "./opt/gnu/lib/debug" "./opt/gnuism" "a/b/c" "a/b/c"))) - (test-assert "does not pull (guix config)" ;; This module is meant both for the host side and "build side", so make ;; sure it doesn't pull in (guix config), which depends on the user's -- 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 06 17:12:28 2021 Received: (at 49348) by debbugs.gnu.org; 6 Jul 2021 21:12:28 +0000 Received: from localhost ([127.0.0.1]:50350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMm-0000uZ-DX for submit@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:28 -0400 Received: from mail-qk1-f179.google.com ([209.85.222.179]:40834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0sMl-0000uA-0e for 49348@debbugs.gnu.org; Tue, 06 Jul 2021 17:12:27 -0400 Received: by mail-qk1-f179.google.com with SMTP id t19so7011817qkg.7 for <49348@debbugs.gnu.org>; Tue, 06 Jul 2021 14:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Enlo/v+uwX3DqIqK0rv0/tx/vOVYUd27LjmnXtaM8oI=; b=GU+BmQPMOlIsD0rc5PpBLGv6OH0xvuLimbtRGug+08hsGXNUn+0PCIQZI9Too1pgLt 2/LXZxLlJ1WcDfHabpmm0IuM2fNafcBZdH+Z05+54Y1QMxB+TcGlJoQuKD3Q7ln0rZxB MQjAvC9i5O2GEl/XLieDZhfxA9tXX9Hk+xI1hEfJ0zUxOHQNhuzFNeZgULmX/hMl4SBU p6IPp1ZceLVobNGN8MqrU+GCWK/ynh54bHuKVIbXqfJltQ1LhjvmI4PMfWFBwfSKMIcM Yl6z7HTtL8XjenTHUfsP+drF9lnSh7Ws44wMsf2ZeEFP6OVGqv2506RESceiy1LAydyw r0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Enlo/v+uwX3DqIqK0rv0/tx/vOVYUd27LjmnXtaM8oI=; b=RwQDMYcI+crGGCFtwpBkPMj4bKy1QTPe9cG4ycyS7LbFkn2o3vqFxat+/0lhhSlcZU hsBt5qH2gY4fJXKz3X3ADkX3nivmevO7KzqvFwH2rVLU91wM7uBscr+frnUSlzvD8hFS 5p8nP5SmNT/x8Bhj2CTSZZTptXjQSqDr7BslBxpxhdHMO2+q/71ZdSNequH180loIg9n K5qlrwqhN0MuvaMyjnC7CtQm4f0vJO6xd8nr/rzm/rH4x+Z0XwVusrBjDQAKDddqeBr+ wN/3qV77Z9u8tqeKnagGnNpz1yXuszCopHQzewka++yFKV/bbb8sp9djSB2VK4OLYUtQ FqpA== X-Gm-Message-State: AOAM530rbGAeg7pyCQ0MFfQWqzA08SlEa5ieRTjRJoR6AtV6FWmdqF+p 6CXmCxBGlSv88TozmD7qgxY7mFgbAGNO3Q== X-Google-Smtp-Source: ABdhPJwDhRitq5MoI7ltxvcIPnUPF0AEdXbQGTGfe2pxGGcw7yUvDP4Z/LnD6kKiqg9cSY2uwRe6lQ== X-Received: by 2002:a37:5886:: with SMTP id m128mr21725868qkb.414.1625605941583; Tue, 06 Jul 2021 14:12:21 -0700 (PDT) Received: from localhost.localdomain (dsl-205-233-125-111.b2b2c.ca. [205.233.125.111]) by smtp.gmail.com with ESMTPSA id s19sm7240662qks.77.2021.07.06.14.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 14:12:21 -0700 (PDT) From: Maxim Cournoyer To: 49348@debbugs.gnu.org Subject: [PATCH v2 4/4] build: pack: Mute error output when checking if tar supports --sort. Date: Tue, 6 Jul 2021 17:11:39 -0400 Message-Id: <20210706211139.2806-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706211139.2806-1-maxim.cournoyer@gmail.com> References: <20210703060642.2424-1-maxim.cournoyer@gmail.com> <20210706211139.2806-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49348 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/build/pack.scm (tar-base-options) [tar-supports-sort?]: Redirect error output to void. --- guix/build/pack.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guix/build/pack.scm b/guix/build/pack.scm index 05c7a3c594..3b73d1b227 100644 --- a/guix/build/pack.scm +++ b/guix/build/pack.scm @@ -27,8 +27,10 @@ deterministically. When TAR, a GNU tar command file name, is provided, the '(\"gzip\" \"-9n\"), is provided, the compressor is explicitly specified via the `-I' option." (define (tar-supports-sort? tar) - (zero? (system* tar "cf" "/dev/null" "--files-from=/dev/null" - "--sort=name"))) + (with-error-to-port (%make-void-port "w") + (lambda () + (zero? (system* tar "cf" "/dev/null" "--files-from=/dev/null" + "--sort=name"))))) `(,@(if compressor (list "-I" (string-join compressor)) -- 2.32.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 18 14:21:02 2021 Received: (at 49348-done) by debbugs.gnu.org; 18 Jul 2021 18:21:02 +0000 Received: from localhost ([127.0.0.1]:57194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5BPS-0002TI-7j for submit@debbugs.gnu.org; Sun, 18 Jul 2021 14:21:02 -0400 Received: from mail-qk1-f175.google.com ([209.85.222.175]:47048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5BPQ-0002Si-Qh for 49348-done@debbugs.gnu.org; Sun, 18 Jul 2021 14:21:01 -0400 Received: by mail-qk1-f175.google.com with SMTP id k4so3550104qkj.13 for <49348-done@debbugs.gnu.org>; Sun, 18 Jul 2021 11:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=J/uhgN64FwvStLFQY4B9viZVxwEz3wvGIHAVHPmFQFw=; b=OL+hL4vII9Tj003BtGhRjkb3VsFWLu6QSOIzg4gmo1vWRVvgZRnAbTG00KUeAC3F1U OYuH69mYO9HPkYFl6lDy7eoz4Nfws/IyNB/imAkx6hCxQbhzoW9VfI5eXrd/AP/WxbJM AIieopEQgHTNrVeYvNixL1FjkhzIACi6mVKRESkxCcLhAm31m8qoRmFzBHYlbon+AOgB bYMdy4vilvtGmep2LG6vGxZ2EnWaVohuO1llQlb7mFYDDuNEu+TDM7VhHdneWO7SjhSW +kAKHGorMiaQrUXPR2I1V0HcQaseZmDPPkgBgoLcb5I3YjSpslqdcth6dVzjNNq+iois U4fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=J/uhgN64FwvStLFQY4B9viZVxwEz3wvGIHAVHPmFQFw=; b=EnI8ZIt5mbcX3Y2GbBsQWNT0iP7l95zpurGYFo0xQcc3hRdle1H/5TXzBSpQmCu56A U6vgw/M9ZPXXkMTY+6siIanw1noBxyX6e1k9cahLvmQYZBCkru6PoFWYtVTG0aem3ov9 KQnanR8GvJ5jeqRLirC2vaXzoxL/I1Zal/Ew8mzIRDK/I4ejsPlvxqWtx049bH2DJwES 0VrxNLY+CsVJKplB/PFK5HTxf12f3nifljxNK/Xs2mBrt8KZ0s36PRTaMw/xY0R5nYxI y0VweT96IYhszaeW9P+X9AP7oLUl7la4r1yl57Ta5pfWMg0nKJ1zDyq9tmZ11/FX3v23 0+OA== X-Gm-Message-State: AOAM533t94wCfqr/6zIx37X7HhIbjYljANQYkWP4DbpYaLn3CiDnKBed PalC2KJB2hQ3OMIoijjuMhR0jZ1BloBNlQ== X-Google-Smtp-Source: ABdhPJwqMaPfyKdkEKckZB2xMmgeei0zlieE6a30fzTkGedxVQIHsJV7dQB0zr4c7RsxZsWlTe+ZTg== X-Received: by 2002:ac8:1389:: with SMTP id h9mr18662288qtj.173.1626625566608; Sun, 18 Jul 2021 09:26:06 -0700 (PDT) Received: from hurd (dsl-10-136-166.b2b2c.ca. [72.10.136.166]) by smtp.gmail.com with ESMTPSA id s81sm6701484qka.82.2021.07.18.09.26.06 for <49348-done@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jul 2021 09:26:06 -0700 (PDT) From: Maxim Cournoyer To: 49348-done@debbugs.gnu.org Subject: Re: bug#49348: Acknowledgement ([PATCH] pack: Allow embedding custom control files in deb packs.) References: <20210703060642.2424-1-maxim.cournoyer@gmail.com> Date: Sun, 18 Jul 2021 12:26:05 -0400 In-Reply-To: (GNU bug Tracking System's message of "Sat, 03 Jul 2021 06:07:02 +0000") Message-ID: <87pmvfk2qq.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49348-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Pushed with commit c170abba4735a2c8a6845063fae8bf090975cbf9. Closing. Maxim From unknown Wed Jun 18 23:08:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 16 Aug 2021 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator