]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - repackage.sh
- 4.2.1
[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         # preprocess args, we must have --target as first arg to rpmbuild
24         local a
25         while [ $# -gt 0 ]; do
26                 case "$1" in
27                 --target)
28                         shift
29                         TARGET=$1
30                         ;;
31                 *)
32                         a="$a $1"
33                         ;;
34                 esac
35                 shift
36         done
37
38         # use gz payload as time is what we need here, not compress ratio
39
40         # we use %__ldconfig variable to test are we on rpm 4.4.9
41         # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead
42         # on 4.4.2 we must redefine %clean to contain %clean
43         set -x
44         /usr/bin/rpmbuild \
45                 ${TARGET:+--target $TARGET} \
46                 --short-circuit \
47                 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
48                 exit 0%{nil}' \
49                 --define 'check %%check \
50                 exit 0%{nil}' \
51                 --define '_source_payload w5.gzdio' \
52                 --define '_binary_payload w5.gzdio' \
53                 --define '__spec_install_pre %___build_pre' \
54                 --define '__spec_clean_body %{nil}' \
55                 $a || exit
56 }
57
58 specdump() {
59         local a
60         while [ $# -gt 0 ]; do
61                 case "$1" in
62                 --target|--with|--without)
63                         a="$a $1 $2"
64                         shift
65                         ;;
66                 --define)
67                         a="$a $1 \"$2\""
68                         shift
69                         ;;
70                 -*)
71                         ;;
72                 *)
73                         a="$a $1"
74                         ;;
75                 esac
76                 shift
77         done
78         set -x
79         eval rpm-specdump $a || echo >&2 $?
80 }
81
82 tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
83 if [ "$tmp" ]; then
84         TARGET="$tmp"
85 fi
86
87 # just create the rpm's if -bb is somewhere in the args
88 if [[ *$@* != *-bb* ]]; then
89         rpmbuild -bi "$@"
90 fi
91 rpmbuild -bb "$@"
This page took 0.048745 seconds and 3 git commands to generate.