From f8b4b2ba71d6afb99d918d20920d656b1a22a481 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta <vivek.dutta@iopsys.eu> Date: Fri, 17 May 2024 10:35:31 +0530 Subject: [PATCH] template: option to install additional packages --- scripts/crun_create | 17 ++++++++++++++--- templates/lxc-iopsys | 11 ++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/crun_create b/scripts/crun_create index 9588244..ecdbb5a 100755 --- a/scripts/crun_create +++ b/scripts/crun_create @@ -579,13 +579,22 @@ configure_busybox() copy_prereq() { + local rootfs extrapkg + rootfs="${1}" + shift + extrapkg="${@}" req_pkg="procd uci opkg ip-full curl libstdcpp6 librt" for p in ${req_pkg}; do /usr/share/swmodd/opkg_offline "${rootfs}" "${p}" done + for p in ${extrapkg}; do + /usr/share/swmodd/opkg_offline "${rootfs}" "${p}" + done + + cp /etc/preinit "${rootfs}/etc/preinit" cp /etc/diag.sh "${rootfs}/etc/diag.sh" cp /sbin/mount_root "${rootfs}/sbin/mount_root" @@ -600,9 +609,11 @@ copy_prereq() create_container() { - local name + local name extrapkg name="${1}" + shift + extrapkg="${@}" # Make sure container already not created list=$(crun list 2>&1 | tail -n +2 | grep "${name}" | awk '{print $1}') @@ -642,7 +653,7 @@ create_container() exit 1 fi - if ! copy_prereq "${rootfs}"; then + if ! copy_prereq "${rootfs}" "${extrapkg}"; then echo "ERROR: Failed to copy required binaries" 1>&2 exit 1 fi @@ -745,6 +756,6 @@ set_bundle_path if [ "$config" -eq "1" ]; then generate_config "$name" else - create_container "$name" + create_container "$name" "${@}" generate_config "${name}" fi diff --git a/templates/lxc-iopsys b/templates/lxc-iopsys index b89c2c7..a23d81d 100755 --- a/templates/lxc-iopsys +++ b/templates/lxc-iopsys @@ -231,13 +231,21 @@ configure_busybox() copy_prereq() { + local rootfs pkgs + rootfs="${1}" + shift + pkgs="${@}" req_pkg="procd uci opkg ip-full curl libstdcpp6 librt" for p in ${req_pkg}; do /usr/share/swmodd/opkg_offline "${rootfs}" "${p}" done + for p in ${pkgs}; do + /usr/share/swmodd/opkg_offline "${rootfs}" "${p}" + done + cp /etc/preinit "${rootfs}/etc/preinit" cp /etc/diag.sh "${rootfs}/etc/diag.sh" cp /sbin/mount_root "${rootfs}/sbin/mount_root" @@ -360,6 +368,7 @@ do esac done +PKGS="$@" # Check that we have all variables we need if [ -z "${name}" ] || [ -z "${path}" ]; then echo "ERROR: Please pass the name and path for the container" 1>&2 @@ -406,7 +415,7 @@ if ! remap_userns "${path}"; then exit 1 fi -if ! copy_prereq "${rootfs}"; then +if ! copy_prereq "${rootfs}" "${PKGS}"; then echo "ERROR: Failed to copy required binaries" 1>&2 exit 1 fi -- GitLab