]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - repackage.sh
- list by size, show total
[packages/rpm-build-tools.git] / repackage.sh
index d5e5bfba02527c71382720c246773d13e4b92b6a..460f68a322f0e5fc36512224aa089accc2d74b08 100644 (file)
 #
 # -glen 2005-03-03
 #
+# Usage:
+# do %install and rpm package, skips %clean
+# SPECS$ ./repackage.sh kdelibs.spec
+#
+# after that is done you could try only package creation (as %clean was
+# skipped), for adjusting %files lists:
+# SPECS$ ./repackage.sh kdelibs.spec -bb
+#
+# See also: SPECS/compile.sh
+#
 # TODO
 # - make builder to understand -bi and use builder for short-circuit
 
 set -e
 
 rpmbuild() {
+       # preprocess args, we must have --target as first arg to rpmbuild
+       # 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"
+                       ;;
+               esac
+               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
+       # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead
+       # on 4.4.2 we must redefine %clean to contain %clean
+       set -x
+       /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 w5.gzdio' \
+               --define '_binary_payload w5.gzdio' \
+               --define '__spec_install_pre %___build_pre' \
+               --define '__spec_clean_body %{nil}' \
+               $a || exit
+}
+
+specdump() {
+       local a
+       while [ $# -gt 0 ]; do
+               case "$1" in
+               --target|--with|--without)
+                       a="$a $1 $2"
+                       shift
+                       ;;
+               --define)
+                       a="$a $1 \"$2\""
+                       shift
+                       ;;
+               -*)
+                       ;;
+               *)
+                       a="$a $1"
+                       ;;
+               esac
+               shift
+       done
        set -x
-       /usr/bin/rpmbuild ${TARGET:+--target $TARGET} $BCONDS --short-circuit --define '_source_payload w9.gzdio' "$@" || exit
+       eval rpm-specdump $a || echo >&2 $?
 }
 
-BCONDS=$(./builder --show-bconds "$@")
-# ignore output from older builders whose output is not compatible.
-if [ "$(echo "$bconds" | wc -l)" -gt 1 ]; then
-       BCONDS=""
+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
 fi
 
-SPECFILE="$1"
-tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
+tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
 if [ "$tmp" ]; then
        TARGET="$tmp"
 fi
@@ -30,4 +106,4 @@ fi
 if [[ *$@* != *-bb* ]]; then
        rpmbuild -bi "$@"
 fi
-rpmbuild -bb --define 'clean %{nil}' "$@"
+rpmbuild -bb "$@"
This page took 0.059299 seconds and 4 git commands to generate.