diff options
-rw-r--r-- | helper/fileutil.inc | 11 | ||||
-rw-r--r-- | helper/string.inc | 9 | ||||
-rwxr-xr-x | mltk | 3 | ||||
-rwxr-xr-x | remote/setup_target | 50 |
4 files changed, 54 insertions, 19 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc index 192758ff..8d61344b 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -1,14 +1,3 @@ -# one time jobs - -# determine packet manager: -if [ ! -z "$(which apt-get 2>/dev/null)" ]; then - PACKET_MANAGER="apt" -elif [ ! -z "$(which zypper 2>/dev/null)" ]; then - PACKET_MANAGER="zypper" -else - perror "Could not determine this platform's packet manager" -fi - # # copy list of files using tar tarcopy () { diff --git a/helper/string.inc b/helper/string.inc index 04809a93..4c6b9778 100644 --- a/helper/string.inc +++ b/helper/string.inc @@ -26,3 +26,12 @@ escape_search() { escape_replace() { sed -e 's/[\/&]/\\&/g' } + +tolower () { + tr '[A-Z]' '[a-z]' +} + +toupper () { + tr '[a-z]' '[A-Z]' +} + @@ -101,10 +101,7 @@ initial_checks() { else banner fi - # print system information pinfo "Arch triplet of this machine: $ARCH_TRIPLET" - pinfo "Kernel version: $KERNEL_VERSION" - pinfo "System's packet manager is $PACKET_MANAGER" # source the 2 central scripts: # setup_target diff --git a/remote/setup_target b/remote/setup_target index 378606b0..2115d18e 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -58,7 +58,37 @@ EXPORT_DIR="/export/build" PROCESSED_MODULES="" initial_checks () { - : + # 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|debian) + PACKET_MANAGER="apt" + ;; + opensuse) + PACKET_MANAGER="zypper" + ;; + scientific) + PACKET_MANAGER="yum" + ;; + *) + 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 (-) + local VERSION=$(lsb_release -rs | tolower | 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" } # @@ -76,10 +106,20 @@ read_config () { [ ! -e "${MODULE_CONFIG}" ] && perror "Config for '$MODULE' not found." # source the config file . "${MODULE_CONFIG}" || perror "Sourcing '${MODULE_CONFIG}' failed." - if [ -e "${MODULE_CONFIG}.${PACKET_MANAGER}" ]; then - # a specific tool.conf seems to exist, use it to override certain vars - . "${MODULE_CONFIG}.${PACKET_MANAGER}" || perror "Sourcing '${MODULE_CONFIG}.${PACKET_MANAGER}' failed." - fi + # sanity checks - no distribution specific things in the global config + local CHECK + for CHECK in REQUIRED_CONTENT_PACKAGES REQUIRED_INSTALLED_PACKAGES; do + [ -n "${!CHECK}" ] && perror "$CHECK is set in ${MODULE}.conf, but distribution specific config has to go to one of these files:\n$PRINT_SYS_VERSIONS" + done + local FILE + for FILE in $SYS_VERSIONS; do + if [ -e "${MODULE_CONFIG}.${FILE}" ]; then + # a specific tool.conf seems to exist, use it to override/extend certain vars + . "${MODULE_CONFIG}.${FILE}" || perror "Sourcing '${MODULE_CONFIG}.${PACKET_MANAGER}' failed." + pinfo "Sourced distribution specific ${MODULE_CONFIG}.${FILE}" + break + fi + done } # |