summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk2013-03-19 18:37:28 +0100
committerDirk2013-03-19 18:37:28 +0100
commit55551dba0187ae1e5d36215109ed8d247756e848 (patch)
tree4daf9bd5430255c7bcb739ff9006f167d2fcf966
parentStuff to activate swap ... (diff)
parentMerge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff)
downloadtm-scripts-55551dba0187ae1e5d36215109ed8d247756e848.tar.gz
tm-scripts-55551dba0187ae1e5d36215109ed8d247756e848.tar.xz
tm-scripts-55551dba0187ae1e5d36215109ed8d247756e848.zip
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
...
-rwxr-xr-x[-rw-r--r--]helper/fileutil.inc28
-rwxr-xr-xmltk97
-rw-r--r--remote/modules/sshd/sshd.build4
-rwxr-xr-xremote/setup_target40
-rwxr-xr-xserver/build_core71
-rwxr-xr-xserver/export_target108
6 files changed, 213 insertions, 135 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index 6b3ea77f..ea8b7899 100644..100755
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -76,27 +76,31 @@ copy_static_data() {
#
# generate initramfs of directory
# usage:
-# generate_initramfs <target_filename> <source_dir>
-#
+# generate_initramfs <source_dir> <files> <destination_dir/filename>
+# example:
+# generate_initramfs "./server/boot/stage32_sqfs" "./mnt/openslx.sqfs" "./server/boot/initramfs2"
+# generate_initramfs "./server/build/stage31" "." "./server/boot/initramfs"
+
generate_initramfs() {
- [ $# -ne 2 ] && perror "Sanity check failed: generate_initramfs needs exactly two params, but $# were given."
- cd "$2" || perror "Cannot cd to '$2'"
- find . | cpio --format="newc" --create | gzip -9 > "${MODULE_DIR}/$1"
+ [ $# -ne 3 ] && perror "Sanity check failed: generate_initramfs needs exactly two params, but $# were given."
+ cd "$1" || perror "Cannot cd to '$1'"
+
+ find $2 | cpio --format="newc" --create | gzip -9 > "$3"
local PS=(${PIPESTATUS[*]})
- [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
+ [ "x${PS[0]}" != "x0" ] && perror "'find $2' in '$(pwd)' failed."
[ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
- [ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/$1' failed."
+ [ "x${PS[2]}" != "x0" ] && perror "gzip to '$3' failed."
cd -
- pinfo "Created initramfs of $2 at ${MODULE_DIR}/$1"
+ pinfo "Created initramfs of $1 at $3"
}
# generates squashfs of directory
# usage:
-# generate_squashfs <target_filename> <source_dir>
+# generate_squashfs <source_dir> <destination_dir/filename>
generate_squashfs() {
[ $# -ne 2 ] && perror "Sanity check failed: generate_squashfs needs exactly two params, but $# were given."
- [ -d $2 ] || perror "$2 is not a directory."
- mksquashfs "$2" "${MODULE_DIR}/$1" -comp xz -b 1M -no-recovery >&6 \
+ [ -d "$1" ] || perror "$1 is not a directory."
+ mksquashfs "$1" "$2" -comp xz -b 1M -no-recovery >&6 \
|| perror "mksquashfs failed ($?)."
- pinfo "Created squashfs of $2 at ${MODULE_DIR}/$1"
+ pinfo "Created squashfs of $1 at $2"
}
diff --git a/mltk b/mltk
index f5d72906..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 <target> [-d] [-c [module]*] [-b [module]*] [-p profile]"
+ echo -e " $(basename ${SELF}) server <target> [-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 <target_dir>"
+ 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 ""
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/modules))"
}
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"
diff --git a/remote/modules/sshd/sshd.build b/remote/modules/sshd/sshd.build
index aa4241e6..0b198c6c 100644
--- a/remote/modules/sshd/sshd.build
+++ b/remote/modules/sshd/sshd.build
@@ -13,6 +13,8 @@ build() {
fi
}
-post_copy() {
+post_copy() {
mkdir -p "${TARGET_BUILD_DIR}/var/run/sshd"
+
+ chmod go-rwx "${TARGET_BUILD_DIR}/etc/ssh/*"
}
diff --git a/remote/setup_target b/remote/setup_target
index eed033fe..e7370b1b 100755
--- a/remote/setup_target
+++ b/remote/setup_target
@@ -3,23 +3,37 @@
MODE_DIR="${ROOT_DIR}/remote"
MODULES_DIR="${MODE_DIR}/modules"
-# check for target directory
-TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
-[ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET"
-TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+KERNEL_DIR="${MODE_DIR}/builds/kernel"
# Keep track of processed modules
PROCESSED_MODULES=""
initial_checks () {
+
# check for required tools
for BIN in git locate depmod
do
local TEST=$(which ${BIN})
[ -z "$TEST" ] && pinfo "Installing $BIN..." && apt-get install $BIN
done
+
}
+copy_kernel() {
+
+ local KERNEL_VER="vmlinuz-$(uname -r)"
+ [ -e "${KERNEL_DIR}/${KERNEL_VER}" ] && return
+
+ local TOOL_STR="$TOOL_STR copy_kernel:"
+
+ [ ! -d "${KERNEL_DIR}" ] && mkdir -p ${KERNEL_DIR}
+
+ pinfo "New kernel found. Copying '${KERNEL_VER}' to '${KERNEL_DIR}'."
+ pinfo "You may want to update your systems firmware/modules to match the current kernel."
+
+ cp "/boot/${KERNEL_VER}" "${KERNEL_DIR}" || perror "Cannot copy kernel from '/boot/${KERNEL_VER}' to '${KERNEL_DIR}'"
+
+}
read_config () {
@@ -134,14 +148,20 @@ copy_files_with_deps () {
generate_target() {
initial_checks
+ copy_kernel
+
+ TARGET=$1
+ TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
+ TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+ [ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET_DIR"
[[ $TARGET == builds || $TARGET == modules ]] && \
perror "Target directory cannot be named 'builds' nor 'modules'."
-
+
pinfo "Generating '$TARGET_BUILD_DIR' for '$TARGET'"
# if no arguments assume all.
- if [ "x$1" = "x" -o "x$1" = "xall" ]; then
+ if [ "x$2" = "x" -o "x$2" = "xall" ]; then
MODULES=$(ls ${TARGET_DIR})
set -- $MODULES
else
@@ -221,7 +241,13 @@ process_module() {
}
clean_modules() {
- if [ "x$1" = "x" -o "x$1" = "xall" ]; then
+
+ TARGET=$1
+ TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
+ TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+ [ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET_DIR"
+
+ if [ "x$2" = "x" -o "x$2" = "xall" ]; then
if [ -d ${TARGET_BUILD_DIR} ]; then
pinfo "Cleaning '${TARGET_BUILD_DIR}'" \
&& rm -rf "${TARGET_BUILD_DIR}"/* \
diff --git a/server/build_core b/server/build_core
deleted file mode 100755
index cf748428..00000000
--- a/server/build_core
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2012 - OpenSLX GmbH
-#
-# This program is free software distributed under the GPL version 2.
-# See http://openslx.org/COPYING
-#
-# If you have any feedback please consult http://openslx.org/feedback and
-# send your feedback to feedback@openslx.org
-#
-# General information about OpenSLX can be found at http://openslx.org
-#
-# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux
-# stateless clients
-#############################################################################
-
-# first parameter is a hash pointing to the target directory
-# /srv/openslx/build
-
-# in the future the prefix should be set via slxsettings ...
-
-MODULE_DIR=${ROOT_DIR}/server
-
-STAGE31_DIR=${ROOT_DIR}/remote/stage3.1
-STAGE32_DIR=${ROOT_DIR}/remote/stage3.2
-
-# initial checks
-initial_checks() {
- local TOOL_STR="$TOOL_STR initial_checks:"
- [ -d "${STAGE31_DIR}" ] || perror "No stage3.1 directory found. Please run './mltk core -b' first."
- [ -d "${STAGE32_DIR}" ] || perror "No stage3.2 directory found. Please run './mltk tools -b' first."
-
- [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
-}
-
-generate_squashfs() {
- [[ $CORE_NO_SQUASHFS == 1 ]] && return
- local TOOL_STR="$TOOL_STR generate_squashfs:"
- [ -e "${MODULE_DIR}/openslx/mnt/openslx.sqfs" ] && rm "${MODULE_DIR}/openslx/mnt/openslx.sqfs"
- pinfo "Writing openslx.sqfs to '${MODULE_DIR}/openslx/mnt/'"
- mksquashfs "${STAGE32_DIR}" "${MODULE_DIR}/openslx/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
- generate_initramfs "initramfs2" "${MODULE_DIR}/openslx"
-}
-
-generate_stage31() {
- initial_checks
- generate_rootfs
- generate_squashfs
-
- if [ ! -e ${MODULE_DIR}/kernel ]; then
- local TOOL_STR="$TOOL_STR copy_kernel:"
- pinfo "Copying Kernel $(uname -r) to ${MODULE_DIR}/kernel"
- cp "/boot/vmlinuz-$(uname -r)" "${MODULE_DIR}/kernel" || perror "Cannot copy kernel from '/boot/vmlinuz-$(uname -r)' to '${MODULE_DIR}/kernel'"
- else
- pinfo "Not copying kernel from system, as it already exists."
- fi
-}
-
-clean_core() {
- local TOOL_STR="$TOOL_STR clean_core:"
- pinfo "Cleaning '${STAGE31_DIR}'..."
- [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed."; }
- pinfo "Cleaning '${MODULE_DIR}/kernel'..."
- [ -e ${MODULE_DIR}/kernel ] && { rm ${MODULE_DIR}/kernel || perror "rm failed."; }
- pinfo "Cleaning '${MODULE_DIR}/initramfs'..."
- [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed."; }
- pinfo "Cleaning '${MODULE_DIR}/openslx'..."
- [ -d ${MODULE_DIR}/openslx ] && { rm -rf ${MODULE_DIR}/openslx || perror "rm failed."; }
- pinfo "Cleaning '${MODULE_DIR}/initramfs2'..."
- [ -d ${MODULE_DIR}/initramfs2 ] && { rm ${MODULE_DIR}/initramfs2 || perror "rm failed."; }
-}
-
diff --git a/server/export_target b/server/export_target
new file mode 100755
index 00000000..cb55a55f
--- /dev/null
+++ b/server/export_target
@@ -0,0 +1,108 @@
+#!/bin/bash
+# Copyright (c) 2012 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux
+# stateless clients
+#############################################################################
+
+#where we are
+MODE_DIR="${ROOT_DIR}/server"
+
+#files generated by this script land in boot
+SERVER_BOOT_DIR="${MODE_DIR}/boot"
+
+#builds from remote server
+SERVER_BUILD_DIR="${MODE_DIR}/remote_builds"
+REMOTE_BUILD_DIR="${ROOT_DIR}/remote/builds"
+
+#stage32 sqfs directory
+STAGE32_SQFS_DIR="${SERVER_BOOT_DIR}/stage32_sqfs/mnt"
+
+# initial checks
+initial_checks() {
+
+ local TOOL_STR="$TOOL_STR initial_checks:"
+
+ #check for required tools
+ for BIN in squashfs-tools
+ do
+ local TEST=$(which ${BIN})
+ [ -z "${TEST}" ] && pinfo "Installing ${BIN}..." && apt-get install ${BIN}
+ done
+
+ #setup link to remote build directory, later this directory will be rsynced or exported to this server...
+ if [ ! -d "${SERVER_BUILD_DIR}" ]; then
+ [ ! -d "${REMOTE_BUILD_DIR}" ] && perror "remote 'builds' directory not foud, exiting."
+ ln -s "${REMOTE_BUILD_DIR}" "${SERVER_BUILD_DIR}"
+ fi
+
+ [ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}"
+}
+
+generate_stage32() {
+ local TOOL_STR="${TOOL_STR} generate_stage32:"
+ [ ! -d "${STAGE32_SQFS_DIR}" ] && mkdir -p "${STAGE32_SQFS_DIR}"
+ [ -e "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${TARGET}.sqfs"
+ pinfo "Writing '${TARGET}.sqfs' to '${STAGE32_SQFS_DIR}/${TARGET}.sqfs'"
+ mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
+ generate_initramfs "${SERVER_BOOT_DIR}/stage32_sqfs" "./mnt/${TARGET}.sqfs" "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
+}
+
+generate_stage31() {
+ local TOOL_STR="${TOOL_STR} generate_stage31:"
+ pinfo "Writing 'initramfs-${BUILD}' to '${SERVER_BOOT_DIR}'"
+ generate_initramfs "${SERVER_BUILD_DIR}/${TARGET}" "." "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
+}
+
+generate_addons() {
+ local TOOL_STR="${TOOL_STR} generate_addons:"
+ pinfo "Writing '${TARGET}.sqfs' to '${SERVER_BOOT_DIR}/${TARGET}.sqfs'"
+ [ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs"
+ mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${SERVER_BOOT_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
+}
+
+export_target() {
+
+initial_checks
+
+TARGET=$1
+[ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}"
+
+case "$2" in
+ stage31)
+ generate_stage31
+ ;;
+ stage32)
+ generate_stage32
+ ;;
+ addons)
+ generate_addons
+ ;;
+esac
+
+}
+
+clean_target() {
+ TARGET=$1
+
+ local TOOL_STR="$TOOL_STR clean_target"
+ pinfo "Cleaning '${SERVER_BUILD_DIR}/${TARGET}'..."
+ [ -d "${SERVER_BUILD_DIR}/${TARGET}" ] && { rm -rf "${SERVER_BUILD_DIR}/${TARGET}" || perror "rm -rf failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/kernel'..."
+ [ -e "${SERVER_BOOT_DIR}/kernel" ] && { rm "${SERVER_BOOT_DIR}/kernel" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/initramfs-${TARGET}'..."
+ [ -e "${SERVER_BOOT_DIR}/initramfs-${TARGET}" ] && { rm "${SERVER_BOOT_DIR}/initramfs-${TARGET}" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/${TARGET}.sqfs'..."
+ [ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs'..."
+ [ -e "${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs" || perror "rm failed."; }
+}
+