Whamcloud - gitweb
b=24091 find_linux_rpms utility
[fs/lustre-release.git] / build / lbuild
index 931a216..37fe5f7 100755 (executable)
@@ -17,6 +17,7 @@ shopt -s extdebug
 
 # include the exit_traps library
 . ${0%/lbuild}/exit_traps.sh
+. ${0%/lbuild}/funcs.sh
 
 # our children should die when we do
 push_exit_trap "kill -INT -$$ || true" kill_children
@@ -117,26 +118,6 @@ readlink() {
     fi
 }
 
-cleanup() {
-
-    true
-}
-
-error() {
-    local msg="$1"
-
-    [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&3
-
-}
-
-fatal() {
-
-    cleanup
-    error "$2"
-    exit $1
-
-}
-
 usage() {
     cat <<EOF
 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
@@ -398,71 +379,6 @@ check_options() {
 
 }
 
-# autodetect target
-autodetect_target() {
-    local distro="$1"
-
-    local target=""
-    case ${distro} in
-          oel5) target="2.6-oel5";;
-         rhel5) target="2.6-rhel5";;
-        sles10) target="2.6-sles10";;
-            *) fatal 1 "I don't know what distro $distro is.\nEither update autodetect_target() or use the --target argument.";;
-    esac
-
-    echo ${target}
-    return 0
-
-}
-
-# autodetect used Distro
-autodetect_distro() {
-
-    local name
-    local version
-
-    if which lsb_release >/dev/null 2>&1; then
-        name="$(lsb_release -s -i)"
-        version="$(lsb_release -s -r)"
-        case "$name" in
-            "EnterpriseEnterpriseServer" | "ScientificSL")
-                name="oel"
-                version="${version%%.*}"
-                ;;
-            "RedHatEnterpriseServer")
-                name="rhel"
-                version="${version%%.*}"
-                ;;
-            "SUSE LINUX")
-                name="sles"
-                ;;
-            *)
-                fatal 1 "I don't know what distro name $name and version $version is.\nEither update autodetect_distro() or use the --distro argument."
-                ;;
-        esac
-    else
-        echo "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#*= }
-        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/[ \.].*//')
-        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}
-    return 0
-
-}
-
 uniqify() {
 
     echo $(echo "$*" | xargs -n 1 | sort -u)
@@ -1007,36 +923,6 @@ find_linux_release() {
 
 }
 
-# XXX this needs to be re-written as a wrapper around find_rpm
-#     or just gotten rid of.  :-)
-find_linux_rpm() {
-    local prefix="$1"
-
-    local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
-    [ -d $pathtorpms ] || return 255
-
-    local kernelbinaryrpm rpmfile
-    local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}"
-
-    local arch ret=1
-    for arch in $TARGET_ARCHS_ALL; do
-        local found_rpm="" rpm
-        for rpm in ${pathtorpms}/${arch}/*.rpm; do
-            if rpm -q --provides -p "$rpm" 2>&3 | grep -q "kernel${prefix} = $wanted_kernel" 2>&3; then
-
-                found_rpm="$rpm"
-                ret=0
-                break
-            fi
-        done
-        [ -f "$found_rpm" ] && break
-    done
-
-    echo "$found_rpm"
-    return $ret
-
-}
-
 # unpack kernel(/source/devel) RPM
 #
 # This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
@@ -1269,42 +1155,6 @@ basearch() {
 
 }
 
-#
-# in a given directory, find the first rpm matching given requirements
-#
-find_rpm() {
-    local dir="$1"
-    local match_type="$2"
-    local match="$3"
-
-    pushd "$dir" > /dev/null || \
-        fatal 1 "Unable to chdir to directory \"$dir\" in find_rpm()"
-
-    local file
-    for file in $(ls *.rpm); do
-        if [ ! -f "$file" ]; then
-            continue
-        fi
-        case "$match_type" in
-            provides)
-                # match is any valid ERE (i.e. given to egrep) match
-                if rpm -q --provides -p "$file" 2>&3 | egrep -q "$match"; then
-                    echo "$file"
-                    popd >/dev/null
-                    return 0
-                fi
-                ;;
-            *)
-                popd >/dev/null
-                fatal 1 "Unknown match type \"$match_type\" given to find_rpm()"
-                ;;
-        esac
-    done
-
-    popd >/dev/null
-    return 1
-}
-
 build_kernel_with_srpm() {
     local outfd=$1