[lxc-devel] [lxc/master] New --bbpath option and unecessary --rootfs checks

Rachid-Koucha on Github lxc-bot at linuxcontainers.org
Fri May 10 15:01:26 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 657 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190510/3b796561/attachment.bin>
-------------- next part --------------
From e7962394064746793403143de177f09220eb9419 Mon Sep 17 00:00:00 2001
From: Rachid Koucha <47061324+Rachid-Koucha at users.noreply.github.com>
Date: Fri, 10 May 2019 17:01:13 +0200
Subject: [PATCH] New --bbpath option and unecessary --rootfs checks

. Add the "--bbpath" option to pass an alternate busybox pathname instead of the one found from ${PATH}.
. Take this opportunity to add some formatting in the usage display
. As a try is done to pick rootfs from the config file and set it to ${path}/rootfs, it is unnecessary to make it mandatory

Signed-off-by: Rachid Koucha <rachid.koucha at gmail.com>
---
 templates/lxc-busybox.in | 41 +++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index 3601655036..22cf27835d 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -23,7 +23,7 @@
 LXC_MAPPED_UID=
 LXC_MAPPED_GID=
 
-BUSYBOX_EXE=
+BUSYBOX_EXE=`which busybox`
 
 # Make sure the usual locations are in PATH
 export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin
@@ -266,19 +266,26 @@ usage() {
 LXC busybox image builder
 
 Special arguments:
-[ -h | --help ]: Print this help message and exit.
-
-LXC internal arguments (do not pass manually!):
-[ --name <name> ]: The container name
-[ --path <path> ]: The path to the container
-[ --rootfs <rootfs> ]: The path to the container's rootfs
-[ --mapped-uid <map> ]: A uid map (user namespaces)
-[ --mapped-gid <map> ]: A gid map (user namespaces)
+
+  [ -h | --help ]: Print this help message and exit.
+
+LXC internal arguments:
+
+  [ --name <name> ]: The container name
+  [ --path <path> ]: The path to the container
+  [ --rootfs <rootfs> ]: The path to the container's rootfs (default: config or <path>/rootfs)
+  [ --mapped-uid <map> ]: A uid map (user namespaces)
+  [ --mapped-gid <map> ]: A gid map (user namespaces)
+
+BUSYBOX template specific arguments:
+
+  [ --bbpath <path> ]: busybox pathname (default: ${BUSYBOX_EXE})
+
 EOF
   return 0
 }
 
-if ! options=$(getopt -o hp:n: -l help,rootfs:,path:,name:,mapped-uid:,mapped-gid: -- "$@"); then
+if ! options=$(getopt -o hp:n: -l help,rootfs:,path:,name:,mapped-uid:,mapped-gid:,bbpath: -- "$@"); then
   usage
   exit 1
 fi
@@ -293,21 +300,25 @@ do
     --rootfs)     rootfs=$2; shift 2;;
     --mapped-uid) LXC_MAPPED_UID=$2; shift 2;;
     --mapped-gid) LXC_MAPPED_GID=$2; shift 2;;
+    --bbpath) BUSYBOX_EXE=$2; shift 2;;
     --)           shift 1; break ;;
     *)            break ;;
   esac
 done
 
 # Check that we have all variables we need
-if [ -z "${name}" ] || [ -z "${path}" ] || [ -z "${rootfs}" ]; then
-    echo "ERROR: Please pass the name, path, and rootfs for the container" 1>&2
+if [ -z "${name}" ] || [ -z "${path}" ]; then
+    echo "ERROR: Please pass the name and path for the container" 1>&2
     exit 1
 fi
 
 # Make sure busybox is present
-BUSYBOX_EXE=`which busybox`
-if [ $? -ne 0 ]; then
-    echo "ERROR: Failed to find busybox binary" 1>&2
+if [ -z "${BUSYBOX_EXE}" ]; then
+    echo "ERROR: Please pass a pathname for busybox binary" 1>&2
+    exit 1
+fi
+if [ ! -x "${BUSYBOX_EXE}" ]; then
+    echo "ERROR: Failed to find busybox binary (${BUSYBOX_EXE})" 1>&2
     exit 1
 fi
 


More information about the lxc-devel mailing list