From 3b8246057629c5fbdcb297da12f88fae69ee1a9a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 12 Apr 2013 15:43:55 +0200 Subject: guix package: Add `--no-substitutes'. * guix/scripts/package.scm (%default-options): Add `substitutes?'. (show-help, %options): Add and document `--no-substitutes'. (guix-package): Call `set-build-options' to honor `substitutes?'. --- doc/guix.texi | 3 +++ 1 file changed, 3 insertions(+) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 1be172c3f6..c91bc2021d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -570,6 +570,9 @@ Use @var{profile} instead of the user's default profile. @itemx -n Show what would be done without actually doing it. +@item --no-substitutes +Build instead of resorting to pre-built substitutes. + @item --verbose Produce verbose output. In particular, emit the environment's build log on the standard error port. -- cgit v1.2.3 From acb6ba256703da1db1d300541e15a4e7428f622b Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Mon, 15 Apr 2013 23:23:27 +0200 Subject: package: allow users to upgrade the whole system by not providing a regexp. * guix/scripts/packages.scm (guix-package) [process-actions]: When upgrading, use "" when REGEXP is #f. * doc/guix.texi: update the documentation accordingly. --- doc/guix.texi | 7 ++++--- guix/scripts/package.scm | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index c91bc2021d..b77335d2c2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -537,9 +537,10 @@ multiple-output package. @itemx -r @var{package} Remove @var{package}. -@item --upgrade=@var{regexp} -@itemx -u @var{regexp} -Upgrade all the installed packages matching @var{regexp}. +@item --upgrade[=@var{regexp}] +@itemx -u [@var{regexp}] +Upgrade all the installed packages. When @var{regexp} is specified, upgrade +only installed packages whose name matches @var{regexp}. Note that this upgrades package to the latest version of packages found in the distribution currently installed. To update your distribution, diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index ac99d16497..5b340c6ab7 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -328,7 +328,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (display (_ " -r, --remove=PACKAGE remove PACKAGE")) (display (_ " - -u, --upgrade=REGEXP upgrade all the installed packages matching REGEXP")) + -u, --upgrade[=REGEXP] upgrade all the installed packages matching REGEXP")) (display (_ " --roll-back roll back to the previous generation")) (newline) @@ -379,7 +379,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (option '(#\r "remove") #t #f (lambda (opt name arg result) (alist-cons 'remove arg result))) - (option '(#\u "upgrade") #t #f + (option '(#\u "upgrade") #f #t (lambda (opt name arg result) (alist-cons 'upgrade arg result))) (option '("roll-back") #f #f @@ -602,7 +602,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (let* ((installed (manifest-packages (profile-manifest profile))) (upgrade-regexps (filter-map (match-lambda (('upgrade . regexp) - (make-regexp regexp)) + (make-regexp (or regexp ""))) (_ #f)) opts)) (upgrade (if (null? upgrade-regexps) -- cgit v1.2.3 From 3b78d1eab826f2e79364ef38cfdc0d4bc0a5f414 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 17 Apr 2013 22:44:19 +0200 Subject: doc: Transparent binary deployment is implemented. * doc/guix.texi (Features): Remove footnote saying that transparent binary deployment is not implemented. --- doc/guix.texi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index b77335d2c2..188ab1ae73 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -447,11 +447,8 @@ scripts, etc. This direct correspondence allows users to make sure a given package installation matches the current state of their distribution, and helps maximize @dfn{reproducibility}. -@c FIXME: Remove footnote when it's implemented. This foundation allows Guix to support @dfn{transparent binary/source -deployment}@footnote{This feature is not implemented as of version -@value{VERSION}. Please contact @email{bug-guix@@gnu.org} for more -details.}. When a pre-built binary for a @file{/nix/store} path is +deployment}. When a pre-built binary for a @file{/nix/store} path is available from an external source, Guix just downloads it; otherwise, it builds the package from source, locally. -- cgit v1.2.3 From 48febeb81a06f95f2af98e153868e6d29a4ba353 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 18 Apr 2013 22:03:04 +0200 Subject: doc: Mention the home page. * doc/guix.texi (Installation): Add a sentence pointing to the home page. Suggested by Arne Babenhauserheide. --- doc/guix.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 188ab1ae73..96ffd51730 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -141,8 +141,10 @@ Distribution}. @node Installation @chapter Installation -This section describes the software requirements of Guix, as well as how -to install it and get ready to use it. +GNU Guix is available for download from its website at +@url{http://www.gnu.org/software/guix/}. This section describes the +software requirements of Guix, as well as how to install it and get +ready to use it. The build procedure for Guix is the same as for other GNU software, and is not covered here. Please see the files @file{README} and -- cgit v1.2.3 From 6858f9d13217b14eeeacede9c42a279468242891 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 18 Apr 2013 22:46:34 +0200 Subject: daemon: Add `--no-substitutes'. Suggested by Mark H. Weaver. * nix/nix-daemon/guix-daemon.cc (GUIX_OPT_NO_SUBSTITUTES): New macro. (options): Add `--no-substitutes'. (parse_opt): Add `GUIX_OPT_NO_SUBSTITUTES' case. (main): Leave `settings.substituters' empty when `settings.useSubstitutes' is false. --- doc/guix.texi | 4 ++++ nix/nix-daemon/guix-daemon.cc | 25 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 96ffd51730..f149eee6dd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -295,6 +295,10 @@ The following command-line options are supported: Take users from @var{group} to run build processes (@pxref{Setting Up the Daemon, build users}). +@item --no-substitutes +Do not use substitutes for build products. That is, always build things +locally instead of allowing downloads of pre-built binaries. + @item --cache-failures Cache build failures. By default, only successful builds are cached. diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index 0f21e4f99e..5f0710c256 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -65,6 +65,7 @@ builds derivations on behalf of its clients."; #define GUIX_OPT_DEBUG 9 #define GUIX_OPT_CHROOT_DIR 10 #define GUIX_OPT_LISTEN 11 +#define GUIX_OPT_NO_SUBSTITUTES 12 static const struct argp_option options[] = { @@ -90,6 +91,8 @@ static const struct argp_option options[] = }, { "build-users-group", GUIX_OPT_BUILD_USERS_GROUP, "GROUP", 0, "Perform builds as a user of GROUP" }, + { "no-substitutes", GUIX_OPT_NO_SUBSTITUTES, 0, 0, + "Do not use substitutes" }, { "cache-failures", GUIX_OPT_CACHE_FAILURES, 0, 0, "Cache build failures" }, { "lose-logs", GUIX_OPT_LOSE_LOGS, 0, 0, @@ -152,6 +155,9 @@ parse_opt (int key, char *arg, struct argp_state *state) exit (EXIT_FAILURE); } break; + case GUIX_OPT_NO_SUBSTITUTES: + settings.useSubstitutes = false; + break; case GUIX_OPT_DEBUG: verbosity = lvlDebug; break; @@ -202,16 +208,21 @@ main (int argc, char *argv[]) /* Use our substituter by default. */ settings.substituters.clear (); - string subs = getEnv ("NIX_SUBSTITUTERS", "default"); - if (subs == "default") - settings.substituters.push_back (settings.nixLibexecDir - + "/guix/substitute-binary"); - else - settings.substituters = tokenizeString (subs, ":"); - + settings.useSubstitutes = true; argp_parse (&argp, argc, argv, 0, 0, 0); + if (settings.useSubstitutes) + { + string subs = getEnv ("NIX_SUBSTITUTERS", "default"); + + if (subs == "default") + settings.substituters.push_back (settings.nixLibexecDir + + "/guix/substitute-binary"); + else + settings.substituters = tokenizeString (subs, ":"); + } + if (geteuid () == 0 && settings.buildUsersGroup.empty ()) fprintf (stderr, "warning: daemon is running as root, so " "using `--build-users-group' is highly recommended\n"); -- cgit v1.2.3 From 6c365eca6dafca37f0ac34d55221bcf197df49a3 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Sun, 21 Apr 2013 17:20:00 +0000 Subject: Add 'guix hash'. * guix/scripts/hash.scm: New file. * Makefile.am (MODULES): Add it. * po/POTFILES.in: Add it. * doc/guix.texi (Invoking guix hash): New node. (Defining Packages): Add a cross-reference to the 'Invoking guix hash' node. --- Makefile.am | 1 + doc/guix.texi | 37 +++++++++++++++- guix/scripts/hash.scm | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + 4 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 guix/scripts/hash.scm (limited to 'doc/guix.texi') diff --git a/Makefile.am b/Makefile.am index 3e697a258a..d1ae126f80 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ MODULES = \ guix/scripts/import.scm \ guix/scripts/package.scm \ guix/scripts/gc.scm \ + guix/scripts/hash.scm \ guix/scripts/pull.scm \ guix/scripts/substitute-binary.scm \ guix/base32.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index f149eee6dd..e23eab0f81 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -814,8 +814,9 @@ the GNU mirrors defined in @code{(guix download)}. The @code{sha256} field specifies the expected SHA256 hash of the file being downloaded. It is mandatory, and allows Guix to check the integrity of the file. The @code{(base32 @dots{})} form introduces the -base32 representation of the hash. A convenient way to obtain this -information is with the @code{guix download} tool. +base32 representation of the hash. You can obtain this information with +the @code{guix hash} (@pxref{Invoking guix hash}) and @code{guix +download} tools. @item @cindex GNU Build System @@ -1094,6 +1095,7 @@ space. @menu * Invoking guix build:: Building packages from the command line. +* Invoking guix hash:: Computing the cryptographic hash of a file. @end menu @node Invoking guix build @@ -1189,6 +1191,37 @@ the @code{package-derivation} procedure of the @code{(guix packages)} module, and to the @code{build-derivations} procedure of the @code{(guix store)} module. +@node Invoking guix hash +@section Invoking @command{guix hash} + +The @command{guix hash} command allows to check the integrity of a file. +It is primarily a convenience tool for anyone contributing to the +distribution: it computes the cryptographic hash of a file, which can be +used in the definition of a package (@pxref{Defining Packages}). + +The general syntax is: + +@example +guix hash @var{option} @var{file} +@end example + +@command{guix hash} has the following option: + +@table @code + +@item --format=@var{fmt} +@itemx -f @var{fmt} +Write the hash in the given format. + +Supported formats: @code{nix-base32}, @code{base32}, @code{base16} +(@code{hex} and @code{hexadecimal} can be used as well). + +If the @option{--format} option is not specified, @command{guix hash} +will output the hash in @code{nix-base32}. This representation is used +in the definitions of packages. + +@end table + @c ********************************************************************* @node GNU Distribution @chapter GNU Distribution diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm new file mode 100644 index 0000000000..ad05a4e66f --- /dev/null +++ b/guix/scripts/hash.scm @@ -0,0 +1,120 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2012, 2013 Ludovic Courtès +;;; Copyright © 2013 Nikita Karetnikov +;;; +;;; 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 . + +(define-module (guix scripts hash) + #:use-module (guix base32) + #:use-module (guix ui) + #:use-module (guix utils) + #:use-module (rnrs io ports) + #:use-module (rnrs files) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) + #:export (guix-hash)) + + +;;; +;;; Command-line options. +;;; + +(define %default-options + ;; Alist of default option values. + `((format . ,bytevector->nix-base32-string))) + +(define (show-help) + (display (_ "Usage: guix hash [OPTION] FILE +Return the cryptographic hash of FILE. + +Supported formats: 'nix-base32' (default), 'base32', and 'base16' +('hex' and 'hexadecimal' can be used as well).\n")) + (format #t (_ " + -f, --format=FMT write the hash in the given format")) + (newline) + (display (_ " + -h, --help display this help and exit")) + (display (_ " + -V, --version display version information and exit")) + (newline) + (show-bug-report-information)) + +(define %options + ;; Specification of the command-line options. + (list (option '(#\f "format") #t #f + (lambda (opt name arg result) + (define fmt-proc + (match arg + ("nix-base32" + bytevector->nix-base32-string) + ("base32" + bytevector->base32-string) + ((or "base16" "hex" "hexadecimal") + bytevector->base16-string) + (x + (leave (_ "unsupported hash format: ~a~%") + arg)))) + + (alist-cons 'format fmt-proc + (alist-delete 'format result)))) + + (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix hash"))))) + + + +;;; +;;; Entry point. +;;; + +(define (guix-hash . args) + (define (parse-options) + ;; Return the alist of option values. + (args-fold args %options + (lambda (opt name arg result) + (leave (_ "unrecognized option: ~a~%") + name)) + (lambda (arg result) + (alist-cons 'argument arg result)) + %default-options)) + + (let* ((opts (parse-options)) + (args (filter-map (match-lambda + (('argument . value) + value) + (_ #f)) + (reverse opts))) + (fmt (assq-ref opts 'format))) + + (match args + ((file) + (catch 'system-error + (lambda () + (format #t "~a~%" + (call-with-input-file file + (compose fmt sha256 get-bytevector-all)))) + (lambda args + (leave (_ "~a~%") + (strerror (system-error-errno args)))))) + (_ + (leave (_ "wrong number of arguments~%")))))) diff --git a/po/POTFILES.in b/po/POTFILES.in index 528e7a6aa7..3b01e2a2a5 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -8,6 +8,7 @@ guix/scripts/build.scm guix/scripts/download.scm guix/scripts/package.scm guix/scripts/gc.scm +guix/scripts/hash.scm guix/scripts/pull.scm guix/gnu-maintenance.scm guix/ui.scm -- cgit v1.2.3