]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - repackage.sh
- use gz payload when repackaging
[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 '_binary_payload w9.gzdio' \
39                 --define '__spec_install_pre %___build_pre' \
40                 --define '__spec_clean_body %{nil}' \
41                 "$@" || exit
42 }
43
44 specdump() {
45         local a
46         while [ $# -gt 0 ]; do
47                 case "$1" in
48                 --target|--with|--without)
49                         a="$a $1 $2"
50                         shift
51                         ;;
52                 --define)
53                         a="$a $1 \"$2\""
54                         shift
55                         ;;
56                 -*)
57                         ;;
58                 *)
59                         a="$a $1"
60                         ;;
61                 esac
62                 shift
63         done
64         set -x
65         eval rpm-specdump $a
66 }
67
68 specfile="${1%.spec}.spec"; shift
69 set -- "$specfile" "$@"
70
71 tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
72 if [ "$tmp" ]; then
73         TARGET="$tmp"
74 fi
75
76 BCONDS=$(./builder -nn -ncs --show-bcond-args $specfile)
77
78 # just create the rpm's if -bb is somewhere in the args
79 if [[ *$@* != *-bb* ]]; then
80         rpmbuild -bi "$@"
81 fi
82 rpmbuild -bb "$@"
This page took 0.03616 seconds and 4 git commands to generate.