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