]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - repackage.sh
- process --define for rpm-specdump
[packages/rpm-build-tools.git] / repackage.sh
1 #!/bin/sh
2 # will build package, skipping %prep and %build stage
3 # i use it a lot!
4 #
5 # -glen 2005-03-03
6 #
7 # Usage:
8 # do %install and rpm package, skips %clean
9 # SPECS$ ./repackage.sh kdelibs.spec
10 #
11 # after that is done you could try only package creation (as %clean was
12 # skipped), for adjusting %files lists:
13 # SPECS$ ./repackage.sh kdelibs.spec -bb
14 #
15 # See also: SPECS/compile.sh
16 #
17 # TODO
18 # - make builder to understand -bi and use builder for short-circuit
19
20 set -e
21
22 rpmbuild() {
23         # use gz payload as time is what we need here, not compress ratio
24
25         # we use %__ldconfig variable to test are we on rpm 4.4.9
26         # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead
27         # on 4.4.2 we must redefine %clean to contain %clean
28         set -x
29         /usr/bin/rpmbuild \
30                 ${TARGET:+--target $TARGET} \
31                 $BCONDS \
32                 --short-circuit \
33                 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
34                 exit 0%{nil}' \
35                 --define 'check %%check \
36                 exit 0%{nil}' \
37                 --define '_source_payload w9.gzdio' \
38                 --define '__spec_install_pre %___build_pre' \
39                 --define '__spec_clean_body %{nil}' \
40                 "$@" || exit
41 }
42
43 specdump() {
44         local a
45         while [ $# -gt 0 ]; do
46                 case "$1" in
47                 --target|--with|--without)
48                         a="$a $1 $2"
49                         shift
50                         ;;
51                 --define)
52                         a="$a $1 \"$2\""
53                         shift
54                         ;;
55                 -*)
56                         ;;
57                 *)
58                         a="$a $1"
59                         ;;
60                 esac
61                 shift
62         done
63         set -x
64         eval rpm-specdump $a
65 }
66
67 specfile="${1%.spec}.spec"; shift
68 set -- "$specfile" "$@"
69
70 tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
71 if [ "$tmp" ]; then
72         TARGET="$tmp"
73 fi
74
75 BCONDS=$(./builder -nn -ncs --show-bcond-args $specfile)
76
77 # just create the rpm's if -bb is somewhere in the args
78 if [[ *$@* != *-bb* ]]; then
79         rpmbuild -bi "$@"
80 fi
81 rpmbuild -bb "$@"
This page took 0.082483 seconds and 4 git commands to generate.