From 7bc46ecc34ceb042ff890e5d306d0a2a736e891d Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 8 Sep 2019 14:35:44 +0200 Subject: doc: Add Guix Cookbook. * .gitignore: Update ignore list. * Makefile.am (assert-no-store-file-names): Exclude the cookbook. * bootstrap: Generate po files for cookbook translations. * doc/guix-cookbook.texi: New file. * doc/local.mk (info_TEXINFOS): Add it; add a rule to build cookbook translations. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): New variable. (EXTRA_DIST): Add cookbook pot file and po files. (doc-po-update-cookbook-%): New target. (doc-pot-update): Also update cookbook pot file. (doc-po-update): Also update cookbook po files. --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 7e3b5c1070..93d18d7df6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -814,7 +814,8 @@ assert-no-store-file-names: $(AM_V_at)if grep -r --exclude=*.texi --exclude=*.info \ --exclude=*.info-[0-9] --exclude=*.dot \ --exclude=*.eps --exclude-dir=bootstrap \ - --exclude=guix-manual.pot --exclude=guix-manual.*.po \ + --exclude=guix-manual.pot --exclude=guix-manual.*.po \ + --exclude=guix-cookbook.pot --exclude=guix-cookbook.*.po \ --exclude=guix-prettify.el \ --exclude=ChangeLog* \ -E "$(storedir)/[a-z0-9]{32}-" $(distdir) ; \ -- cgit v1.2.3 From aeb51370da7c854e8167066df9b138e15d7363e6 Mon Sep 17 00:00:00 2001 From: zimoun Date: Thu, 19 Sep 2019 19:24:42 +0200 Subject: guix package: Add 'guix show' alias. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/show.scm: New file. * Makefile.am (MODULES): Add it. * po/guix/POTFILES.in: Add it. * tests/guix-package-aliases.sh: Add test. * doc/guix.texi (Invoking guix package): Document it and use it in a example. Signed-off-by: Ludovic Courtès --- Makefile.am | 1 + doc/guix.texi | 8 ++++-- guix/scripts/show.scm | 67 +++++++++++++++++++++++++++++++++++++++++++ po/guix/POTFILES.in | 1 + tests/guix-package-aliases.sh | 4 +++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 guix/scripts/show.scm (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 93d18d7df6..f71ea77671 100644 --- a/Makefile.am +++ b/Makefile.am @@ -241,6 +241,7 @@ MODULES = \ guix/scripts/remove.scm \ guix/scripts/upgrade.scm \ guix/scripts/search.scm \ + guix/scripts/show.scm \ guix/scripts/gc.scm \ guix/scripts/hash.scm \ guix/scripts/pack.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 0ed59072c9..af1903f6ff 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2657,7 +2657,9 @@ For your convenience, we also provide the following aliases: @item @command{guix remove} is an alias for @command{guix package -r}, @item -and @command{guix upgrade} is an alias for @command{guix package -u}. +@command{guix upgrade} is an alias for @command{guix package -u}, +@item +and @command{guix show} is an alias for @command{guix package --show=}. @end itemize These aliases are less expressive than @command{guix package} and provide @@ -3020,9 +3022,9 @@ version: 3.3.5 @end example You may also specify the full name of a package to only get details about a -specific version of it: +specific version of it (this time using the @command{guix show} alias): @example -$ guix package --show=python@@3.4 | recsel -p name,version +$ guix show python@@3.4 | recsel -p name,version name: python version: 3.4.3 @end example diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm new file mode 100644 index 0000000000..94f0559358 --- /dev/null +++ b/guix/scripts/show.scm @@ -0,0 +1,67 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Simon Tournier +;;; +;;; 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 show) + #:use-module (guix ui) + #:use-module (guix scripts package) + #:use-module (guix scripts) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) + #:export (guix-show)) + +(define (show-help) + (display (G_ "Usage: guix show [OPTION] PACKAGE... +Show details about PACKAGE.")) + (display (G_" +This is an alias for 'guix package --show='.\n")) + (newline) + (display (G_ " + -h, --help display this help and exit")) + (display (G_ " + -V, --version display version information and exit")) + (newline) + (show-bug-report-information)) + +(define %options + ;; Specification of the command-line options. + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix show"))))) + +(define (guix-show . args) + (define (handle-argument arg result) + ;; Treat all non-option arguments as regexps. + (cons `(query show ,arg) + result)) + + (define opts + (args-fold* args %options + (lambda (opt name arg . rest) + (leave (G_ "~A: unrecognized option~%") name)) + handle-argument + '())) + + (unless (assoc-ref opts 'query) + (leave (G_ "missing arguments: no package to show~%"))) + + (guix-package* opts)) diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index 8b556ac0ec..f629034d61 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -47,6 +47,7 @@ guix/scripts/install.scm guix/scripts/remove.scm guix/scripts/upgrade.scm guix/scripts/search.scm +guix/scripts/show.scm guix/scripts/gc.scm guix/scripts/hash.scm guix/scripts/import.scm diff --git a/tests/guix-package-aliases.sh b/tests/guix-package-aliases.sh index 5c68664093..9c038b99a5 100644 --- a/tests/guix-package-aliases.sh +++ b/tests/guix-package-aliases.sh @@ -58,3 +58,7 @@ if guix remove -i guile-bootstrap -p "$profile" --bootstrap then false; else true; fi guix search '\' game | grep '^name: gnubg' + +guix show --version +guix show guile +guix show python@3 | grep "^name: python" -- cgit v1.2.3 From 873f6f1334ab06a69e768a8aea0054404237542f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 14 Sep 2019 17:54:06 +0200 Subject: git: Add 'commit-difference'. * guix/git.scm (commit-closure, commit-difference): New procedures. * guix/tests/git.scm, tests/git.scm: New files. * Makefile.am (dist_noinst_DATA): Add guix/tests/git.scm. (SCM_TESTS): Add tests/git.scm. --- .dir-locals.el | 1 + Makefile.am | 6 +++- guix/git.scm | 40 ++++++++++++++++++++++ guix/tests/git.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/git.scm | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 guix/tests/git.scm create mode 100644 tests/git.scm (limited to 'Makefile.am') diff --git a/.dir-locals.el b/.dir-locals.el index 228685a69f..22aac2c402 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -90,6 +90,7 @@ (eval . (put 'eventually 'scheme-indent-function 1)) (eval . (put 'call-with-progress-reporter 'scheme-indent-function 1)) + (eval . (put 'with-temporary-git-repository 'scheme-indent-function 2)) ;; This notably allows '(' in Paredit to not insert a space when the ;; preceding symbol is one of these. diff --git a/Makefile.am b/Makefile.am index f71ea77671..658f03bd54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -307,7 +307,10 @@ STORE_MODULES = \ MODULES += $(STORE_MODULES) # Internal modules with test suite support. -dist_noinst_DATA = guix/tests.scm guix/tests/http.scm +dist_noinst_DATA = \ + guix/tests.scm \ + guix/tests/http.scm \ + guix/tests/git.scm # Auxiliary files for packages. AUX_FILES = \ @@ -391,6 +394,7 @@ SCM_TESTS = \ tests/file-systems.scm \ tests/gem.scm \ tests/gexp.scm \ + tests/git.scm \ tests/glob.scm \ tests/gnu-maintenance.scm \ tests/grafts.scm \ diff --git a/guix/git.scm b/guix/git.scm index 92a7353b5a..d7dddde3a7 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -28,6 +28,7 @@ #:use-module (guix utils) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (guix sets) #:use-module (rnrs bytevectors) #:use-module (ice-9 match) #:use-module (srfi srfi-1) @@ -37,8 +38,10 @@ #:export (%repository-cache-directory honor-system-x509-certificates! + with-repository update-cached-checkout latest-repository-commit + commit-difference git-checkout git-checkout? @@ -339,6 +342,43 @@ Log progress and checkout info to LOG-PORT." (set-exception-printer! 'git-error print-git-error) + +;;; +;;; Commit difference. +;;; + +(define (commit-closure commit) + "Return the closure of COMMIT as a set." + (let loop ((commits (list commit)) + (visited (setq))) + (match commits + (() + visited) + ((head . tail) + (if (set-contains? visited head) + (loop tail visited) + (loop (append (commit-parents head) tail) + (set-insert head visited))))))) + +(define (commit-difference new old) + "Return the list of commits between NEW and OLD, where OLD is assumed to be +an ancestor of NEW. + +Essentially, this computes the set difference between the closure of NEW and +that of OLD." + (let loop ((commits (list new)) + (result '()) + (visited (commit-closure old))) + (match commits + (() + (reverse result)) + ((head . tail) + (if (set-contains? visited head) + (loop tail result visited) + (loop (append (commit-parents head) tail) + (cons head result) + (set-insert head visited))))))) + ;;; ;;; Checkouts. diff --git a/guix/tests/git.scm b/guix/tests/git.scm new file mode 100644 index 0000000000..52abe77c83 --- /dev/null +++ b/guix/tests/git.scm @@ -0,0 +1,97 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Ludovic Courtès +;;; +;;; 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 tests git) + #:use-module (git) + #:use-module (guix utils) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:use-module (ice-9 control) + #:export (git-command + with-temporary-git-repository + find-commit)) + +(define git-command + (make-parameter "git")) + +(define (populate-git-repository directory directives) + "Initialize a new Git checkout and repository in DIRECTORY and apply +DIRECTIVES. Each element of DIRECTIVES is an sexp like: + + (add \"foo.txt\" \"hi!\") + +Return DIRECTORY on success." + + ;; Note: As of version 0.2.0, Guile-Git lacks the necessary bindings to do + ;; all this, so resort to the "git" command. + (define (git command . args) + (apply invoke (git-command) "-C" directory + command args)) + + (mkdir-p directory) + (git "init") + + (let loop ((directives directives)) + (match directives + (() + directory) + ((('add file contents) rest ...) + (let ((file (string-append directory "/" file))) + (mkdir-p (dirname file)) + (call-with-output-file file + (lambda (port) + (display contents port))) + (git "add" file) + (loop rest))) + ((('commit text) rest ...) + (git "commit" "-m" text) + (loop rest)) + ((('branch name) rest ...) + (git "branch" name) + (loop rest)) + ((('checkout branch) rest ...) + (git "checkout" branch) + (loop rest)) + ((('merge branch message) rest ...) + (git "merge" branch "-m" message) + (loop rest))))) + +(define (call-with-temporary-git-repository directives proc) + (call-with-temporary-directory + (lambda (directory) + (populate-git-repository directory directives) + (proc directory)))) + +(define-syntax-rule (with-temporary-git-repository directory + directives exp ...) + "Evaluate EXP in a context where DIRECTORY contains a checkout populated as +per DIRECTIVES." + (call-with-temporary-git-repository directives + (lambda (directory) + exp ...))) + +(define (find-commit repository message) + "Return the commit in REPOSITORY whose message includes MESSAGE, a string." + (let/ec return + (fold-commits (lambda (commit _) + (and (string-contains (commit-message commit) + message) + (return commit))) + #f + repository) + (error "commit not found" message))) diff --git a/tests/git.scm b/tests/git.scm new file mode 100644 index 0000000000..8ba10ece51 --- /dev/null +++ b/tests/git.scm @@ -0,0 +1,99 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Ludovic Courtès +;;; +;;; 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 (test-git) + #:use-module (git) + #:use-module (guix git) + #:use-module (guix tests git) + #:use-module (guix build utils) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-64)) + +;; Test the (guix git) tools. + +(test-begin "git") + +;; 'with-temporary-git-repository' relies on the 'git' command. +(unless (which (git-command)) (test-skip 1)) +(test-assert "commit-difference, linear history" + (with-temporary-git-repository directory + '((add "a.txt" "A") + (commit "first commit") + (add "b.txt" "B") + (commit "second commit") + (add "c.txt" "C") + (commit "third commit") + (add "d.txt" "D") + (commit "fourth commit")) + (with-repository directory repository + (let ((commit1 (find-commit repository "first")) + (commit2 (find-commit repository "second")) + (commit3 (find-commit repository "third")) + (commit4 (find-commit repository "fourth"))) + (and (lset= eq? (commit-difference commit4 commit1) + (list commit2 commit3 commit4)) + (lset= eq? (commit-difference commit4 commit2) + (list commit3 commit4)) + (equal? (commit-difference commit3 commit2) + (list commit3)) + + ;; COMMIT4 is not an ancestor of COMMIT1 so we should get the + ;; empty list. + (null? (commit-difference commit1 commit4))))))) + +(unless (which (git-command)) (test-skip 1)) +(test-assert "commit-difference, fork" + (with-temporary-git-repository directory + '((add "a.txt" "A") + (commit "first commit") + (branch "devel") + (checkout "devel") + (add "devel/1.txt" "1") + (commit "first devel commit") + (add "devel/2.txt" "2") + (commit "second devel commit") + (checkout "master") + (add "b.txt" "B") + (commit "second commit") + (add "c.txt" "C") + (commit "third commit") + (merge "devel" "merge") + (add "d.txt" "D") + (commit "fourth commit")) + (with-repository directory repository + (let ((master1 (find-commit repository "first commit")) + (master2 (find-commit repository "second commit")) + (master3 (find-commit repository "third commit")) + (master4 (find-commit repository "fourth commit")) + (devel1 (find-commit repository "first devel")) + (devel2 (find-commit repository "second devel")) + (merge (find-commit repository "merge"))) + (and (equal? (commit-difference master4 merge) + (list master4)) + (lset= eq? (commit-difference master3 master1) + (list master3 master2)) + (lset= eq? (commit-difference devel2 master1) + (list devel2 devel1)) + + ;; The merge occurred between MASTER2 and MASTER4 so here we + ;; expect to see all the commits from the "devel" branch in + ;; addition to those on "master". + (lset= eq? (commit-difference master4 master2) + (list master4 merge master3 devel1 devel2))))))) + +(test-end "git") -- cgit v1.2.3 From dcc90d15581189dbc30e201db2b807273d6484f0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 15 Sep 2019 17:53:13 +0200 Subject: Add '.guix-channel' file. * .guix-channel: New file. * Makefile.am (EXTRA_DIST): Add it. --- .guix-channel | 5 +++++ Makefile.am | 1 + 2 files changed, 6 insertions(+) create mode 100644 .guix-channel (limited to 'Makefile.am') diff --git a/.guix-channel b/.guix-channel new file mode 100644 index 0000000000..3e618d79f8 --- /dev/null +++ b/.guix-channel @@ -0,0 +1,5 @@ +;; This is a Guix channel. + +(channel + (version 0) + (news-file "etc/news.scm")) diff --git a/Makefile.am b/Makefile.am index 658f03bd54..3c27d8ee10 100644 --- a/Makefile.am +++ b/Makefile.am @@ -533,6 +533,7 @@ EXTRA_DIST += \ TODO \ CODE-OF-CONDUCT \ .dir-locals.el \ + .guix-channel \ scripts/guix.in \ etc/guix-install.sh \ build-aux/build-self.scm \ -- cgit v1.2.3 From 90ca791ab082f0513cd5e8af7acfd8db63a6e73a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 15 Sep 2019 18:03:56 +0200 Subject: etc: Add channel news file. * etc/news.scm: New file. * Makefile.am (EXTRA_DIST): Add it. --- Makefile.am | 1 + etc/news.scm | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 etc/news.scm (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 3c27d8ee10..6a4cfcd4a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -536,6 +536,7 @@ EXTRA_DIST += \ .guix-channel \ scripts/guix.in \ etc/guix-install.sh \ + etc/news.scm \ build-aux/build-self.scm \ build-aux/compile-all.scm \ build-aux/hydra/evaluate.scm \ diff --git a/etc/news.scm b/etc/news.scm new file mode 100644 index 0000000000..736e8b5516 --- /dev/null +++ b/etc/news.scm @@ -0,0 +1,30 @@ +;; GNU Guix news, for use by 'guix pull'. +;; +;; Copyright © 2019 Ludovic Courtès +;; +;; Copying and distribution of this file, with or without modification, are +;; permitted in any medium without royalty provided the copyright notice and +;; this notice are preserved. + +(channel-news + (version 0) + (entry (commit "dcc90d15581189dbc30e201db2b807273d6484f0") + (title (en "New channel news mechanism") + (de "Neuer Mechanismus, um Neuigkeiten über Kanäle anzuzeigen.") + (fr "Nouveau mécanisme d'information sur les canaux")) + (body + (en "You are reading this message through the new channel news +mechanism, congratulations! This mechanism allows channel authors to provide +@dfn{news entries} that their users can view with @command{guix pull --news}. +Run @command{info \"(guix) Invoking guix pull\"} for more info.") + (de "Sie lesen diese Meldung mit Hilfe des neuen Mechanismus, um +Neuigkeiten über Kanäle anzuzeigen — Glückwunsch! Mit diesem +Mechanismus können Kanalautoren Ihren Nutzern @dfn{Einträge zu +Neuigkeiten} mitteilen, die diese sich mit @command{guix pull --news} +anzeigen lassen können. Führen Sie @command{info \"(guix.de) Aufruf +von guix pull\"} aus, um weitere Informationen zu erhalten.") + (fr "Ce message t'arrive à travers le nouveau mécanisme d'information +des canaux, bravo ! Ce mécanisme permet aux auteur·rice·s de canaux de +fournir des informations qu'on peut visualiser avec @command{guix pull +--news}. Tape @command{info \"(guix.fr) Invoquer guix pull\"} pour plus de +détails.")))) -- cgit v1.2.3