From 0f73578721f4bdb59bd73efba936b2c8178a2db9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 18 Dec 2012 20:45:02 +0000 Subject: [PATCH] Allow manual installation of packages. Rather than force creation of an element for a single package install, allow people to do this from the command line. Change-Id: I63e2e7e50c4a7dbb8a8e198581dfadce91773621 --- bin/disk-image-create | 6 +++++- lib/img-functions | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index d0b4f90f..1c49d0b5 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -27,11 +27,13 @@ function show_options () { echo " -o filename -- set the name of the output file" echo " -x -- turn on tracing" echo " -u -- uncompressed; do not compress the image - larger but faster" + echo " -p package[,package,package] -- list of packages to install in the image" exit 0 } +INSTALL_PACKAGES="" COMPRESS_IMAGE="true" -TEMP=`getopt -o a:ho:xu -n $SCRIPTNAME -- "$@"` +TEMP=`getopt -o a:ho:xup: -n $SCRIPTNAME -- "$@"` if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi echo "XXX $TEMP" @@ -45,6 +47,7 @@ while true ; do -h) show_options;; -x) shift; set -x;; -u) shift; export COMPRESS_IMAGE="";; + -p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;; --) shift ; break ;; *) echo "Internal error!" ; exit 1 ;; esac @@ -88,6 +91,7 @@ mount_tmp_image ${IMAGE_BLOCK_DEVICE} create_base run_d extra-data do_pre_install +do_extra_package_install do_install prepare_first_boot finalise_base diff --git a/lib/img-functions b/lib/img-functions index 945d790c..8e6278c9 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -231,3 +231,10 @@ function do_install () { run_d_in_target install unblock_daemons } + +function do_extra_package_install () { + # Install any packages that were requested with the -p command line option + if [ "$INSTALL_PACKAGES" != "" ]; then + run_in_target apt-get -y install ${INSTALL_PACKAGES[@]} + fi +}