]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - repackage.sh
- keep parallel downloads to 1; reset release to 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         # we need to grab also dir where spec resides
25         local a spec specdir
26         while [ $# -gt 0 ]; do
27                 case "$1" in
28                 --target)
29                         shift
30                         TARGET=$1
31                         ;;
32                 *.spec)
33                         spec="$1"
34                         a="$a $1"
35                         ;;
36                 *)
37                         a="$a $1"
38                         ;;
39                 esac
40                 shift
41         done
42
43     specdir=$(dirname "$(pwd)/${spec:-.}")
44
45         # use gz payload as time is what we need here, not compress ratio
46
47         # we use %__ldconfig variable to test are we on rpm 4.4.9
48         # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead
49         # on 4.4.2 we must redefine %clean to contain %clean
50         set -x
51         /usr/bin/rpmbuild \
52                 ${TARGET:+--target $TARGET} \
53                 --short-circuit \
54                 --define "_specdir $specdir" --define "_sourcedir $specdir" \
55                 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
56                 exit 0%{nil}' \
57                 --define 'check %%check \
58                 exit 0%{nil}' \
59                 --define '_source_payload w5.gzdio' \
60                 --define '_binary_payload w5.gzdio' \
61                 --define '__spec_install_pre %___build_pre' \
62                 --define '__spec_clean_body %{nil}' \
63                 $a || exit
64 }
65
66 specdump() {
67         local a
68         while [ $# -gt 0 ]; do
69                 case "$1" in
70                 --target|--with|--without)
71                         a="$a $1 $2"
72                         shift
73                         ;;
74                 --define)
75                         a="$a $1 \"$2\""
76                         shift
77                         ;;
78                 -*)
79                         ;;
80                 *)
81                         a="$a $1"
82                         ;;
83                 esac
84                 shift
85         done
86         set -x
87         eval rpm-specdump $a || echo >&2 $?
88 }
89
90 if [ $# = 0 ]; then
91         # if no spec name passed, glob *.spec
92         set -- *.spec
93         if [ ! -f "$1" -o $# -gt 1 ]; then
94                 echo >&2 "ERROR: Too many or too few .spec files found"
95                 echo >&2 "Usage: ${0##*/} PACKAGE.spec"
96                 exit 1
97         fi
98 else
99         # $1 must be spec, ensure it has .spec ext
100         spec=$1; shift
101         set -- ${spec%.spec}.spec "$@"
102 fi
103
104 tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
105 if [ "$tmp" ]; then
106         TARGET="$tmp"
107 fi
108
109 # just create the rpm's if -bb is somewhere in the args
110 if [[ *$@* != *-bb* ]]; then
111         rpmbuild -bi "$@"
112 fi
113 rpmbuild -bb "$@"
This page took 0.21011 seconds and 3 git commands to generate.