]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - repackage.sh
builder: Check md5 sums of downloaded patches
[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
22rpmbuild() {
ace4b218 23 # preprocess args, we must have --target as first arg to rpmbuild
13fccae7
ER
24 # we need to grab also dir where spec resides
25 local a spec specdir
ace4b218
ER
26 while [ $# -gt 0 ]; do
27 case "$1" in
28 --target)
29 shift
30 TARGET=$1
31 ;;
13fccae7
ER
32 *.spec)
33 spec="$1"
34 a="$a $1"
35 ;;
ace4b218
ER
36 *)
37 a="$a $1"
38 ;;
39 esac
40 shift
41 done
42
13fccae7
ER
43 specdir=$(dirname "$(pwd)/${spec:-.}")
44
f0e590fe 45 # use gz payload as time is what we need here, not compress ratio
6816b44c
ER
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
b0f3c13a 50 set -x
3d133bf0 51 /usr/bin/rpmbuild \
e3332001 52 ${TARGET:+--target $TARGET} \
e3332001 53 --short-circuit \
13fccae7 54 --define "_specdir $specdir" --define "_sourcedir $specdir" \
6816b44c 55 --define 'clean %%%{!?__ldconfig:clean}%{?__ldconfig:check} \
f0e590fe
ER
56 exit 0%{nil}' \
57 --define 'check %%check \
58 exit 0%{nil}' \
df631f48
ER
59 --define '_source_payload w5.gzdio' \
60 --define '_binary_payload w5.gzdio' \
6816b44c
ER
61 --define '__spec_install_pre %___build_pre' \
62 --define '__spec_clean_body %{nil}' \
e21ba2b0 63 --define '_enable_debug_packages 0' \
ace4b218 64 $a || exit
b0f3c13a 65}
e5c7e9c1 66
ebdafdf7
ER
67specdump() {
68 local a
69 while [ $# -gt 0 ]; do
70 case "$1" in
71 --target|--with|--without)
72 a="$a $1 $2"
73 shift
74 ;;
bf76d74e
ER
75 --define)
76 a="$a $1 \"$2\""
77 shift
78 ;;
ebdafdf7
ER
79 -*)
80 ;;
81 *)
82 a="$a $1"
83 ;;
84 esac
85 shift
86 done
87 set -x
fe30f816 88 eval rpm-specdump $a || echo >&2 $?
ebdafdf7
ER
89}
90
553e4236
ER
91if [ $# = 0 ]; then
92 # if no spec name passed, glob *.spec
93 set -- *.spec
94 if [ ! -f "$1" -o $# -gt 1 ]; then
95 echo >&2 "ERROR: Too many or too few .spec files found"
96 echo >&2 "Usage: ${0##*/} PACKAGE.spec"
97 exit 1
98 fi
578b62c7
ER
99else
100 # $1 must be spec, ensure it has .spec ext
101 spec=$1; shift
c6d96c51 102 set -- ${spec%.spec}.spec "$@"
553e4236
ER
103fi
104
ebdafdf7 105tmp=$(specdump "$@" | awk '$2 == "_target_cpu" {print $3}')
595e4fde
ER
106if [ "$tmp" ]; then
107 TARGET="$tmp"
108fi
109
e5c7e9c1
ER
110# just create the rpm's if -bb is somewhere in the args
111if [[ *$@* != *-bb* ]]; then
4a529b9f 112 rpmbuild -bi "$@"
e5c7e9c1 113fi
3d133bf0 114rpmbuild -bb "$@"
This page took 0.038483 seconds and 4 git commands to generate.