From 1c387eecd96250d8c530743e7e2fda2637faa984 Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 16:59:19 +0100 Subject: new mltk --- mltk | 97 +++++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 44 deletions(-) (limited to 'mltk') diff --git a/mltk b/mltk index ac79798e..49ceee09 100755 --- a/mltk +++ b/mltk @@ -46,35 +46,38 @@ banner () { } print_usage() { - echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" - echo "Usage: $(basename ${SELF}) remote target_dir [-d] [-c [module]*] [-b [module]*] [-p profile]" - echo " $(basename ${SELF}) server [-d] [-c] [-b] [-n]" + echo -e "" + echo -e "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" + echo -e "Usage: $(basename ${SELF}) remote [-d] [-c [module]*] [-b [module]*] [-p profile]" + echo -e " $(basename ${SELF}) server [-e stage31|stage32|addons] [-d] [-c]" echo -e "" echo -e " Mode:" - echo -e " server \t server mode: packs stage3.1 and stage3.2 as initramfs/squashfs." - echo -e " remote \t remote mode: builds a minimal systemd-based rootfs based on the activated modules in " + echo -e " server \t server mode: packs stage3.1, stage3.2 or addons as initramfs/squashfs." + echo -e " remote \t remote mode: builds a minimal rootfs based on the activated modules in " echo -e "" echo -e " Mode options:" - echo -e " -b build module(s)." - echo -e " -c clean module(s)." - echo -e " -d activates debug output for current target" + echo -e " -b remote: build module(s)" + echo -e " -e type server: export target as stage31, stage32 or addons" + echo -e " -c remote: clean module(s). / server: clean target in remote_builds/ and corresponding files under boot/" + echo -e " -d activates debug output for current target/build" echo -e " -p profile build all modules from given profile" - echo -e " -n don't generate squashfs from stage 3.2" echo -e "" echo -e " In mode 'remote', you can pass names of specific modules to clean/build." echo -e " Otherwise, all modules will be built/cleaned." echo -e "" echo -e " Examples:" - echo -e " remote stage3.1 -b (build all the modules activated (linked) in remote/stage3.1 in remote/build/stage3.1" - echo -e " remote stage3.1 -b plymouth (build plymouth in remote/build/stage3.1)" - echo -e " remote stage3.2 -c -b base policykit sshd (clean all modules, build base, policykit and sshd in remote/build/stage3.2)" - echo -e " remote stage3.2 -c -b (clean all modules, build all modules in remote/build/stage3.2)" - echo -e " remote stage3.2 -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)" - echo -e " remote stage3.2 -c -p default (clean all modules, build modules listed in profile default)" - echo -e " server -c -b (clean and build the initramfs archives under /server/build)" + echo -e " remote stage31 -c -b (clean all modules and build all linked modules in remote/targets/stage31 to remote/builds/stage31)" + echo -e " remote stage32 -c -b rootfs_stage31 sshd (clean all modules, build base, policykit and sshd in remote/builds/stage32)" + echo -e " remote stage32 -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)" + echo -e " server stage32 -e stage32 (pack stage32 as squashfs+initramfs)" + echo -e " server stage31 -c (clean stage31 build under server/remote_builds and initramfs under server/boot)" + echo -e " server addons-eexam -e addons (pack eexam-addons as squashfs)" + echo -e "" + echo -e " Existing targets for remote are:" + echo -e " $(echo $(ls ${ROOT_DIR}/remote/targets 2>/dev/null || echo "No targets for remote found."))" + echo -e " Existing targets for server are:" + echo -e " $(echo $(ls ${ROOT_DIR}/server/remote_builds 2>/dev/null || echo "No targets for remote found."))" echo -e "" - echo -e " Existing modules for remote are:" - echo -e " $(echo $(ls ${ROOT_DIR}/remote/tools))" } initial_checks() { @@ -89,15 +92,18 @@ initial_checks() { pinfo "Kernel version: $KERNEL_VERSION" pinfo "System's packet manager is $PACKET_MANAGER" - # setup_tools and build_core - SETUP_TARGET="${ROOT_DIR}/remote/setup_target" - [ ! -e "${SETUP_TARGET}" ] && perror "Missing script 'remote/setup_target', re-clone git. Exiting." + # setup_target and export_target + REMOTE_SETUP_TARGET="${ROOT_DIR}/remote/setup_target" + SERVER_EXPORT_TARGET="${ROOT_DIR}/server/export_target" + + [ ! -e "${REMOTE_SETUP_TARGET}" ] && perror "Missing script remote/setup_target. Exiting." + [ ! -e "${SERVER_EXPORT_TARGET}" ] && perror "Missing script server/export_target. Exiting." } read_params() { local MODE="" local SUBMODE="" - # select target: core or tools + # select mode: remote or server case "$1" in server) MODE="SERVER" @@ -113,14 +119,13 @@ read_params() { esac shift - # set the global TARGET if in remote mode. - if [[ $MODE == REMOTE ]]; then - if [[ $1 != "-"* ]]; then - TARGET=$1 - shift - else - perror "Remote mode requires a target directory. None given." - fi + TARGET="" + # set target. + if [[ $1 != "-"* ]]; then + TARGET=$1 + shift + else + perror "A target is required. None given." fi # handle rest of arguments @@ -135,6 +140,7 @@ read_params() { SUBMODE="CLEAN" ;; -b) + [ "$MODE" != "REMOTE" ] && perror "-b can only be used in remote mode" SUBMODE="BUILD" ;; -d) @@ -151,9 +157,13 @@ read_params() { shift continue ;; - -n) - [ "$MODE" != "SERVER" ] && perror "-n can only be used in server mode" - SERVER_NO_SQUASHFS="1" + -e) + [ "$#" -lt "1" ] && perror "Missing argument to -e" + [ "$MODE" != "SERVER" ] && perror "-e can only be used in server mode" + [[ "stage31|stage32|addons" != *"$1"* ]] && perror "Wrong type specified. Muste be either 'stage31', 'stage32' or 'addons'" + SERVER_EXPORT="1" + SERVER_EXPORT_TYPE="$1" + shift continue ;; *) @@ -173,29 +183,28 @@ read_params() { done # exit if no command - [[ $SERVER_CLEAN == 0 && $SERVER_BUILD == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 ]] && print_usage && exit 1 + [[ $SERVER_CLEAN == 0 && $SERVER_EXPORT == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 ]] && print_usage && exit 1 } run() { if [[ $REMOTE_CLEAN == 1 || $REMOTE_BUILD == 1 ]]; then [[ $REMOTE_DEBUG == 1 ]] && unset_quiet || set_quiet - . "${SETUP_TARGET}" || perror "Cannot source ${SETUP_TARGET}" - [[ $REMOTE_CLEAN == 1 ]] && clean_modules $REMOTE_LIST_CLEAN - [[ $REMOTE_BUILD == 1 ]] && generate_target $REMOTE_LIST_BUILD + . "${REMOTE_SETUP_TARGET}" || perror "Cannot source ${REMOTE_SETUP_TARGET}" + [[ $REMOTE_CLEAN == 1 ]] && clean_modules $TARGET $REMOTE_LIST_CLEAN + [[ $REMOTE_BUILD == 1 ]] && generate_target $TARGET $REMOTE_LIST_BUILD fi - if [[ $SERVER_CLEAN == 1 || $SERVER_BUILD == 1 ]]; then + if [[ $SERVER_CLEAN == 1 || $SERVER_EXPORT == 1 ]]; then [[ $SERVER_DEBUG == 1 ]] && unset_quiet || set_quiet - local TOOL_STR="[CORE]" - . "${SETUP_CORE}" || perror "Cannot source ${SETUP_CORE}" - [[ $SERVER_CLEAN == 1 ]] && clean_core - [[ $SERVER_BUILD == 1 ]] && generate_stage31 + . "${SERVER_EXPORT_TARGET}" || perror "Cannot source ${SERVER_EXPORT_TARGET}" + [[ $SERVER_CLEAN == 1 ]] && clean_target $TARGET + [[ $SERVER_EXPORT == 1 ]] && export_target $TARGET $SERVER_EXPORT_TYPE fi } SERVER_DEBUG="0" -SERVER_BUILD="0" +SERVER_EXPORT="0" SERVER_CLEAN="0" -SERVER_NO_SQUASHFS="0" +SERVER_EXPORT_TYPE="" REMOTE_DEBUG="0" REMOTE_CLEAN="0" REMOTE_BUILD="0" -- cgit v1.2.3-55-g7522