From b5ff6c8c7d8f171c6000b38b60b27cb908f6e40b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 27 Aug 2013 18:28:56 +0200 Subject: Missed a file... --- helper/distribution.inc | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 helper/distribution.inc (limited to 'helper') diff --git a/helper/distribution.inc b/helper/distribution.inc new file mode 100644 index 00000000..817baa53 --- /dev/null +++ b/helper/distribution.inc @@ -0,0 +1,54 @@ + + +detect_distribution () { + # Set up distribution and package management + # Lowercase distributor ID is what we use as the general distribution name + SYS_DISTRIBUTION=$(lsb_release -is | tolower | sed -r 's/[^a-z0-9]//g;s/project$//g;s/scientificsl$/scientific/g') + # Then determine packet manager + case "$SYS_DISTRIBUTION" in + ubuntu) + PACKET_MANAGER="apt" + PACKET_HANDLER="dpkg" + detect_ubuntu_lts + ;; + debian) + PACKET_MANAGER="apt" + PACKET_HANDLER="dpkg" + ;; + opensuse) + PACKET_MANAGER="zypper" + PACKET_HANDLER="rpm" + ;; + scientific) + PACKET_MANAGER="yum" + PACKET_HANDLER="rpm" + ;; + *) + perror "Unknown Distribution: $SYS_DISTRIBUTION - Please specify its packet manager in remote/setup_target" + ;; + esac + # Get version - we mangle this quite a bit. first make sure it has no spaces, then split version at period (.), underscore (_) and dash (-) + SYS_VERSION=$(lsb_release -rs | tolower) + local VERSION=$(echo $SYS_VERSION | sed -r 's/\s//g;s/[\._]/ /g;s/-//g') + local STRTMP="" + PRINT_SYS_VERSIONS="*.conf.$SYS_DISTRIBUTION" + SYS_VERSIONS="$SYS_DISTRIBUTION" + for PART in $VERSION; do + [ -z "$PART" ] && continue + STRTMP+=".$PART" + SYS_VERSIONS="${SYS_DISTRIBUTION}${STRTMP} $SYS_VERSIONS" + PRINT_SYS_VERSIONS="*.conf.${SYS_DISTRIBUTION}${STRTMP} $PRINT_SYS_VERSIONS" + done + pinfo "Config source order: *.conf first, then the first one of these (if found)" + pinfo "$PRINT_SYS_VERSIONS" +} + +detect_ubuntu_lts () { + local TMP=$(dpkg -S /usr/bin/Xorg) + [[ "$TMP" == xserver-xorg* ]] || perror "Could not detect xserver package version (returned: $TMP)" + TMP=${TMP%: *} + TMP=${TMP#xserver-xorg-core} + pinfo "Ubuntu LTS Xorg suffix: $TMP" + UBUNTU_XORG_PKG_SUFFIX="$TMP" +} + -- cgit v1.2.3-55-g7522 From 399251bc12efd30a3fa12c83c815e96d0e1cb8bd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 27 Aug 2013 18:41:58 +0200 Subject: [fileutil.inc] list_packet_files: Ignore output lines that do not start with a slash (e.g. dpkg messages about diverted files) --- helper/fileutil.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'helper') diff --git a/helper/fileutil.inc b/helper/fileutil.inc index c93e82b8..798f825a 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -38,9 +38,9 @@ list_packet_files() { [ "x$OPTIONAL" = "x@" ] && PACKAGE="$(echo "$PACKAGE" | cut -c 2-)" local FILES="" if [ "$PACKET_MANAGER" = "apt" ]; then - FILES="$(dpkg -L "$PACKAGE" | grep -v -E 'share/(man|doc)|/var/run|/var/log'; echo ":###:${PIPESTATUS[0]}")" + FILES="$(dpkg -L "$PACKAGE" | grep "^/" | grep -v -E 'share/(man|doc)|/var/run|/var/log'; echo ":###:${PIPESTATUS[0]}")" elif [ "$PACKET_MANAGER" = "zypper" -o "$PACKET_MANAGER" = "yum" ]; then - FILES="$(rpm -ql "$PACKAGE" | grep -v -E 'share/(doc|man)|/var/run|/var/log'; echo ":###:${PIPESTATUS[0]}")" + FILES="$(rpm -ql "$PACKAGE" | grep "^/" | grep -v -E 'share/(man|doc)|/var/run|/var/log'; echo ":###:${PIPESTATUS[0]}")" fi # ugly hack to get our return value #local LPRET=$(echo "$FILES" | tail -1 | sed 's/^.*:###:\([0-9]*\)$/\1/g') -- cgit v1.2.3-55-g7522