#exec 3>&1; STDOUT=3
STDOUT=2
-. ${0%/find_linux_rpms}/funcs.sh
+# Assume that lbuild's support files can be found in the same
+# canonicalized path as this very script.
+THIS_SCRIPT=$(readlink -f ${0})
+LBUILD_DIR=${LBUILD_DIR:-$(dirname ${THIS_SCRIPT})}
+
+. $LBUILD_DIR/funcs.sh
TOPDIR=$PWD
KERNELRPMSDIR="$1"
DISTRO=$(autodetect_distro)
+# remove minor version only for rhel and oel
+[[ $DISTRO =~ "el-" ]] && DISTRO=${DISTRO%%.*}
+# remove separator
+DISTRO=${DISTRO/-/}
-source ${0%/*}/lbuild-$DISTRO
+source $LBUILD_DIR/lbuild-$DISTRO
TARGET_ARCH="$(uname -m)"
TARGET_ARCHS="$(uname -m)"