summaryrefslogtreecommitdiffstats
path: root/mltk
diff options
context:
space:
mode:
authorJonathan Bauer2013-03-14 14:22:20 +0100
committerJonathan Bauer2013-03-14 14:22:20 +0100
commit2a94d11a5525f66698678a76f1341831b2e622f7 (patch)
treed68bf6ae8b5f9c227002c0e8c4bfafb9c48160d8 /mltk
parentMerge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff)
downloadtm-scripts-2a94d11a5525f66698678a76f1341831b2e622f7.tar.gz
tm-scripts-2a94d11a5525f66698678a76f1341831b2e622f7.tar.xz
tm-scripts-2a94d11a5525f66698678a76f1341831b2e622f7.zip
new arguments for mltk, see manpages & changed INIT_DIR to TARGET_BUILD DIR
Diffstat (limited to 'mltk')
-rwxr-xr-xmltk119
1 files changed, 65 insertions, 54 deletions
diff --git a/mltk b/mltk
index b4ee268c..7e6945c3 100755
--- a/mltk
+++ b/mltk
@@ -33,7 +33,6 @@ qnd_exit() {
. "${ROOT_DIR}/helper/binutil.inc"
. "${ROOT_DIR}/helper/system.inc"
-pinfo "System's packet manager is $PACKET_MANAGER"
banner () {
echo -e "\033[38;5;202m\t __ __ __ "
@@ -48,31 +47,33 @@ banner () {
print_usage() {
echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)"
- echo "Usage: $(basename ${SELF}) tools [-d] [-c [module]*] [-b [module]*] [-p profile]"
- echo " $(basename ${SELF}) core [-d] [-c] [-b] [-n]"
+ 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 " Target:"
- echo -e " core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)."
- echo -e " tools \t minimal systemd-based rootfs including basic tools (required for core)."
+ 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 <target_dir>"
echo -e ""
- echo -e " Target options:"
- echo -e " -b build target"
- echo -e " -c clean target"
+ 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 " -p profile build all modules from given profile"
- echo -e " -n don't generate squashfs for stage 3.2"
+ echo -e " -n don't generate squashfs from stage 3.2"
echo -e ""
- echo -e " For target 'tools', you can pass names of specific modules to clean/build."
+ 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 " tools -c -b base policykit sshd (clean all tools, build base, policykit and sshd)"
- echo -e " tools -c -b (clean all tools, build all tools)"
- echo -e " tools -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)"
- echo -e " tools -c -p default (clean all tools, build modules listed in profile default)"
- echo -e " core -c -b (clean and build core)"
+ 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 ""
- echo -e " Existing modules for tools are:"
+ echo -e " Existing modules for remote are:"
echo -e " $(echo $(ls ${ROOT_DIR}/remote/tools))"
}
@@ -83,12 +84,16 @@ initial_checks() {
else
banner
fi
+ # print system information
+ pinfo "Arch triplet of this machine: $ARCH_TRIPLET"
+ pinfo "Kernel version: $KERNEL_VERSION"
+ pinfo "System's packet manager is $PACKET_MANAGER"
# setup_tools and build_core
SETUP_CORE="${ROOT_DIR}/remote/setup_core"
SETUP_TOOLS="${ROOT_DIR}/remote/setup_tools"
- [ ! -e "${SETUP_CORE}" ] && perror "Missing script build_core, re-clone. Exiting."
+ [ ! -e "${SETUP_CORE}" ] && perror "Missing script setup_core, re-clone. Exiting."
[ ! -e "${SETUP_TOOLS}" ] && perror "Missing script setup_tools, re-clone. Exiting."
}
@@ -97,19 +102,30 @@ read_params() {
local SUBMODE=""
# select target: core or tools
case "$1" in
- core)
- MODE="CORE"
+ server)
+ MODE="SERVER"
;;
- tools)
- MODE="TOOLS"
+ remote)
+ MODE="REMOTE"
;;
*)
- pwarning "Unknown target: $1"
+ pwarning "Unknown mode: $1"
print_usage
exit 1
;;
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
+ fi
+
# handle rest of arguments
while [ "$#" -gt "0" ]; do
local PARAM="$1"
@@ -130,17 +146,17 @@ read_params() {
;;
-p)
[ "$#" -lt "1" ] && perror "Missing argument to -p"
- [ "$MODE" != "TOOLS" ] && perror "-p can only be used for target tools"
+ [ "$MODE" != "REMOTE" ] && perror "-p can only be used in remote mode"
. "remote/profiles/${1}.profile" || perror "Profile '$1' not found in remote/profiles/"
- TOOLS_BUILD="1"
- TOOLS_LIST_BUILD="$TOOLS_LIST_BUILD $MODULES"
+ REMOTE_BUILD="1"
+ REMOTE_LIST_BUILD="$REMOTE_LIST_BUILD $MODULES"
unset MODULES
shift
continue
;;
-n)
- [ "$MODE" != "CORE" ] && perror "-n can only be used for target core"
- CORE_NO_SQUASHFS="1"
+ [ "$MODE" != "SERVER" ] && perror "-n can only be used in server mode"
+ SERVER_NO_SQUASHFS="1"
continue
;;
*)
@@ -154,45 +170,40 @@ read_params() {
fi
# module name
- [[ $MODE != TOOLS ]] && pwarning "You cannot specify module names for target CORE." && print_usage && exit 1
- [[ $SUBMODE != CLEAN && $SUBMODE != BUILD ]] && pwarning "Module name given for --tools, but no action specified (eg. build)" && print_usage && exit 1
+ [[ $MODE != REMOTE ]] && pwarning "You cannot specify module names in server mode." && print_usage && exit 1
+ [[ $SUBMODE != CLEAN && $SUBMODE != BUILD ]] && pwarning "Module name given in remote mode, but no action specified (eg. build)" && print_usage && exit 1
eval "${MODE}_LIST_${SUBMODE}=\"\$${MODE}_LIST_${SUBMODE} \$PARAM\""
done
-
- #pinfo "tools clean: $TOOLS_CLEAN -$TOOLS_LIST_CLEAN"
- #pinfo "tools build: $TOOLS_BUILD -$TOOLS_LIST_BUILD"
- #pinfo "core clean: $CORE_CLEAN"
- #pinfo "core build: $CORE_BUILD"
-
+
# exit if no command
- [[ $CORE_CLEAN == 0 && $CORE_BUILD == 0 && $TOOLS_CLEAN == 0 && $TOOLS_BUILD == 0 ]] && print_usage && exit 1
+ [[ $SERVER_CLEAN == 0 && $SERVER_BUILD == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 ]] && print_usage && exit 1
}
run() {
- if [[ $TOOLS_CLEAN == 1 || $TOOLS_BUILD == 1 ]]; then
- [[ $TOOLS_DEBUG == 1 ]] && unset_quiet || set_quiet
+ if [[ $REMOTE_CLEAN == 1 || $REMOTE_BUILD == 1 ]]; then
+ [[ $REMOTE_DEBUG == 1 ]] && unset_quiet || set_quiet
. "${SETUP_TOOLS}" || perror "Cannot source ${SETUP_TOOLS}"
- [[ $TOOLS_CLEAN == 1 ]] && clean_tools $TOOLS_LIST_CLEAN
- [[ $TOOLS_BUILD == 1 ]] && generate_stage32 $TOOLS_LIST_BUILD
+ [[ $REMOTE_CLEAN == 1 ]] && clean_tools $REMOTE_LIST_CLEAN
+ [[ $REMOTE_BUILD == 1 ]] && generate_target $REMOTE_LIST_BUILD
fi
- if [[ $CORE_CLEAN == 1 || $CORE_BUILD == 1 ]]; then
- [[ $CORE_DEBUG == 1 ]] && unset_quiet || set_quiet
+ if [[ $SERVER_CLEAN == 1 || $SERVER_BUILD == 1 ]]; then
+ [[ $SERVER_DEBUG == 1 ]] && unset_quiet || set_quiet
local TOOL_STR="[CORE]"
. "${SETUP_CORE}" || perror "Cannot source ${SETUP_CORE}"
- [[ $CORE_CLEAN == 1 ]] && clean_core
- [[ $CORE_BUILD == 1 ]] && generate_stage31
+ [[ $SERVER_CLEAN == 1 ]] && clean_core
+ [[ $SERVER_BUILD == 1 ]] && generate_stage31
fi
}
-CORE_DEBUG="0"
-CORE_BUILD="0"
-CORE_CLEAN="0"
-CORE_NO_SQUASHFS="0"
-TOOLS_DEBUG="0"
-TOOLS_CLEAN="0"
-TOOLS_BUILD="0"
-TOOLS_LIST_CLEAN=""
-TOOLS_LIST_BUILD=""
+SERVER_DEBUG="0"
+SERVER_BUILD="0"
+SERVER_CLEAN="0"
+SERVER_NO_SQUASHFS="0"
+REMOTE_DEBUG="0"
+REMOTE_CLEAN="0"
+REMOTE_BUILD="0"
+REMOTE_LIST_CLEAN=""
+REMOTE_LIST_BUILD=""
initial_checks
read_params $@