summaryrefslogtreecommitdiffstats
path: root/helper
diff options
context:
space:
mode:
authorJonathan Bauer2013-07-11 15:26:48 +0200
committerJonathan Bauer2013-07-11 15:26:48 +0200
commitc6086513734e8ee6072e2beadbd169148309e3ab (patch)
tree449004c107f491a7fbb0fa0873641c4fecba09b5 /helper
parent[pam] fix location of pam_script.so on suse 64biot (diff)
downloadtm-scripts-c6086513734e8ee6072e2beadbd169148309e3ab.tar.gz
tm-scripts-c6086513734e8ee6072e2beadbd169148309e3ab.tar.xz
tm-scripts-c6086513734e8ee6072e2beadbd169148309e3ab.zip
[fileutil.inc] improve install_packages function to check whether packages are already installed before trying to install them (should speed up the whole thing). Additionally it now outputs the list of installed packages. This could be saved in some log to review which packages where installed during the building process
Diffstat (limited to 'helper')
-rw-r--r--helper/fileutil.inc59
1 files changed, 50 insertions, 9 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index 4b9a2b4d..192758ff 100644
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -71,6 +71,8 @@ list_packet_files() {
done
}
#
+# Conveniance function
+#
# install all dependencies of a module
# goes through all package as given in the variable REQUIRED_INSTALLED_PACKAGES
install_dependencies() {
@@ -84,15 +86,54 @@ install_dependencies() {
install_packages() {
[ $# -eq 0 ] && perror "Sanity check failed: no argument given to install_package"
local PACKAGE_LIST="$@"
- if [ "x$PACKET_MANAGER" == "xapt" ]; then
- apt-get install -y ${PACKAGE_LIST} || \
- pwarning "install_packages: apt-get failed with '$IRET' for package '$PACKAGE_LIST'"
- elif [ "x$PACKET_MANAGER" == "xzypper" ]; then
- zypper --no-refresh --non-interactive install ${PACKAGE_LIST} || \
- pwarning "install_packages: zypper failed with '$IRET' for package '$PACKAGE_LIST'"
- else
- pinfo "No packet manager determined, this should not happen!"
- fi
+ local INSTALLED_PACKAGES=""
+
+ for PKG in ${PACKAGE_LIST}; do
+ # check if installed
+ if [ "x$PACKET_MANAGER" == "xapt" ]; then
+ dpkg -L ${PKG} > /dev/null 2>&1
+ elif [ "x$PACKET_MANAGER" == "xzypper" ]; then
+ rpm -ql ${PKG} > /dev/null 2>&1
+ else
+ perror "No packet manager determined, this should not happen!"
+ fi
+
+ local LRET=$?
+ if [ "x$LRET" == "x0" ]; then
+ # package installed
+ pdebug "$PKG installed!"
+ elif [ "x$LRET" == "x1" ]; then
+ # package not installed
+ pdebug "$PKG not installed!"
+ if [ "x$PACKET_MANAGER" == "xapt" ]; then
+ apt-get install -y ${PKG}
+ local IRET=$?
+ if [ "x$IRET" == "x0" ]; then
+ # $PGK was installed successfully
+ INSTALLED_PACKAGES+="$PKG "
+ elif [ "x$IRET" == "x1" ]; then
+ # PKG was not installed
+ # TODO error handling
+ pwarning "install_packages: apt-get failed with '$?' for package '$PKG'"
+ fi
+ elif [ "x$PACKET_MANAGER" == "xzypper" ]; then
+ zypper --no-refresh --non-interactive install ${PKG}
+ local IRET=$?
+ if [ "x$IRET" == "x0" ]; then
+ # $PGK was installed successfully
+ INSTALLED_PACKAGES+="$PKG "
+ elif [ "x$IRET" == "x1" ]; then
+ # PKG was not installed
+ # TODO error handling
+ pwarning "install_packages: zypper failed with '$?' for package '$PKG'"
+ fi
+ else
+ perror "No packet manager determined, this should not happen!"
+ fi
+ fi
+ done
+ [ ! -z "$INSTALLED_PACKAGES" ] && pinfo "Packages installed: ${INSTALLED_PACKAGES}"
+
}
#