diff options
author | Michael Neves | 2013-03-20 15:22:51 +0100 |
---|---|---|
committer | sr | 2013-04-12 19:11:30 +0200 |
commit | 97b4ba82596ae5484079483afeaba7986958ecab (patch) | |
tree | f85896acc369038481d6a3338561258a6683ea69 /helper/fileutil.inc | |
parent | use default location for aufs.ko (diff) | |
download | tm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.tar.gz tm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.tar.xz tm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.zip |
KERNEL_VERSION from system.inc
gitignore and calc_size in fileutil calculates the build size of a module
fix generate_target argument parsing
add xfs to rootfs-stage31.conf
added server sync option -s
- Fix sshd module failing to set permissions on sshd config
- Add all required packages for openSUSE to xorg module
- Softlink sh to bash in rootfs-stage32, as some scripts might fail otherwise
Thanks hwinfo but we don't need you anymore
Added size log
fix list_packet_files exiting loop when a packet wasnt installed
remove flag checks, now done in setup_target
check if kernel module is already built-in
Diffstat (limited to 'helper/fileutil.inc')
-rw-r--r--[-rwxr-xr-x] | helper/fileutil.inc | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc index d39fbe87..07dab7af 100755..100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -24,7 +24,8 @@ tarcopy () { [ ${#SHORT} -gt 30 ] && SHORT=$(echo "$SHORT" | sed ':a;N;$!ba;s/\n/ /g' | cut -c-25)...$(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" + # TODO count files copied? would remove the need to do it everywhere :) + tar -cpP $FROM | tar -xp -C "$TO" 2> /dev/null local PS=(${PIPESTATUS[*]}) [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})" [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})" @@ -45,8 +46,8 @@ 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" ] && pwarning "dpkg/rpm exited with code '$LPRET' for packet ${PACKAGE}." && return 1 - [ -z "$FILES" ] && pwarning "list_packet_files empty for packet ${PACKAGE}." + [ "x$LPRET" != "x0" ] && pwarning "dpkg/rpm exited with code '$LPRET' for packet ${PACKAGE}." && continue + [ -z "$FILES" ] && pwarning "list_packet_files empty for packet ${PACKAGE}." && continue for FILE in $FILES; do [ ! -d "$FILE" ] && echo "$FILE" done @@ -56,8 +57,10 @@ list_packet_files() { # install all dependencies of a module # goes through all package as given in the variable REQUIRED_DEPENDENCIES install_dependencies() { - [ -z "$REQUIRED_DEPENDENCIES" ] && return + [ -z "$REQUIRED_DEPENDENCIES" ] && return if [ "$PACKET_MANAGER" = "apt" ]; then + # install package, only if not already installed + dpkg -l $(echo $(echo "$REQUIRED_DEPENDENCIES")) &> /dev/null && return apt-get install -y $REQUIRED_DEPENDENCIES || perror "Could not apt-get install $REQUIRED_DEPENDENCIES" elif [ "$PACKET_MANAGER" = "zypper" ]; then zypper --no-refresh install -y -n $REQUIRED_DEPENDENCIES || perror "Could not zypper install $REQUIRED_DEPENDENCIES" @@ -68,11 +71,30 @@ install_dependencies() { # 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}" + cp -r "${MODULE_DIR}/data/"* ${TARGET_BUILD_DIR} || perror "Could not copy static data of ${MODULE}" } +calc_size() { + + local CURRENT_BUILD_SIZE=$(du -bc "${TARGET_BUILD_DIR}" | awk 'END {print $1}') + + [ ! -z "${BUILD_SIZE[$MODULE]}" ] && local OLD_MODULE_SIZE=${BUILD_SIZE[$MODULE]} || local OLD_MODULE_SIZE=0 + local diff=$((CURRENT_BUILD_SIZE-TARGET_BUILD_SIZE+OLD_MODULE_SIZE)) + + if [ -z "${BUILD_SIZE[$MODULE]}" ]; then + echo "BUILD_SIZE[$MODULE]=${diff}" >> "${ROOT_DIR}/logs/${TARGET}.size" + else + sed -i "s/^BUILD_SIZE\[${MODULE}\]=.*$/BUILD_SIZE\[${MODULE}\]=${diff}/g" "${ROOT_DIR}/logs/${TARGET}.size" + fi + + MODULE_BUILD_SIZE=$(echo $diff | awk '{ sum=$1; hum[1024^3]="GB"; hum[1024^2]="MB"; hum[1024]="KB"; + for (x=1024^3; x>=1024; x/=1024){ + if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break } + } + }') + TARGET_BUILD_SIZE=$CURRENT_BUILD_SIZE +} -###################################################################################################################### # # generate initramfs of directory # usage: @@ -80,7 +102,6 @@ copy_static_data() { # 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'" @@ -90,7 +111,7 @@ generate_initramfs() { [ "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 - + cd - &> /dev/null pinfo "Created initramfs of $1 at $3" } |