From 243fe8b4946a81bc7db1b196336207bc5185d90c Mon Sep 17 00:00:00 2001 From: hayao Date: Sun, 10 May 2020 14:03:09 +0900 Subject: [PATCH] [update] : Added command line options. --- lubs | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/lubs b/lubs index 756152d..7d83856 100755 --- a/lubs +++ b/lubs @@ -8,14 +8,11 @@ export LANG=C arch=amd64 script_path=$(readlink -f ${0%/*}) work_dir="${script_path}/work" -cache_dir="${work_dir}/cache" -bootfiles_dir="${work_dir}/bootfiles" channels_dir="${script_path}/channels" isolinux_dir="${script_path}/isolinux" out_dir="${script_path}/out" codename="focal" mirror="http://ftp.jaist.ac.jp/pub/Linux/ubuntu/" - os_name="Ubuntu" iso_name="ubuntu" iso_label="${os_name}_${codename}_${arch}" @@ -83,7 +80,22 @@ _apt_install() { run_cmd apt-get --no-install-recommends --yes install ${@} } - +# Show help +_usage () { + echo "usage ${0} [options] [channel]" + echo + echo " General options:" + echo + echo " -a Set architecture" + echo " Default: ${arch}" + echo " -h This help message and exit." + echo + echo " -o Set the output directory" + echo " Default: ${out_dir}" + echo " -w Set the working directory" + echo " Default: ${work_dir}" + echo +} prepare_build() { @@ -305,6 +317,34 @@ make_checksum() { cd - > /dev/null 2>&1 } + +# Parse options +while getopts 'a:w:o:g:p:c:t:hbk:xs:jlu:d-:' arg; do + case "${arg}" in + w) work_dir="${OPTARG}" ;; + o) out_dir="${OPTARG}" ;; + h) _usage; exit 0 ;; + a) arch="${OPTARG}" ;; + -) + case "${OPTARG}" in + help) _usage; exit 0 ;; + *) + _msg_error "Invalid argument '${OPTARG}'" + _usage 1 + ;; + esac + ;; + *) + _msg_error "Invalid argument '${arg}'" + _usage 1 + ;; + esac +done + +cache_dir="${work_dir}/cache" +bootfiles_dir="${work_dir}/bootfiles" + + prepare_build run_once make_basefs run_once make_sourcelist -- 2.11.0