]>
Commit | Line | Data |
---|---|---|
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 | skip_dep_generators() { | |
23 | local dep | |
24 | for dep in \ | |
25 | font \ | |
26 | gstreamer \ | |
27 | java \ | |
28 | kernel \ | |
29 | libtool \ | |
30 | mimetype \ | |
31 | mono \ | |
32 | perl \ | |
33 | php \ | |
34 | pkgconfig \ | |
35 | python \ | |
36 | ruby \ | |
37 | ; do | |
38 | printf "--define __%s_provides%%{nil}\n" $dep | |
39 | printf "--define __%s_requires%%{nil}\n" $dep | |
40 | done | |
41 | } | |
42 | ||
43 | rpmbuild() { | |
44 | # preprocess args, we must have --target as first arg to rpmbuild | |
45 | # we need to grab also dir where spec resides | |
46 | local a spec specdir | |
47 | while [ $# -gt 0 ]; do | |
48 | case "$1" in | |
49 | --target) | |
50 | shift | |
51 | TARGET=$1 | |
52 | ;; | |
53 | *.spec) | |
54 | spec="$1" | |
55 | a="$a $1" | |
56 | ;; | |
57 | *) | |
58 | a="$a $1" | |
59 | ;; | |
60 | esac | |
61 | shift | |
62 | done | |
63 | ||
64 | specdir=$(dirname "$(pwd)/${spec:-.}") | |
65 | ||
66 | # use gz payload as time is what we need here, not compress ratio | |
67 | ||
68 | # we use %__ldconfig variable to test are we on rpm 4.4.9 | |
69 | # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead | |
70 | # on 4.4.2 we must redefine %clean to contain %clean | |
71 | set -x | |
72 | /usr/bin/rpmbuild \ | |
73 | ${TARGET:+--target $TARGET} \ | |
74 | --short-circuit \ | |
75 | --define "_specdir $specdir" --define "_sourcedir $specdir" \ | |
76 | --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \ | |
77 | exit 0%{nil}' \ | |
78 | --define 'check %%check \ | |
79 | exit 0%{nil}' \ | |
80 | --define '_source_payload w5.gzdio' \ | |
81 | --define '_binary_payload w5.gzdio' \ | |
82 | --define '__spec_install_pre %___build_pre' \ | |
83 | --define '__spec_clean_body %{nil}' \ | |
84 | --define '_enable_debug_packages 0' \ | |
85 | ${bb+$(skip_dep_generators)} \ | |
86 | ${bb+--define '%py_postclean(-x:) %{nil}'} \ | |
87 | $a || exit | |
88 | } | |
89 | ||
90 | specdump() { | |
91 | local a | |
92 | while [ $# -gt 0 ]; do | |
93 | case "$1" in | |
94 | --target|--with|--without) | |
95 | a="$a $1 $2" | |
96 | shift | |
97 | ;; | |
98 | --define) | |
99 | a="$a $1 \"$2\"" | |
100 | shift | |
101 | ;; | |
102 | -*) | |
103 | ;; | |
104 | *) | |
105 | a="$a $1" | |
106 | ;; | |
107 | esac | |
108 | shift | |
109 | done | |
110 | set -x | |
111 | eval rpm-specdump $a || echo >&2 $? | |
112 | } | |
113 | ||
114 | if [ $# = 0 ]; then | |
115 | # if no spec name passed, glob *.spec | |
116 | set -- *.spec | |
117 | if [ ! -f "$1" -o $# -gt 1 ]; then | |
118 | echo >&2 "ERROR: Too many or too few .spec files found" | |
119 | echo >&2 "Usage: ${0##*/} PACKAGE.spec" | |
120 | exit 1 | |
121 | fi | |
122 | else | |
123 | # $1 must be spec, ensure it has .spec ext | |
124 | spec=$1; shift | |
125 | set -- ${spec%.spec}.spec "$@" | |
126 | fi | |
127 | ||
128 | tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}') | |
129 | if [ "$tmp" ]; then | |
130 | TARGET="$tmp" | |
131 | fi | |
132 | ||
133 | # skip -bi if -bb is somewhere in the args | |
134 | if [[ *$@* = *-bb* ]]; then | |
135 | bb= | |
136 | else | |
137 | bb= rpmbuild -bi "$@" | |
138 | unset bb | |
139 | fi | |
140 | rpmbuild -bb "$@" |