guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/04: pack: 'guix pack -R' wrapper correctly reports exit code.


From: guix-commits
Subject: 02/04: pack: 'guix pack -R' wrapper correctly reports exit code.
Date: Fri, 24 Apr 2020 10:22:27 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 2520059bdb43fa1663ce102f3f4c442d4918c32b
Author: Ludovic Courtès <address@hidden>
AuthorDate: Fri Apr 24 14:30:38 2020 +0200

    pack: 'guix pack -R' wrapper correctly reports exit code.
    
    Fixes <https://bugs.gnu.org/40816>.
    Reported by Jan (janneke) Nieuwenhuizen <address@hidden>.
    
    * gnu/packages/aux-files/run-in-namespace.c (main): In the 'default'
    case, check 'WIFEXITED (status)' and exit with the corresponding code in
    that case.  Exit with 255 in other cases.
    * tests/guix-pack-relocatable.sh: Add test.
---
 gnu/packages/aux-files/run-in-namespace.c | 10 ++++++++--
 tests/guix-pack-relocatable.sh            |  6 +++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/aux-files/run-in-namespace.c 
b/gnu/packages/aux-files/run-in-namespace.c
index 551f4db..160f7da 100644
--- a/gnu/packages/aux-files/run-in-namespace.c
+++ b/gnu/packages/aux-files/run-in-namespace.c
@@ -1,5 +1,5 @@
 /* GNU Guix --- Functional package management for GNU
-   Copyright (C) 2018, 2019 Ludovic Courtès <address@hidden>
+   Copyright (C) 2018, 2019, 2020 Ludovic Courtès <address@hidden>
 
    This file is part of GNU Guix.
 
@@ -343,7 +343,13 @@ Please refer to the 'guix pack' documentation for more 
information.\n");
            chdir ("/");                          /* avoid EBUSY */
            rm_rf (new_root);
            free (new_root);
-           exit (status);
+
+           if (WIFEXITED (status))
+             exit (WEXITSTATUS (status));
+           else
+             /* Abnormal termination cannot really be reproduced, so exit
+                with 255.  */
+             exit (255);
          }
        }
     }
diff --git a/tests/guix-pack-relocatable.sh b/tests/guix-pack-relocatable.sh
index e93610e..a3fd456 100644
--- a/tests/guix-pack-relocatable.sh
+++ b/tests/guix-pack-relocatable.sh
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2018, 2019 Ludovic Courtès <address@hidden>
+# Copyright © 2018, 2019, 2020 Ludovic Courtès <address@hidden>
 #
 # This file is part of GNU Guix.
 #
@@ -72,6 +72,10 @@ then
     # mounting an empty file system on top of it.  That way, we exercise the
     # wrapper code that creates the user namespace and bind-mounts the store.
     unshare -mrf sh -c 'mount -t tmpfs none "$STORE_PARENT"; echo 
"$STORE_PARENT"/*; "$test_directory/Bin/sed" --version > 
"$test_directory/output"'
+
+    # Check whether the exit code is preserved.
+    if unshare -mrf sh -c 'mount -t tmpfs none "$STORE_PARENT"; echo 
"$STORE_PARENT"/*; "$test_directory/Bin/sed" --does-not-exist';
+    then false; else true; fi
 else
     # Run the relocatable 'sed' in the current namespaces.  This is a weak
     # test because we're going to access store items from the host store.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]