summaryrefslogtreecommitdiffstats
path: root/helper/fileutil.inc
diff options
context:
space:
mode:
authorroot2013-03-19 15:28:56 +0100
committerroot2013-03-19 15:28:56 +0100
commitcc112cd5c1b75403fa99357f981a5471784f5ab4 (patch)
treec61196354a0112720b0181ae2b0cd9fb1736605e /helper/fileutil.inc
parentopenSUSE non-interactive zypper (diff)
parentbinutil: add libs to blacklist, speeds up by a LOT (thanks michi:)) (diff)
downloadtm-scripts-cc112cd5c1b75403fa99357f981a5471784f5ab4.tar.gz
tm-scripts-cc112cd5c1b75403fa99357f981a5471784f5ab4.tar.xz
tm-scripts-cc112cd5c1b75403fa99357f981a5471784f5ab4.zip
Merge branch 'master' of ssh://openslx/openslx-ng/tm-scripts
Diffstat (limited to 'helper/fileutil.inc')
-rw-r--r--helper/fileutil.inc46
1 files changed, 42 insertions, 4 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index 63173258..19c9dd93 100644
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -23,6 +23,7 @@ tarcopy () {
local SHORT=$FROM
[ ${#SHORT} -gt 23 ] && SHORT=$(echo "$SHORT" | cut -c-18)...$(echo "$SHORT" | cut -c$[${#SHORT} - 4]-)
[ -z "$TO" ] && perror "tarcopy called with empty destination."
+ [ ! -d "$TO" ] && { mkdir -p "$TO" || perror "could not create destination "$TO" for tar-copy."; }
tar -cp $FROM | tar -xp -C "$TO"
local PS=(${PIPESTATUS[*]})
[ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})"
@@ -31,7 +32,7 @@ tarcopy () {
# get all files of required packages by a module
list_packet_files() {
- [ -z "$REQUIRED_PACKAGES" ] && return
+ [ -z "$REQUIRED_PACKAGES" ] && pinfo "No required packages for $TOOL" && return 1
for PACKAGE in $REQUIRED_PACKAGES; do
local FILES=""
if [ "$PACKET_MANAGER" = "apt" ]; then
@@ -44,15 +45,16 @@ list_packet_files() {
#FILES=$(echo "$FILES" | sed 's/^\(.*\):###:[0-9]*$/\1/g')
local LPRET=$(echo "$FILES" | awk -F ':###:' '{printf $2}')
FILES=$(echo "$FILES" | awk -F ':###:' '{print $1}')
- [ "x$LPRET" != "x0" ] && perror "list_packet_files exited with code '$LPRET' for packet ${PACKAGE}."
- [ -z "$FILES" ] && perror "list_packet_files empty for packet ${PACKAGE}."
+ [ "x$LPRET" != "x0" ] && pwarning "dpkg/rpm exited with code '$LPRET' for packet ${PACKAGE}."
+ [ -z "$FILES" ] && pwarning "list_packet_files empty for packet ${PACKAGE}."
for FILE in $FILES; do
[ ! -d "$FILE" ] && echo "$FILE"
done
done
}
-
+#
# install all dependencies of a module
+# goes through all package as given in the variable REQUIRED_DEPENDENCIES
install_dependencies() {
[ -z "$REQUIRED_DEPENDENCIES" ] && return
if [ "$PACKET_MANAGER" = "apt" ]; then
@@ -61,4 +63,40 @@ install_dependencies() {
zypper install -n $REQUIRED_DEPENDENCIES || perror "Could not zypper install $REQUIRED_DEPENDENCIES"
fi
}
+#
+# copies static data files from <MODULE>/data/ to <TARGET_BUILD_DIR>
+#
+copy_static_data() {
+ [ ! -d "${MODULE_DIR}/data" ] && pinfo "${MODULE} has no static 'data' directory." && return
+ cp -r ${MODULE_DIR}/data/* ${TARGET_BUILD_DIR} || perror "Could not copy static data of ${MODULE}"
+}
+
+######################################################################################################################
+#
+# generate initramfs of directory
+# usage:
+# generate_initramfs <target_filename> <source_dir>
+#
+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"
+ local PS=(${PIPESTATUS[*]})
+ [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
+ [ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
+ [ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/$1' failed."
+ cd -
+ pinfo "Created initramfs of $2 at ${MODULE_DIR}/$1"
+}
+
+# generates squashfs of directory
+# usage:
+# generate_squashfs <target_filename> <source_dir>
+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 \
+ || perror "mksquashfs failed ($?)."
+ pinfo "Created squashfs of $2 at ${MODULE_DIR}/$1"
+}