From 48023e336bc95bda974f1e772e209dc07f3b1e05 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Mon, 29 Aug 2011 01:45:49 -0300 Subject: [configs/releng] Support configurable build options via command line usage ./build.sh [options] command General options: -N Set an iso filename (prefix) Default: archlinux -V Set an iso version (in filename) Default: 2011.08.18 -L Set an iso label (disk label) Default: ARCH_201108 -D Set an install_dir (directory inside iso) Default: arch -w Set the working directory Default: work -o Set the output directory Default: out -v Enable verbose output -h This help message Commands: build Build selected .iso by and purge Clean working directory except iso/ directory of build clean Clean working directory and .iso file in output directory of build Command options: Valid values 'single' or 'dual' Valid values 'netinstall', 'core' or 'all' Signed-off-by: Gerardo Exequiel Pozzi --- configs/releng/build.sh | 239 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 175 insertions(+), 64 deletions(-) (limited to 'configs') diff --git a/configs/releng/build.sh b/configs/releng/build.sh index 7660ee9..feac4a8 100755 --- a/configs/releng/build.sh +++ b/configs/releng/build.sh @@ -9,7 +9,7 @@ install_dir=arch arch=$(uname -m) work_dir=work out_dir=out -verbose="n" +verbose="" script_path=$(readlink -f ${0%/*}) @@ -214,13 +214,82 @@ make_dual() { fi } +purge_single () +{ + if [[ -d ${work_dir} ]]; then + find ${work_dir} -mindepth 1 -maxdepth 1 \ + ! -path ${work_dir}/iso -prune \ + | xargs rm -rf + fi +} + +purge_dual () +{ + if [[ -d ${work_dir}/dual ]]; then + find ${work_dir}/dual -mindepth 1 -maxdepth 1 \ + ! -path ${work_dir}/dual/iso -prune \ + | xargs rm -rf + fi +} + +clean_single () +{ + rm -rf ${work_dir} + rm -f ${out_dir}/${iso_name}-${iso_version}-*-${arch}.iso +} +clean_dual () +{ + rm -rf ${work_dir}/dual + rm -f ${out_dir}/${iso_name}-${iso_version}-*-dual.iso +} + +make_common_single() { + make_basefs + make_packages + make_customize_root_image + make_setup_mkinitcpio + make_boot + make_syslinux + make_isolinux + make_lib_modules + make_usr_share + make_aitab $1 + make_prepare $1 + make_iso $1 +} _usage () { - echo "usage ${0##*/} net_iso_single | core_iso_single | all_iso_single | purge_single | clean_single" - echo " net_iso_dual | core_iso_dual | all_iso_dual | purge_dual | clean_dual" + echo "usage ${0} [options] command " + echo + echo " General options:" + echo " -N Set an iso filename (prefix)" + echo " Default: ${iso_name}" + echo " -V Set an iso version (in filename)" + echo " Default: ${iso_version}" + echo " -L Set an iso label (disk label)" + echo " Default: ${iso_label}" + echo " -D Set an install_dir (directory inside iso)" + echo " Default: ${install_dir}" + echo " -w Set the working directory" + echo " Default: ${work_dir}" + echo " -o Set the output directory" + echo " Default: ${out_dir}" + echo " -v Enable verbose output" + echo " -h This help message" echo + echo " Commands:" + echo " build " + echo " Build selected .iso by and " + echo " purge " + echo " Clean working directory except iso/ directory of build " + echo " clean " + echo " Clean working directory and .iso file in output directory of build " + echo + echo " Command options:" + echo " Valid values 'single' or 'dual'" + echo " Valid values 'netinstall', 'core' or 'all'" exit ${1} } @@ -229,81 +298,123 @@ if [[ ${EUID} -ne 0 ]]; then _usage 1 fi +while getopts 'N:V:L:D:w:o:vh' arg; do + case "${arg}" in + N) iso_name="${OPTARG}" ;; + V) iso_version="${OPTARG}" ;; + L) iso_label="${OPTARG}" ;; + D) install_dir="${OPTARG}" ;; + w) work_dir="${OPTARG}" ;; + o) out_dir="${OPTARG}" ;; + v) verbose="-v" ;; + h|?) _usage 0 ;; + *) + _msg_error "Invalid argument '${arg}'" 0 + _usage 1 + ;; + esac +done + +shift $((OPTIND - 1)) + if [[ $# -lt 1 ]]; then echo "No command specified" _usage 1 fi command_name="${1}" -if [[ ${verbose} == "y" ]]; then - verbose="-v" -else - verbose="" +if [[ $# -lt 2 ]]; then + echo "No command mode specified" + _usage 1 fi +command_mode="${2}" -if [[ ${command_name} =~ single ]]; then - work_dir=${work_dir}/${arch} +if [[ ${command_name} == "build" ]]; then + if [[ $# -lt 3 ]]; then + echo "No build type specified" + _usage 1 + fi +command_type="${3}" fi -make_common_single() { - make_basefs - make_packages - make_customize_root_image - make_setup_mkinitcpio - make_boot - make_syslinux - make_isolinux - make_lib_modules - make_usr_share - make_aitab $1 - make_prepare $1 - make_iso $1 -} +if [[ ${command_mode} == "single" ]]; then + work_dir=${work_dir}/${arch} +fi case "${command_name}" in - net_iso_single) - make_common_single netinstall - ;; - core_iso_single) - make_core_repo - make_common_single core - ;; - all_iso_single) - make_common_single netinstall - make_core_repo - make_common_single core - ;; - net_iso_dual) - make_dual netinstall - ;; - core_iso_dual) - make_dual core - ;; - all_iso_dual) - make_dual netinstall - make_dual core - ;; - purge_single) - if [[ -d ${work_dir} ]]; then - find ${work_dir} -mindepth 1 -maxdepth 1 \ - ! -path ${work_dir}/iso -prune \ - | xargs rm -rf - fi - ;; - purge_dual) - if [[ -d ${work_dir}/dual ]]; then - find ${work_dir}/dual -mindepth 1 -maxdepth 1 \ - ! -path ${work_dir}/dual/iso -prune \ - | xargs rm -rf - fi + build) + case "${command_mode}" in + single) + case "${command_type}" in + netinstall) + make_common_single netinstall + ;; + core) + make_core_repo + make_common_single core + ;; + all) + make_common_single netinstall + make_core_repo + make_common_single core + ;; + *) + echo "Invalid build type '${command_type}'" + _usage 1 + ;; + esac + ;; + dual) + case "${command_type}" in + netinstall) + make_dual netinstall + ;; + core) + make_dual core + ;; + all) + make_dual netinstall + make_dual core + ;; + *) + echo "Invalid build type '${command_type}'" + _usage 1 + ;; + esac + ;; + *) + echo "Invalid build mode '${command_mode}'" + _usage 1 + ;; + esac ;; - clean_single) - rm -rf ${work_dir} - rm -f ${out_dir}/${iso_name}-${iso_version}-*-${arch}.iso + purge) + case "${command_mode}" in + single) + purge_single + ;; + dual) + purge_dual + ;; + *) + echo "Invalid purge mode '${command_mode}'" + _usage 1 + ;; + esac ;; - clean_dual) - rm -rf ${work_dir}/dual - rm -f ${out_dir}/${iso_name}-${iso_version}-*-dual.iso + clean) + case "${command_mode}" in + single) + clean_single + ;; + dual) + clean_dual + ;; + *) + echo "Invalid clean mode '${command_mode}'" + _usage 1 + ;; + esac ;; *) echo "Invalid command name '${command_name}'" -- cgit v1.2.2