summaryrefslogtreecommitdiffstats
path: root/helper/fileutil.inc
diff options
context:
space:
mode:
authorroot2013-02-27 22:19:53 +0100
committerroot2013-02-27 22:19:53 +0100
commit83dcd2b34cefd5b324b5a4f54be141a858dc5238 (patch)
treed0b5db5602029646fe4af2e22891bed813406258 /helper/fileutil.inc
parenttihi (diff)
downloadtm-scripts-83dcd2b34cefd5b324b5a4f54be141a858dc5238.tar.gz
tm-scripts-83dcd2b34cefd5b324b5a4f54be141a858dc5238.tar.xz
tm-scripts-83dcd2b34cefd5b324b5a4f54be141a858dc5238.zip
Generalization:
- Rework install_dependencies: make it a global function, not per tools.build - Determine packet manager of local system (currently supports apt/dpkg and zypper/rpm) - Look for packet manager specific tools.conf.$MANAGER first, use tools.conf otherwise - Added list_package_files which should be used instead of "for $(dpkg -L | grep ...) ... >> ... done"
Diffstat (limited to 'helper/fileutil.inc')
-rw-r--r--helper/fileutil.inc46
1 files changed, 46 insertions, 0 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index 3e1ea56a..e3a79b4a 100644
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -1,3 +1,16 @@
+# one time jobs
+
+# determine packet manager:
+if [ ! -z "$(which apt-get)" ]; then
+ PACKET_MANAGER="apt"
+elif [ ! -z "$(which zypper)" ]; then
+ PACKET_MANAGER="zypper"
+else
+ perror "Could not determine this platform's packet manager"
+fi
+
+#
+
# copy list of files using tar
tarcopy () {
[ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given."
@@ -16,3 +29,36 @@ tarcopy () {
[ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})"
}
+# get all files of required packages by a module
+list_packet_files() {
+ [ -z "$REQUIRED_PACKAGES" ] && return
+ for PACKAGE in $REQUIRED_PACKAGES; do
+ local FILES=""
+ if [ "$PACKET_MANAGER" = "apt" ]; then
+ FILES="$(dpkg -L "$PACKAGE" | grep -v share/doc | grep -v share/man; echo ":###:${PIPESTATUS[0]}")"
+ elif [ "$PACKET_MANAGER" = "zypper" ]; then
+ FILES="$(rpm -ql "$PACKAGE" | grep -v share/doc | grep -v share/man; echo ":###:${PIPESTATUS[0]}")"
+ fi
+ # ugly hack to get our return value
+ #local LPRET=$(echo "$FILES" | tail -1 | sed 's/^.*:###:\([0-9]*\)$/\1/g')
+ #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}."
+ for FILE in $FILES; do
+ [ ! -d "$FILE" ] && echo "$FILE"
+ done
+ done
+}
+
+# install all dependencies of a module
+install_dependencies() {
+ [ -z "$REQUIRED_DEPENDENCIES" ] && return
+ if [ "$PACKET_MANAGER" = "apt" ]; then
+ apt-get install -y $REQUIRED_DEPENDENCIES || perror "Could not apt-get install $REQUIRED_DEPENDENCIES"
+ elif [ "$PACKET_MANAGER" = "zypper" ]; then
+ zypper install -y $REQUIRED_DEPENDENCIES || perror "Could not zypper install $REQUIRED_DEPENDENCIES"
+ fi
+}
+