]>
Commit | Line | Data |
---|---|---|
86d57dce | 1 | #!/bin/bash |
b0f3c13a ER |
2 | # will build package, skipping %prep and %build stage |
3 | # i use it a lot! | |
4 | # | |
5 | # -glen 2005-03-03 | |
201eefee | 6 | # |
5f775b93 ER |
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 | # | |
201eefee | 17 | # TODO |
1e4db2ae | 18 | # - make builder to understand -bi and use builder for short-circuit |
b0f3c13a ER |
19 | |
20 | set -e | |
21 | ||
86d57dce ER |
22 | dump() { |
23 | local a | |
24 | for a in "$@"; do | |
25 | echo "$a" | |
26 | done | |
27 | } | |
28 | ||
ec69e1fc ER |
29 | skip_dep_generators() { |
30 | local dep | |
31 | for dep in \ | |
32 | font \ | |
33 | gstreamer \ | |
34 | java \ | |
35 | kernel \ | |
36 | libtool \ | |
37 | mimetype \ | |
38 | mono \ | |
39 | perl \ | |
40 | php \ | |
41 | pkgconfig \ | |
42 | python \ | |
43 | ruby \ | |
44 | ; do | |
86d57dce ER |
45 | args+=("--define=__${dep}_provides %%{nil}") |
46 | args+=("--define=__${dep}_requires %%{nil}") | |
ec69e1fc ER |
47 | done |
48 | } | |
49 | ||
b0f3c13a | 50 | rpmbuild() { |
ace4b218 | 51 | # preprocess args, we must have --target as first arg to rpmbuild |
13fccae7 ER |
52 | # we need to grab also dir where spec resides |
53 | local a spec specdir | |
ace4b218 ER |
54 | while [ $# -gt 0 ]; do |
55 | case "$1" in | |
56 | --target) | |
57 | shift | |
58 | TARGET=$1 | |
59 | ;; | |
13fccae7 ER |
60 | *.spec) |
61 | spec="$1" | |
62 | a="$a $1" | |
63 | ;; | |
ace4b218 ER |
64 | *) |
65 | a="$a $1" | |
66 | ;; | |
67 | esac | |
68 | shift | |
69 | done | |
70 | ||
13fccae7 ER |
71 | specdir=$(dirname "$(pwd)/${spec:-.}") |
72 | ||
f0e590fe | 73 | # use gz payload as time is what we need here, not compress ratio |
6816b44c ER |
74 | |
75 | # we use %__ldconfig variable to test are we on rpm 4.4.9 | |
76 | # on 4.4.9 we should not redefine %clean to contain %clean, and redefine %__spec_clean_body instead | |
77 | # on 4.4.2 we must redefine %clean to contain %clean | |
86d57dce ER |
78 | local -a args=() |
79 | if [ -n "${bb+1}" ]; then | |
80 | skip_dep_generators | |
81 | args+=(--define '%py_postclean(-x:) %{nil}') | |
82 | fi | |
83 | ||
b0f3c13a | 84 | set -x |
3d133bf0 | 85 | /usr/bin/rpmbuild \ |
e3332001 | 86 | ${TARGET:+--target $TARGET} \ |
e3332001 | 87 | --short-circuit \ |
86d57dce | 88 | --define 'disable_short_circuited_deps 0' \ |
13fccae7 | 89 | --define "_specdir $specdir" --define "_sourcedir $specdir" \ |
6816b44c | 90 | --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \ |
f0e590fe ER |
91 | exit 0%{nil}' \ |
92 | --define 'check %%check \ | |
93 | exit 0%{nil}' \ | |
df631f48 ER |
94 | --define '_source_payload w5.gzdio' \ |
95 | --define '_binary_payload w5.gzdio' \ | |
6816b44c ER |
96 | --define '__spec_install_pre %___build_pre' \ |
97 | --define '__spec_clean_body %{nil}' \ | |
e21ba2b0 | 98 | --define '_enable_debug_packages 0' \ |
86d57dce | 99 | "${args[@]}" \ |
ace4b218 | 100 | $a || exit |
b0f3c13a | 101 | } |
e5c7e9c1 | 102 | |
ebdafdf7 ER |
103 | specdump() { |
104 | local a | |
105 | while [ $# -gt 0 ]; do | |
106 | case "$1" in | |
107 | --target|--with|--without) | |
108 | a="$a $1 $2" | |
109 | shift | |
110 | ;; | |
bf76d74e ER |
111 | --define) |
112 | a="$a $1 \"$2\"" | |
113 | shift | |
114 | ;; | |
ebdafdf7 ER |
115 | -*) |
116 | ;; | |
117 | *) | |
118 | a="$a $1" | |
119 | ;; | |
120 | esac | |
121 | shift | |
122 | done | |
123 | set -x | |
fe30f816 | 124 | eval rpm-specdump $a || echo >&2 $? |
ebdafdf7 ER |
125 | } |
126 | ||
553e4236 ER |
127 | if [ $# = 0 ]; then |
128 | # if no spec name passed, glob *.spec | |
129 | set -- *.spec | |
130 | if [ ! -f "$1" -o $# -gt 1 ]; then | |
131 | echo >&2 "ERROR: Too many or too few .spec files found" | |
132 | echo >&2 "Usage: ${0##*/} PACKAGE.spec" | |
133 | exit 1 | |
134 | fi | |
578b62c7 ER |
135 | else |
136 | # $1 must be spec, ensure it has .spec ext | |
137 | spec=$1; shift | |
c6d96c51 | 138 | set -- ${spec%.spec}.spec "$@" |
553e4236 ER |
139 | fi |
140 | ||
ebdafdf7 | 141 | tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}') |
595e4fde ER |
142 | if [ "$tmp" ]; then |
143 | TARGET="$tmp" | |
144 | fi | |
145 | ||
ec69e1fc ER |
146 | # skip -bi if -bb is somewhere in the args |
147 | if [[ *$@* = *-bb* ]]; then | |
148 | bb= | |
149 | else | |
150 | bb= rpmbuild -bi "$@" | |
151 | unset bb | |
e5c7e9c1 | 152 | fi |
3d133bf0 | 153 | rpmbuild -bb "$@" |