From ad167d028e97dca1937ad6ae3d89d2c4de997754 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 3 Feb 2017 11:26:25 +0100 Subject: file-systems: Remove dependency on (guix store). (gnu system file-systems) is used on the "build" side since commit 5970e8e248f6327c41c83b86bb2c89be7c3b1b4e. * gnu/system/file-systems.scm: Remove dependency on (guix store). (%store-prefix): New procedure. * tests/file-systems.scm ("does not pull (guix config)"): New test. --- tests/file-systems.scm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/file-systems.scm b/tests/file-systems.scm index fd1599e132..467ee8ca5d 100644 --- a/tests/file-systems.scm +++ b/tests/file-systems.scm @@ -18,6 +18,7 @@ (define-module (test-file-systems) #:use-module (guix store) + #:use-module (guix modules) #:use-module (gnu system file-systems) #:use-module (srfi srfi-64) #:use-module (rnrs bytevectors)) @@ -72,4 +73,11 @@ (device "/foo") (flags '(bind-mount read-only))))))))) +(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 + ;; config. + (not (member '(guix config) + (source-module-closure '((gnu system file-systems)))))) + (test-end) -- cgit v1.2.3 From c90db25f4cf1f98f3f4f3af38d175a14ffb8c32a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 6 Feb 2017 23:45:00 +0100 Subject: linux-container: Add 'container-excursion*'. * gnu/build/linux-container.scm (container-excursion*): New procedure. * tests/containers.scm ("container-excursion*") ("container-excursion*, same namespaces"): New tests. --- gnu/build/linux-container.scm | 22 +++++++++++++++++++++- tests/containers.scm | 27 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index dd56a79232..95bfd92dde 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson +;;; Copyright © 2017 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,7 +33,8 @@ %namespaces run-container call-with-container - container-excursion)) + container-excursion + container-excursion*)) (define (user-namespace-supported?) "Return #t if user namespaces are supported on this system." @@ -326,3 +328,21 @@ return the exit status." (match (waitpid pid) ((_ . status) (status:exit-val status)))))) + +(define (container-excursion* pid thunk) + "Like 'container-excursion', but return the return value of THUNK." + (match (pipe) + ((in . out) + (match (container-excursion pid + (lambda () + (close-port in) + (write (thunk) out))) + (0 + (close-port out) + (let ((result (read in))) + (close-port in) + result)) + (_ ;maybe PID died already + (close-port out) + (close-port in) + #f))))) diff --git a/tests/containers.scm b/tests/containers.scm index 745b56b710..0b3a4be12b 100644 --- a/tests/containers.scm +++ b/tests/containers.scm @@ -180,4 +180,31 @@ (lambda () (primitive-exit 42)))) +(skip-if-unsupported) +(test-assert "container-excursion*" + (call-with-temporary-directory + (lambda (root) + (define (namespaces pid) + (let ((pid (number->string pid))) + (map (lambda (ns) + (readlink (string-append "/proc/" pid "/ns/" ns))) + '("user" "ipc" "uts" "net" "pid" "mnt")))) + + (let* ((pid (run-container root '() + %namespaces 1 + (lambda () + (sleep 100)))) + (result (container-excursion* pid + (lambda () + (namespaces 1))))) + (kill pid SIGKILL) + (equal? result (namespaces pid)))))) + +(skip-if-unsupported) +(test-equal "container-excursion*, same namespaces" + 42 + (container-excursion* (getpid) + (lambda () + (* 6 7)))) + (test-end) -- cgit v1.2.3 From 4eaac4b722b180b433b75127a30b871aaf9f0913 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 8 Feb 2017 15:58:36 +0100 Subject: import: pypi: Correctly handle multiple-URL origins. Fixes . Reported by Sergei Trofimovich . * guix/import/pypi.scm (guix-package->pypi-name)[url->pypi-name]: New procedure. Rewrite body to match lists in addition to strings. * tests/pypi.scm ("guix-package->pypi-name, several URLs"): New test. --- guix/import/pypi.scm | 13 ++++++++++--- tests/pypi.scm | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index ed0d4297a4..1e433e3fb3 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 David Thompson ;;; Copyright © 2015 Cyril Roelandt -;;; Copyright © 2015, 2016 Ludovic Courtès +;;; Copyright © 2015, 2016, 2017 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -89,9 +89,16 @@ package." (define (guix-package->pypi-name package) "Given a Python PACKAGE built from pypi.python.org, return the name of the package on PyPI." - (let ((source-url (and=> (package-source package) origin-uri))) + (define (url->pypi-name url) (hyphen-package-name->name+version - (basename (file-sans-extension source-url))))) + (basename (file-sans-extension url)))) + + (match (and=> (package-source package) origin-uri) + ((? string? url) + (url->pypi-name url)) + ((lst ...) + (any url->pypi-name lst)) + (#f #f))) (define (wheel-url->extracted-directory wheel-url) (match (string-split (basename wheel-url) #\-) diff --git a/tests/pypi.scm b/tests/pypi.scm index 447c23ee95..a132900566 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -22,6 +22,7 @@ #:use-module (guix base32) #:use-module (guix hash) #:use-module (guix tests) + #:use-module (guix build-system python) #:use-module ((guix build utils) #:select (delete-file-recursively which)) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) @@ -90,6 +91,15 @@ baz > 13.37") (uri "https://pypi.python.org/packages/a2/3b/4756e6a0ceb14e084042a2a65c615d68d25621c6fd446d0fc10d14c4ce7d/certbot-0.8.1.tar.gz")))))) +(test-equal "guix-package->pypi-name, several URLs" + "cram" + (guix-package->pypi-name + (dummy-package "foo" + (source + (dummy-origin + (uri (list "https://bitheap.org/cram/cram-0.7.tar.gz" + (pypi-uri "cram" "0.7")))))))) + (test-assert "pypi->guix-package" ;; Replace network resources with sample data. (mock ((guix import utils) url-fetch -- cgit v1.2.3