rpmbuild() {
# preprocess args, we must have --target as first arg to rpmbuild
- local a
+ # we need to grab also dir where spec resides
+ local a spec specdir
while [ $# -gt 0 ]; do
case "$1" in
--target)
shift
TARGET=$1
;;
+ *.spec)
+ spec="$1"
+ a="$a $1"
+ ;;
*)
a="$a $1"
;;
shift
done
+ specdir=$(dirname "$(pwd)/${spec:-.}")
+
# use gz payload as time is what we need here, not compress ratio
# we use %__ldconfig variable to test are we on rpm 4.4.9
/usr/bin/rpmbuild \
${TARGET:+--target $TARGET} \
--short-circuit \
+ --define "_specdir $specdir" --define "_sourcedir $specdir" \
--define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
exit 0%{nil}' \
--define 'check %%check \
exit 0%{nil}' \
- --define '_source_payload w9.gzdio' \
- --define '_binary_payload w9.gzdio' \
+ --define '_source_payload w5.gzdio' \
+ --define '_binary_payload w5.gzdio' \
--define '__spec_install_pre %___build_pre' \
--define '__spec_clean_body %{nil}' \
$a || exit
eval rpm-specdump $a || echo >&2 $?
}
+if [ $# = 0 ]; then
+ # if no spec name passed, glob *.spec
+ set -- *.spec
+ if [ ! -f "$1" -o $# -gt 1 ]; then
+ echo >&2 "ERROR: Too many or too few .spec files found"
+ echo >&2 "Usage: ${0##*/} PACKAGE.spec"
+ exit 1
+ fi
+else
+ # $1 must be spec, ensure it has .spec ext
+ spec=$1; shift
+ set -- ${spec%.spec}.spec "$@"
+fi
+
tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
if [ "$tmp" ]; then
TARGET="$tmp"