]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - rpm-build.sh
shrc: covert ac-tag to git
[packages/rpm-build-tools.git] / rpm-build.sh
CommitLineData
7e37b984
ER
1# shell aliases and functions for PLD Developer
2
2e6b7800 3# set $dist, used by functions below
c8a54e84
ER
4[ -n "$dist" ] || dist=$(awk '/PLD Linux/ {print tolower($NF)}' /etc/pld-release 2>/dev/null | tr -d '()')
5
6case "$dist" in
15aa13b9 7ac|th|ti)
c8a54e84
ER
8 ;;
9*)
10 # invalid one ;)
11 dist=
12esac
2e6b7800 13
5e0caa68 14if [ "$dist" ]; then
7e37b984 15
d392508c 16alias ipoldek-$dist="poldek -q --sn $dist --cmd"
d392508c 17alias $dist-provides="ipoldek-$dist what-provides"
2e6b7800 18alias $dist-verify=dist-verify
c48232ce 19alias $dist-requires=dist-requires
2e6b7800 20
5d6ca156
ER
21# move AC-branch tag to current checkout
22# if AC-branch as branch exists, it is first removed
23# TODO: refuse to delete AC-branch if that branch point is unassociated (has no tag on the same hash)
24ac-tag() {
25 # see if remote has branch present
26 if [ -n "$(git branch -r | grep AC-branch)" ]; then
27 git push --delete origin AC-branch
28 fi
29
30 git tag -f AC-branch
31 git push origin AC-branch
32}
33
6ebe30c9
ER
34# undo spec utf8
35# note: it will do it blindly, so any lang other than -pl is most likely broken
36specutfundo() {
37 local spec="$1"
38 iconv -futf8 -tlatin2 "$spec" > m
39 sed -e 's/\.UTF-8//' m > "$spec"
40 rm -f m
41}
42
c48232ce
ER
43dist-requires() {
44 local opts deps
45 while [ $# -gt 0 ]; do
46 case "$1" in
47 --sn)
48 opts="$opts $1 $2"
49 shift
50 ;;
51 -*)
52 opts="$opts $1"
53 ;;
54 *)
55 deps="$deps $1"
56 ;;
57 esac
58 shift
59 done
f43b3983
ER
60
61 case "$dist" in
62 ac)
63 opts="$opts --sn=$dist-updates"
64 ;;
65 esac
66
67 poldek -q -Q --sn $dist $opts --cmd what-requires $deps
c48232ce
ER
68}
69
37ae34a0 70dist-verify() {
70d18f4d
ER
71 local args sn
72 sn="--sn $dist"
3e963c20 73
b15006fb
ER
74 case "$dist" in
75 ac)
70d18f4d
ER
76 sn="$sn --sn $dist-updates"
77
bec0be2e 78 local a ignore
eaca9a85
ER
79 # typo
80 ignore="$ignore kdenetwork-kopete-tool-conectionstatus"
25fd7f1b 81 # obsoleted
eaca9a85
ER
82 ignore="$ignore gimp-plugin-swfdec wine-drv-arts ntp-ntptrace"
83 # quake2@MAIN is now quake2forge, original quake2 restored to quake2
84 ignore="$ignore quake2-3dfx quake2-sdl quake2-sgl quake2-snd-alsa quake2-snd-ao quake2-snd-oss quake2-snd-sdl quake2-static"
25fd7f1b
ER
85 # obsoleted
86 ignore="$ignore mozilla-firefox-lang-en apache1-mod_perl-devel libyasm-static"
eb06631a
ER
87 # renamed (courier-authlib.spec, r1.54)
88 ignore="$ignore courier-authlib-userdb courier-authlib-pipe"
4876f0af
ER
89 # obsoleted, squid 2.6
90 ignore="$ignore squid-winbind_acl squid-winbind_auth"
6bf0c9cd
ER
91 # obsoleted with 1.0.4
92 ignore="$ignore python-numpy-FFT python-numpy-MA python-numpy-RNG"
a7498178
ER
93 # subpkgs renamed
94 ignore="$ignore apache1-doc apache1-index"
0e1522d9
ER
95 # obsoleted by kadu-module-mediaplayer-amarok
96 ignore="$ignore kadu-module-amarok"
97 # obsoleted by kadu-module-mediaplayer-xmms
98 ignore="$ignore kadu-module-xmms"
99 # obsoleted by kadu 0.6.0
92a62be8 100 ignore="$ignore kadu-theme-icons-crystal16 kadu-theme-icons-crystal22 kadu-theme-icons-nuvola16 kadu-theme-icons-nuvola22 kadu-module-iwait4u"
c937c6db
ER
101 # obsoleted pear test packages
102 ignore="$ignore php-*-tests"
0ead02ef
ER
103 # obsoleted
104 ignore="$ignore nmap-X11"
105 # mksd dependency not distributale
106 ignore="$ignore samba-vfs-vscan-mks"
107 # ibbackup is not distributale
108 ignore="$ignore innobackup"
3373d30b
ER
109 # use ac-updates
110 ignore="$ignore ntp-client ntp"
54c11aa2
ER
111 # php4 only(php-pecl-tidy), for php<5.2(php-pecl-filter)
112 ignore="$ignore php-pecl-tidy php-pecl-filter"
0ead02ef 113
3e963c20
ER
114 # renamed to vim-syntax-txt2tags
115 ignore="$ignore txt2tags-vim"
0ead02ef 116
bec0be2e 117 for a in $ignore; do
eaca9a85
ER
118 args="$args --ignore=$a"
119 done
b15006fb
ER
120 ;;
121 esac
122
70d18f4d 123 poldek $sn --up --upa -q "$@"
6bf0c9cd 124 poldek $sn --uniq --noignore --verify=deps $args "$@"
2e6b7800 125}
a5ab8a8f 126
5e0caa68
ER
127# displays latest used tag for a specfile
128autotag() {
286a9a85
ER
129 local out s
130 for s in "$@"; do
131 # strip branches
132 s=${s%:*}
133 # ensure package ends with .spec
134 s=${s%.spec}.spec
d3124c6e 135 git fetch --tags
6e820567
KK
136 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
137 --format='%(refname:short)')
5e0caa68
ER
138 echo "$s:$out"
139 done
7e37b984
ER
140}
141
3bc010e2
ER
142get-buildlog() {
143 local p=$1
144 if [ -z "$p" ]; then
145 echo >&2 "Usage: get-buildlog PACKAGE"
146 echo >&2 ""
147 echo >&2 "Grabs buildlogs from pld builder for all arch."
148 return
149 fi
150
d6f9dd1b 151 local archlist
3bc010e2
ER
152 case "$dist" in
153 ac)
d6f9dd1b 154 archlist='i686 i586 i386 athlon alpha sparc amd64 ppc'
3bc010e2
ER
155 ;;
156 th)
d6f9dd1b 157 archlist='x86_64 i486 i686'
3bc010e2
ER
158 ;;
159 *)
160 echo >&2 "get-buildlog: $dist buildlogs are /dev/null"
161 return
162 esac
163
aa1d27ff 164 local url arch path ftp=ftp://buildlogs.pld-linux.org
d6f9dd1b
ER
165 for arch in $archlist; do
166 [ "$arch" ] || continue
167 path=${url#$ftp}
168 echo -n "Checking $p.$arch... "
169 url=$(lftp -c "debug 0;open $ftp; cls --sort=date -r /$dist/$arch/OK/$p,*.bz2 /$dist/$arch/FAIL/$p,*.bz2 | tail -n1")
170 url=$ftp$url
171
172 echo -n "$url... "
173 if wget -q $url -O .$p~; then
3bc010e2 174 echo "OK"
d6f9dd1b 175 mv -f .$p~ $p.$arch.bz2
3bc010e2
ER
176 else
177 echo "SKIP"
178 rm -f .$p~
179 fi
180 done
181}
182
5e0caa68
ER
183fi # no $dist set
184
185alias cv='cvs status -v'
186alias adif="dif -x '*.m4' -x ltmain.sh -x install-sh -x depcomp -x 'Makefile.in' -x compile -x 'config.*' -x configure -x missing -x mkinstalldirs -x autom4te.cache"
187alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'"
188
7e37b984 189# makes diff from PLD CVS urls
d29ef356 190# requires: cvs, tee
7e37b984
ER
191urldiff() {
192 local url="$1"
193 if [ -z "$url" ]; then
194 echo >&2 "Reading STDIN"
195 read url
196 fi
197
198 echo >&2 "Process $url"
199 local file="$url"
200 file=${file#*SPECS/}
201 file=${file#*SOURCES/}
202 file=${file##*/}
203 local r1=${file#*r1=}
204 local r2=${r1#*r2=}
8c550ffc 205 r2=${r2%%[&;]*}
7765da19 206 r1=${r1%%[&;]*}
7e37b984 207 file=${file%\?*}
7765da19 208 file=${file%.diff}
7e37b984
ER
209
210 echo >&2 "$file: $r1 -> $r2"
79aa1413
ER
211
212 if [ -t 1 ]; then
ce56ac3b
ER
213 cvs diff -u -r$r1 -r$r2 $file | tee m.patch | diffcol
214 else
215 cvs diff -u -r$r1 -r$r2 $file
79aa1413 216 fi
7e37b984
ER
217}
218
d29ef356
ER
219# makes diff from kde svn path
220# requires: wget, tee
221kdediff() {
15a4aede 222 local url="$1" r1 r2
d29ef356
ER
223 # --- branches/KDE/3.5/kdepim/kpilot/conduits/vcalconduit/vcalRecord.cc #624744:624745
224 url=${url#*--- }
225 echo >&2 "Process $url"
226 r1=${url#*#}
227 r2=${r1#*:}
228 r1=${r1%:*}
229
230 # http://websvn.kde.org/branches/KDE/3.5/kdepim/kpilot/conduits/vcalconduit/vcalRecord.cc?rev=624745&r1=612579&r2=624745&makepatch=1&diff_format=u
397a2489 231 # http://websvn.kde.org/branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/aim/aimcontact.cpp?r1=609808&r2=673027&view=patch
d29ef356 232 url=http://websvn.kde.org/${url% *}
397a2489 233 url="$url?r1=$r1&r2=$r2&view=patch"
d29ef356
ER
234
235 if [ -t 1 ]; then
236 wget "$url" -O -| tee m.patch | diffcol
237 else
238 wget "$url" -O -
239 fi
240}
241
5e0caa68
ER
242# merges two patches
243# requires: patchutils
244pmerge() {
245 combinediff -p1 $1 $2 > m.patch || return
246 pclean m.patch
247 dif $1 m.patch
248}
249
7e37b984
ER
250# downloads sourceforge url from specific mirror
251sfget() {
252 local url="$1"
253 url="${url%?download}"
54e1e1fd
ER
254 url="${url%?use_mirror=*}"
255 url="${url#http://downloads.}"
7e37b984
ER
256 url="http://dl.${url#http://prdownloads.}"
257 # use mirror
258 local mirror="http://nchc.dl.sourceforge.net"
259 url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}"
260 wget -c "$url"
261}
262
88e7bbe5
ER
263dif() {
264 if [ -t 1 ]; then
d6f9dd1b 265 diff -ur -x .svn -x .git -x .bzr -x CVS "$@" | diffcol | less -R
88e7bbe5 266 else
d6f9dd1b 267 diff -ur -x .svn -x .git -x .bzr -x CVS "$@"
88e7bbe5
ER
268 fi
269}
270
271diffcol() {
272sed -e '
273 s,\e,\e[44m^[\e[49m,g;
274 s,\a,\e[44m^G\e[49m,g;
275 s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
276 s,^@@ ,\e[33m&,;
277 s,^-,\e[35m&,;
278 s,^+,\e[36m&,;
001e6af4 279 s,\r,\e[44m^M\e[49m,g;
88e7bbe5
ER
280 s, , ,g;
281 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
282 s,$,\e[0m,
28cd815f 283' ${1:+"$@"}
88e7bbe5 284}
6ef19b16
ER
285
286# chdir to file location and do 'cvs log'
287cvslog() {
288 local f="$1"
0db4548a
ER
289 local d="${f%/*}"
290 [ "$d" = "$f" ] && d=.
291 (builtin cd $d && cvs log ${f##*/})
6ef19b16 292}
2d0b7430 293
83744afa 294# does diff between FILE~ and FILE
924512bf 295# the diff can be applied with patch -p1
2d0b7430 296d() {
924512bf 297 local file="$1"
15a4aede 298 local dir diff
924512bf
ER
299 if [[ "$file" = /* ]]; then
300 # full path -- no idea where to strip
301 dir=.
302 diff=$file
303 else
304 # relative path -- keep one path component from current dir
305 dir=..
306 diff=${PWD##*/}/${file}
307 fi
308
309 (builtin cd "$dir"; dif $diff{~,})
2d0b7430 310}
15a4aede 311
e7a82b31 312rpmb() {
15a4aede 313 local SPEC SPECDIR arg
92037b96 314 for arg in "$@"; do
e7a82b31
TP
315 case "$arg" in
316 *.spec) SPEC="$arg"
317 ;;
318 esac
319 done
320 SPECDIR=$(dirname "$(pwd)/${SPEC:-.}")
92037b96 321 command rpmbuild --define "_specdir $SPECDIR" --define "_sourcedir $SPECDIR" "$@"
e7a82b31 322}
This page took 0.104631 seconds and 4 git commands to generate.