X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=contrib%2Flbuild%2Ffuncs.sh;h=71633b3139dcafc99aeff1e3623b9b47bb912e31;hb=dbd8f93ccc78204fc5394148d4b6a313332b9594;hp=bbd77096900f89a7dc2196bae17c1f69a33debee;hpb=25c93758d6b1136d268fe3fcc1c4979c17463c0b;p=fs%2Flustre-release.git diff --git a/contrib/lbuild/funcs.sh b/contrib/lbuild/funcs.sh index bbd7709..71633b3 100644 --- a/contrib/lbuild/funcs.sh +++ b/contrib/lbuild/funcs.sh @@ -6,16 +6,15 @@ cleanup() { error() { local msg="$1" - [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&$STDOUT - + if [ -n "$msg" ]; then + echo -e "\n${0##*/}: $msg" >&$STDOUT + fi } fatal() { - cleanup error "$2" exit $1 - } # @@ -56,14 +55,14 @@ find_rpm() { find_linux_rpms() { local prefix="$1" - local pathtorpms=${2:-"${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${TARGET_ARCH}"} + local pathtorpms=${2:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"} - local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}" + local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}${rpmfix}" local kernel_rpms=$(find_linux_rpm "$prefix" "$pathtorpms") # call a distro specific hook, if available - if type -p find_linux_rpms-$DISTRO; then + if type -p find_linux_rpms-$DISTROMAJ; then local rpm - if rpm=$(find_linux_rpms-$DISTRO "$prefix" "$wanted_kernel" "$pathtorpms"); then + if rpm=$(find_linux_rpms-$DISTROMAJ "$prefix" "$wanted_kernel" "$pathtorpms"); then kernel_rpms="$kernel_rpms $rpm" else return 255 @@ -86,10 +85,10 @@ resolve_arch() { # or just gotten rid of. :-) find_linux_rpm() { local prefix="$1" - local pathtorpms=${2:-"${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${TARGET_ARCH}"} + local pathtorpms=${2:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"} local found_rpm="" - local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}" + local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}${rpmfix}" local ret=1 if [ -d "$pathtorpms" ]; then local rpm @@ -108,8 +107,8 @@ find_linux_rpm() { # done if [ -z "$found_rpm" ]; then # see if there is a distro specific way of getting the RPM - if type -p find_linux_rpm-$DISTRO; then - if found_rpm=$(find_linux_rpm-$DISTRO "$prefix" "$wanted_kernel" "$pathtorpms"); then + if type -p find_linux_rpm-$DISTROMAJ; then + if found_rpm=$(find_linux_rpm-$DISTROMAJ "$prefix" "$wanted_kernel" "$pathtorpms"); then found_rpm="${pathtorpms}/$found_rpm" ret=0 else @@ -135,14 +134,14 @@ autodetect_distro() { case "$name" in "EnterpriseEnterpriseServer") name="oel" - version="${version%%.*}" ;; "RedHatEnterpriseServer" | "ScientificSL" | "CentOS") name="rhel" - version="${version%%.*}" ;; "SUSE LINUX") name="sles" + PATCHLEVEL=$(sed -n -e 's/^PATCHLEVEL = //p' /etc/SuSE-release) + version="${version}.$PATCHLEVEL" ;; "Fedora") name="fc" @@ -152,24 +151,25 @@ autodetect_distro() { ;; esac else - echo "You really ought to install lsb_release for accurate distro identification" + error "You really ought to install lsb_release for accurate distro identification" # try some heuristics if [ -f /etc/SuSE-release ]; then name=sles - version=$(grep ^VERSION /etc/SuSE-release) - version=${version#*= } + version=$(sed -n -e 's/^VERSION = //p' /etc/SuSE-release) + PATCHLEVEL=$(sed -n -e 's/^PATCHLEVEL = //p' /etc/SuSE-release) + version="${version}.$PATCHLEVEL" elif [ -f /etc/redhat-release ]; then #name=$(head -1 /etc/redhat-release) name=rhel version=$(echo "$distroname" | - sed -e 's/^[^0-9.]*//g' | sed -e 's/[ \.].*//') + sed -e 's/^[^0-9.]*//g' | sed -e 's/[ ].*//') fi if [ -z "$name" -o -z "$version" ]; then fatal 1 "I don't know how to determine distro type/version.\nEither update autodetect_distro() or use the --distro argument." fi fi - echo ${name}${version} + echo ${name}-${version} return 0 } @@ -180,14 +180,16 @@ autodetect_target() { local target="" case ${distro} in - oel5) target="2.6-oel5";; - rhel5) target="2.6-rhel5";; - rhel6) target="2.6-rhel6";; - sles10) target="2.6-sles10";; - sles11) target="$(uname -r | cut -d . -f 1,2)-sles11";; - fc15) target="2.6-fc15";; - fc18) target="3.x-fc18";; - *) fatal 1 "I don't know what distro $distro is.\nEither update autodetect_target() or use the --target argument.";; + oel5*) target="2.6-oel5";; + rhel5*) target="2.6-rhel5";; + rhel6*) target="2.6-rhel6";; + rhel7*) target="3.10-rhel7";; + sles10*) target="2.6-sles10";; + sles11.3) target="$(uname -r | cut -d . -f 1,2)-sles11sp3";; + sles11*) target="$(uname -r | cut -d . -f 1,2)-sles11";; + fc15) target="2.6-fc15";; + fc18) target="3.x-fc18";; + *) fatal 1 "I don't know what distro $distro is.\nEither update autodetect_target() or use the --target argument.";; esac echo ${target}