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 +}