]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - repackage.sh
on -j define __jobs instead of _smp_mflags
[packages/rpm-build-tools.git] / repackage.sh
CommitLineData
b0f3c13a
ER
1#!/bin/sh
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
20set -e
21
ec69e1fc
ER
22skip_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
b0f3c13a 43rpmbuild() {
ace4b218 44 # preprocess args, we must have --target as first arg to rpmbuild
13fccae7
ER
45 # we need to grab also dir where spec resides
46 local a spec specdir
ace4b218
ER
47 while [ $# -gt 0 ]; do
48 case "$1" in
49 --target)
50 shift
51 TARGET=$1
52 ;;
13fccae7
ER
53 *.spec)
54 spec="$1"
55 a="$a $1"
56 ;;
ace4b218
ER
57 *)
58 a="$a $1"
59 ;;
60 esac
61 shift
62 done
63
13fccae7
ER
64 specdir=$(dirname "$(pwd)/${spec:-.}")
65
f0e590fe 66 # use gz payload as time is what we need here, not compress ratio
6816b44c
ER
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
b0f3c13a 71 set -x
3d133bf0 72 /usr/bin/rpmbuild \
e3332001 73 ${TARGET:+--target $TARGET} \
e3332001 74 --short-circuit \
13fccae7 75 --define "_specdir $specdir" --define "_sourcedir $specdir" \
6816b44c 76 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
f0e590fe
ER
77 exit 0%{nil}' \
78 --define 'check %%check \
79 exit 0%{nil}' \
df631f48
ER
80 --define '_source_payload w5.gzdio' \
81 --define '_binary_payload w5.gzdio' \
6816b44c
ER
82 --define '__spec_install_pre %___build_pre' \
83 --define '__spec_clean_body %{nil}' \
e21ba2b0 84 --define '_enable_debug_packages 0' \
ec69e1fc 85 ${bb+$(skip_dep_generators)} \
84d61793 86 ${bb+--define '%py_postclean(-x:) %{nil}'} \
ace4b218 87 $a || exit
b0f3c13a 88}
e5c7e9c1 89
ebdafdf7
ER
90specdump() {
91 local a
92 while [ $# -gt 0 ]; do
93 case "$1" in
94 --target|--with|--without)
95 a="$a $1 $2"
96 shift
97 ;;
bf76d74e
ER
98 --define)
99 a="$a $1 \"$2\""
100 shift
101 ;;
ebdafdf7
ER
102 -*)
103 ;;
104 *)
105 a="$a $1"
106 ;;
107 esac
108 shift
109 done
110 set -x
fe30f816 111 eval rpm-specdump $a || echo >&2 $?
ebdafdf7
ER
112}
113
553e4236
ER
114if [ $# = 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
578b62c7
ER
122else
123 # $1 must be spec, ensure it has .spec ext
124 spec=$1; shift
c6d96c51 125 set -- ${spec%.spec}.spec "$@"
553e4236
ER
126fi
127
ebdafdf7 128tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
595e4fde
ER
129if [ "$tmp" ]; then
130 TARGET="$tmp"
131fi
132
ec69e1fc
ER
133# skip -bi if -bb is somewhere in the args
134if [[ *$@* = *-bb* ]]; then
135 bb=
136else
137 bb= rpmbuild -bi "$@"
138 unset bb
e5c7e9c1 139fi
3d133bf0 140rpmbuild -bb "$@"
This page took 0.112122 seconds and 4 git commands to generate.