]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - repackage.sh
f71b9eb16645ccc06b49776db9136c4a613e682b
[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                 --short-circuit \
32                 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
33                 exit 0%{nil}' \
34                 --define 'check %%check \
35                 exit 0%{nil}' \
36                 --define '_source_payload w9.gzdio' \
37                 --define '_binary_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 || echo >&2 $?
65 }
66
67 tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
68 if [ "$tmp" ]; then
69         TARGET="$tmp"
70 fi
71
72 # just create the rpm's if -bb is somewhere in the args
73 if [[ *$@* != *-bb* ]]; then
74         rpmbuild -bi "$@"
75 fi
76 rpmbuild -bb "$@"
This page took 0.033226 seconds and 3 git commands to generate.