summaryrefslogtreecommitdiffstats
path: root/mltk
diff options
context:
space:
mode:
authorSimon Rettberg2014-01-02 19:36:42 +0100
committerSimon Rettberg2014-01-02 19:36:42 +0100
commit61c9b1c97b1f5d07183987c2256637e523d1ff17 (patch)
tree5c5fa89bb09873edceae121c2222948083636972 /mltk
parent<setup_target> Add check for changed .build/.conf file of modules, autoclean ... (diff)
downloadtm-scripts-61c9b1c97b1f5d07183987c2256637e523d1ff17.tar.gz
tm-scripts-61c9b1c97b1f5d07183987c2256637e523d1ff17.tar.xz
tm-scripts-61c9b1c97b1f5d07183987c2256637e523d1ff17.zip
!! Split up 'mltk' into 'mltk' and 'openslx' !!
'mltk remote' is now 'mltk' 'mltk server' is now 'openslx' Also changed the export type (-e) stage31 to 'cpio' and stage32 and addons to 'sqfs' It should describe what it's packed as, not what the meaning of the content is; you can already tell from the file name.
Diffstat (limited to 'mltk')
-rwxr-xr-xmltk228
1 files changed, 82 insertions, 146 deletions
diff --git a/mltk b/mltk
index 753af701..ca736592 100755
--- a/mltk
+++ b/mltk
@@ -1,6 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------
-#
+#
# Copyright (c) 2011 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
@@ -11,12 +11,13 @@
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
-#
+#
# Mini-Linux Toolkit
-#
+#
# -----------------------------------------------------------------------------
-SELF="$(readlink -f $0)"
+ARG0="$0"
+SELF="$(readlink -f "$ARG0")"
ROOT_DIR="$(dirname "${SELF}")"
MLTK_PID="$$"
@@ -31,14 +32,24 @@ qnd_exit() {
exit 1
}
-# source all helper functions files that are found under helper/*.inc
-for HELPER in $ROOT_DIR/helper/*.inc; do
+# source all helper unit files that are found under helper/*.inc
+# these are general and used by "mltk" and "openslx"
+for HELPER in "$ROOT_DIR"/helper/*.inc; do
+ . "$HELPER" && continue
+ unset_quiet
+ echo "Could not source $HELPER"
+ qnd_exit
+done
+
+# source specific units only used by mltk
+for HELPER in "$ROOT_DIR"/remote/includes/*.inc; do
. "$HELPER" && continue
unset_quiet
echo "Could not source $HELPER"
qnd_exit
done
+
banner () {
echo -e "\033[38;5;202m\t __ __ __ "
echo -e "\033[38;5;202m\t.--------.| | | |_| |--."
@@ -47,63 +58,43 @@ banner () {
echo -e "\033[38;5;214m\t "
echo -e "\033[38;5;220m\t ** OpenSLX Project // 2013 **"
echo -e "\033[38;5;226m\t http://lab.openslx.org/"
- echo -e "\033[0m"
+ echo -e "\033[00m"
}
print_usage() {
echo -e ""
echo -e "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)"
- echo -e "Usage: $(basename ${SELF}) remote <target> [-d] [-c [module]*] [-b [module]*] [-p profile]"
- echo -e " $(basename ${SELF}) server <remotehost> [-s] [<target>] [-e stage31|stage32|addons] [-d] [-c]"
- echo -e ""
- echo -e " Mode:"
- 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 <target>"
+ #echo -e "Usage: $(basename ${SELF}) <target> [-d] [-c [module]*] [-b [module]*] [-p profile]"
+ echo -e "Usage: $ARG0 <target> [-d] [-c [module]*] [-b [module]*] [-n]"
echo -e ""
- echo -e " Global options (valid for all modes):"
- echo -e " -d activates debug output for the task"
- echo -e " "
- echo -e " Options for 'remote'-mode:"
+ echo -e " Options:"
+ echo -e " -d activates debug output for the task (spamy)"
echo -e " -b build module(s) and copy them to the target build directory"
- echo -e " -c clean build directory of module(s)."
- echo -e " -p profile build all modules from given profile (DEPRECATED?)"
- echo -e " -n bind mount all the local builds under remote/builds to /export/builds."
- echo -e " Allows for syncing from the server machine using the '-s'-flag."
- 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 " -c clean build directory of module(s) and target dir"
+ #echo -e " -p profile build all modules from given profile (DEPRECATED?)"
+ echo -e " -n bind mount all the local builds (remote/builds) to /export/builds"
echo -e ""
- echo -e " Options for 'server'-mode:"
- echo -e " -e type export target as 'type'. type can be of 'stage31' (simple initramfs), 'stage32' or 'addons' (both beeing squashfs)"
- echo -e " -s sync 'builds' directory of remote host"
- echo -e " -c clean target in remote_builds/ and corresponding files under boot/"
- echo -e ""
- echo -e "--------------------------------------------------------------------------------------------------------------------------------------"
+ echo -e " You can pass names of specific modules to clean/build (-c / -b)."
+ echo -e " Otherwise, all modules will be cleaned/built."
echo -e ""
echo -e " Examples:"
- echo -e " remote stage31 -c -b (clean all modules and build all linked modules in remote/targets/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 " remote -n (provides bind mount at /export/build for synchronizing)"
- echo -e " server 1.2.3.4 -s (sync all builds from remote system 1.2.3.4)"
- echo -e " server 1.2.3.4 stage32 -e stage32 (packs stage32 as squashfs from remote system 1.2.3.4)"
- echo -e " server 1.2.3.4 stage31 -c (clean stage31 build under server/remote_builds and initramfs under server/boot)"
- echo -e " server 1.2.3.4 addons-eexam -e addons (pack eexam-addons as squashfs)"
- echo -e " server 1.2.3.4 -k [configname] (generate config file configs/config.tgz)"
- 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 " $ARG0 stage31 -c -b"
+ echo -e " (clean and build all modules symlinked in remote/targets/stage31)"
+ echo -e " $ARG0 stage32 -c base sshd -b sshd ldm -d"
+ echo -e " (clean base and sshd, build sshd and ldm, be verbose)"
+ echo -e " $ARG0 -n"
+ echo -e " (provides bind mount at /export/build for synchronizing)"
echo -e ""
- echo -e " NOTE: Use 'local' as the remote host if you're running the server part on the same machine as the remote part."
+ echo -e " Existing targets are:"
+ echo -e " $(echo $(ls "${ROOT_DIR}/remote/targets" 2>/dev/null || echo "No targets for remote found."))"
echo -e ""
}
-
check_devtools() {
# Checking for needed development tools, compilers etc.
# Required: m4 make gcc g++ binutils
# no qmake here, qmake (libqt4-devel) should be installed in a module!
- local DEV_TOOLS="gcc c++ g++ make m4 strip git depmod patch mksquashfs pkg-config" # 'strip' as marker for binutils
+ local DEV_TOOLS="gcc g++ make m4 strip git depmod patch pkg-config" # 'strip' as marker for binutils
# DEV_CHECK marks missing dev-tools
local DEV_TOOLS_MISSING=""
@@ -116,19 +107,21 @@ check_devtools() {
pinfo "Missing tools are: $DEV_TOOLS_MISSING"
pinfo "For $SYS_DISTRIBUTION you probably need to run:"
case $SYS_DISTRIBUTION in
- ubuntu | debian) pinfo "apt-get install build-essential m4 squashfs-tools"
- pinfo "to install missing development tools."
- ;;
- # FIXME: Don't know how precise this filter works so we might want to have a better matching ...
- opensuse) pinfo "zypper install gcc gcc-c++ make m4 binutils git module-init-tools patch squashfs pkg-config"
- pinfo "to install missing development tools."
- ;;
- *) perror "Cannot determine SYS_DISTRIBUTION: $SYS_DISTRIBUTION unknown!"
- ;;
+ ubuntu | debian)
+ pinfo "apt-get install build-essential m4 squashfs-tools"
+ pinfo "to install missing development tools."
+ ;;
+ # FIXME: Don't know how precise this filter works so we might want to have a better matching ...
+ opensuse)
+ pinfo "zypper install gcc gcc-c++ make m4 binutils git module-init-tools patch squashfs pkg-config"
+ pinfo "to install missing development tools."
+ ;;
+ *)
+ perror "No installation help for $SYS_DISTRIBUTION available."
+ ;;
esac
perror "Please install missing dependencies (see above) and try again!"
-
- fi
+ fi
}
initial_checks() {
@@ -138,50 +131,40 @@ initial_checks() {
else
banner
fi
- pinfo "Arch triplet of this machine: $ARCH_TRIPLET"
+ pdebug "Arch triplet of this machine: $ARCH_TRIPLET"
- # source the 2 central scripts:
+ # source the central script:
# setup_target
# - builds all modules activated under the target directory
# (basic targets are 'stage31' and 'stage32')
- # export_target
- # - pack given target as a cpio or squashfs depending on
- # the export type:
- # stage31 (cpio archive of the complete stage31-filesystem)
- # stage32 (cpio archive containing the squashfs'ed stage32-filesystem)
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=""
- # mltk knows two modes in which to run:
- # - remote: functions to be run on the reference system
- # from which to build the mini-linux
- # - server: functions for rsyncing the generated stage31/stage32
- # to a server, exporting the stage31-/stage32-filesystems
case "$1" in
server)
- MODE="SERVER"
- [ "$#" -lt "2" ] && perror "Missing argument to server-mode flag 'server' (expecting remote host)"
- REMOTE_IP="$2"
- shift
+ pwarning " ** WARNING: mltk has been split up into 'mltk' and 'openslx'"
+ pwarning " ** mltk now only has the old 'mltk remote' functionality, while"
+ pwarning " ** openslx provides the 'mltk server' functionality. Please"
+ pwarning " ** use 'openslx' instead of 'mltk server'."
+ pwarning " ** Run 'mltk' or 'openslx' without any arguments for help."
+ if [ -x "./openslx" ]; then
+ pwarning " ** Calling 'openslx' in 5 seconds for compatibility...."
+ sleep 5
+ shift
+ exec ./openslx $@
+ fi
;;
remote)
- MODE="REMOTE"
- ;;
- *)
- pwarning "Unknown mode: $1"
- print_usage
- check_devtools
- exit 1
+ pwarning " ** Passing 'remote' as the first argument is not required"
+ pwarning " ** anymore. mltk now only provides the 'remote' functionality"
+ pwarning " ** while the 'server' functionality has been moved to 'openslx'."
+ shift
;;
esac
- shift
# A target represents a set of modules to be build for a specific stage.
# i.e. a very basic stage31 target should includes:
@@ -197,10 +180,10 @@ read_params() {
# - kdm
# - plymouth
TARGET=""
- if [[ $1 != "-"* ]]; then
- TARGET=$1
+ if [[ "$1" != -* ]]; then
+ TARGET="$1"
shift
- elif [[ $1 != "-s" && $1 != "-n" && $1 != "-k" ]]; then
+ elif [[ "$1" != "-n" ]]; then
perror "A target is required. None given."
fi
@@ -210,63 +193,30 @@ read_params() {
shift
# options to current target
- if [[ "$PARAM" == "-"* ]]; then
+ if [[ "$PARAM" == -* ]]; then
case "$PARAM" in
- -k)
- [ "$MODE" != "SERVER" ] && perror "-k can only be used in server mode"
- # NOTE: check for validity of config is done in 'inital_checks' of server/export_target
- SERVER_CONFIG_TYPE="$1"
- SERVER_CONFIG="1"
- shift
- continue
- ;;
- -s)
- SERVER_SYNC="1"
- continue
- ;;
-c)
SUBMODE="CLEAN"
;;
-b)
- [ "$MODE" != "REMOTE" ] && perror "-b can only be used in remote mode"
SUBMODE="BUILD"
;;
-d)
- eval ${MODE}_DEBUG="1"
+ REMOTE_DEBUG=1
continue
;;
- -p)
+ -p) # Profile mode - currently not supported
[ "$#" -lt "1" ] && perror "Missing argument to -p"
- [ "$MODE" != "REMOTE" ] && perror "-p can only be used in remote mode"
- . "remote/profiles/${1}.profile" || perror "Profile '$1' not found in remote/profiles/"
+ . "remote/profiles/${PARAM}.profile" || perror "Profile '$PARAM' not found in remote/profiles/"
REMOTE_BUILD="1"
REMOTE_LIST_BUILD="$REMOTE_LIST_BUILD $MODULES"
unset MODULES
shift
continue
;;
- -e)
- [ "$#" -lt "1" ] && perror "Missing argument to -e"
- #TODO: rework these types, since now we only have initramfs or squashfs. This makes a distinction between
- # stage32 and addons obsolete.
- [[ "stage31|stage32|addons" != *"$1"* ]] && perror "Wrong type specified. Muste be either 'stage31', 'stage32' or 'addons'"
- SERVER_EXPORT="1"
- SERVER_EXPORT_TYPE="$1"
- shift
- continue
- ;;
-n)
- if [ "$MODE" == "REMOTE" ]; then
- [ "x" != "x$1" ] && perror "'-n' accepts no parameters. Given: $1"
- REMOTE_EXPORT="1"
- fi
- continue
- ;;
- -a)
- if [ "$MODE" == "REMOTE" ]; then
- [ "x" != "x$1" ] && perror "'-a' accepts no parameters. Given: $1"
- REMOTE_AUTOMATIC_BUILD="1"
- fi
+ [ "x" != "x$1" ] && perror "'-n' accepts no parameters. Given: $1"
+ REMOTE_EXPORT="1"
continue
;;
*)
@@ -275,19 +225,17 @@ read_params() {
exit 1
;;
esac
- eval ${MODE}_${SUBMODE}="1"
+ eval REMOTE_${SUBMODE}=1
continue
fi
# module name
- [[ $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\""
+ [[ "$SUBMODE" != "CLEAN" && "$SUBMODE" != "BUILD" ]] && pwarning "Module name given, but no action specified (eg. build)" && print_usage && exit 1
+ eval "REMOTE_LIST_${SUBMODE}=\"\$REMOTE_LIST_${SUBMODE} \$PARAM\""
done
-
+
# exit if no command
-
- [[ $SERVER_CLEAN == 0 && $SERVER_EXPORT == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 && $SERVER_SYNC == 0 && $REMOTE_EXPORT == 0 && $SERVER_CONFIG == 0 ]] && print_usage && exit 1
+ [[ "$REMOTE_CLEAN" == 0 && "$REMOTE_BUILD" == 0 && "$REMOTE_EXPORT" == 0 ]] && print_usage && exit 1
}
run() {
@@ -298,22 +246,8 @@ run() {
[[ $REMOTE_BUILD == 1 ]] && generate_target $TARGET $REMOTE_LIST_BUILD
[[ $REMOTE_EXPORT == 1 ]] && export_builds
fi
- if [[ $SERVER_CLEAN == 1 || $SERVER_EXPORT == 1 || $SERVER_SYNC == 1 || $SERVER_CONFIG == 1 ]]; then
- [[ $SERVER_DEBUG == 1 ]] && unset_quiet || set_quiet
- . "${SERVER_EXPORT_TARGET}" || perror "Cannot source ${SERVER_EXPORT_TARGET}"
- [[ $SERVER_SYNC == 1 ]] && sync_remote
- [[ $SERVER_CLEAN == 1 ]] && clean_target $TARGET
- [[ $SERVER_EXPORT == 1 ]] && export_target $TARGET $SERVER_EXPORT_TYPE
- [[ $SERVER_CONFIG == 1 ]] && generate_config $SERVER_CONFIG_TYPE
- fi
}
-SERVER_DEBUG="0"
-SERVER_EXPORT="0"
-SERVER_CLEAN="0"
-SERVER_EXPORT_TYPE=""
-SERVER_SYNC="0"
-SERVER_CONFIG="0"
REMOTE_DEBUG="0"
REMOTE_CLEAN="0"
REMOTE_BUILD="0"
@@ -327,3 +261,5 @@ read_params $@
check_devtools
run
+exit 0
+