summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Rettberg2014-01-02 19:36:42 +0100
committerSimon Rettberg2014-01-02 19:36:42 +0100
commit61c9b1c97b1f5d07183987c2256637e523d1ff17 (patch)
tree5c5fa89bb09873edceae121c2222948083636972 /server
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 'server')
-rwxr-xr-xserver/export_target44
-rw-r--r--server/includes/packing.inc35
2 files changed, 49 insertions, 30 deletions
diff --git a/server/export_target b/server/export_target
index 906c5cdc..c5fae7f4 100755
--- a/server/export_target
+++ b/server/export_target
@@ -39,7 +39,7 @@ copy_kernel() {
pinfo "Copying kernel from ${REMOTE_IP} to ${SERVER_BOOT_DIR}/kernel/"
if [ -d ${SERVER_BUILD_DIR}/kernel ]; then
cd ${SERVER_BUILD_DIR}
- tarcopy kernel ${SERVER_BOOT_DIR}
+ tarcopy "kernel" "${SERVER_BOOT_DIR}"
cd - &> /dev/null
fi
}
@@ -59,27 +59,6 @@ sync_remote() {
fi
}
-generate_stage32() {
- local TOOL_STR="${TOOL_STR} generate_stage32:"
- rm -f "${SERVER_BOOT_DIR}/${TARGET}.sqfs"
- pinfo "Writing '${TARGET}.sqfs' to '${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 ($?)."
- pinfo "Created '${SERVER_BOOT_DIR}/${TARGET}.sqfs'."
-}
-
-generate_stage31() {
- local TOOL_STR="${TOOL_STR} generate_stage31:"
- pinfo "Writing 'initramfs-${TARGET}' 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 ($?)."
-}
-
generate_config() {
# generate config from the target directory
local TOOL_STR="${TOOL_STR} generate_config:"
@@ -159,19 +138,24 @@ export_target() {
copy_kernel
TARGET=$1
- [ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}"
+ [ -z "$TARGET" ] && perror "No target passed to export_target()"
+ [ -d "${SERVER_BUILD_DIR}/${TARGET}" ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}"
case "$2" in
- stage31)
- generate_stage31
+ cpio)
+ local TOOL_STR="${TOOL_STR} generate_initramfs:"
+ pinfo "Writing 'initramfs-${TARGET}' to '${SERVER_BOOT_DIR}/'"
+ generate_initramfs "${SERVER_BUILD_DIR}/${TARGET}/" "." "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
;;
- stage32)
- generate_stage32
+ sqfs)
+ local TOOL_STR="${TOOL_STR} generate_squashfs:"
+ pinfo "Creating '${TARGET}.sqfs' in '${SERVER_BOOT_DIR}/'"
+ generate_squashfs "${SERVER_BUILD_DIR}/${TARGET}/" "${SERVER_BOOT_DIR}/${TARGET}.sqfs"
;;
- addons)
- generate_addons
+ *)
+ perror "Invalid export format: $2"
;;
- esac
+ esac
}
diff --git a/server/includes/packing.inc b/server/includes/packing.inc
new file mode 100644
index 00000000..84b47262
--- /dev/null
+++ b/server/includes/packing.inc
@@ -0,0 +1,35 @@
+
+#
+# generate initramfs of directory
+# usage:
+# 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 3 ] && perror "Sanity check failed: generate_initramfs needs exactly two params, but $# were given."
+ cd "$1" || perror "Cannot cd to '$1'"
+ rm -f -- "$3"
+
+ find $2 | cpio --format="newc" --create | gzip -9 > "$3"
+ local PS=(${PIPESTATUS[*]})
+ [ "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 '$3' failed."
+ cd - > /dev/null
+ pinfo "Created initramfs of $1 at $3"
+ pinfo "Size: $(du -bsh "$3" | awk 'END {print $1}')"
+}
+
+# generates squashfs of directory
+# usage:
+# 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 "$1" ] || perror "$1 is not a directory."
+ mksquashfs "$1" "$2" -comp xz -b 1M -no-recovery >&6 \
+ || perror "mksquashfs failed ($?)."
+ pinfo "Created squashfs of $1 at $2"
+ pinfo "Size: $(du -bsh "$2" | awk 'END {print $1}')"
+}
+