]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - shrc.sh
Make sure readable file is uploaded.
[packages/rpm-build-tools.git] / shrc.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
5d6ca156
ER
23ac-tag() {
24 # see if remote has branch present
1f4470d7 25 local branch=AC-branch
aea94aaf 26 if git show-ref -q refs/remotes/origin/$branch; then
cb59d78d 27 git fetch --tags
68a80586 28 if [ -z "$(git tag --points-at origin/$branch 2>/dev/null)" ]; then
1f4470d7
ER
29 echo >&2 "There's no tag pointing to current $branch; refusing to delete branch"
30 return 1
31 fi
7eac21d3
ER
32 # delete local branch if exists
33 git show-ref -q refs/heads/$branch && git branch -d $branch
34
35 # drop remote branch
1f4470d7 36 git push --delete origin $branch
5d6ca156
ER
37 fi
38
1f4470d7 39 git tag -f $branch
0fbec6c0 40 git push -f origin $branch
5d6ca156
ER
41}
42
6ebe30c9
ER
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
c48232ce
ER
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
f43b3983
ER
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
c48232ce
ER
77}
78
37ae34a0 79dist-verify() {
70d18f4d
ER
80 local args sn
81 sn="--sn $dist"
3e963c20 82
b15006fb
ER
83 case "$dist" in
84 ac)
70d18f4d
ER
85 sn="$sn --sn $dist-updates"
86
bec0be2e 87 local a ignore
eaca9a85
ER
88 # typo
89 ignore="$ignore kdenetwork-kopete-tool-conectionstatus"
25fd7f1b 90 # obsoleted
eaca9a85
ER
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"
25fd7f1b
ER
94 # obsoleted
95 ignore="$ignore mozilla-firefox-lang-en apache1-mod_perl-devel libyasm-static"
eb06631a
ER
96 # renamed (courier-authlib.spec, r1.54)
97 ignore="$ignore courier-authlib-userdb courier-authlib-pipe"
4876f0af
ER
98 # obsoleted, squid 2.6
99 ignore="$ignore squid-winbind_acl squid-winbind_auth"
6bf0c9cd
ER
100 # obsoleted with 1.0.4
101 ignore="$ignore python-numpy-FFT python-numpy-MA python-numpy-RNG"
a7498178
ER
102 # subpkgs renamed
103 ignore="$ignore apache1-doc apache1-index"
0e1522d9
ER
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
92a62be8 109 ignore="$ignore kadu-theme-icons-crystal16 kadu-theme-icons-crystal22 kadu-theme-icons-nuvola16 kadu-theme-icons-nuvola22 kadu-module-iwait4u"
c937c6db
ER
110 # obsoleted pear test packages
111 ignore="$ignore php-*-tests"
0ead02ef
ER
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"
3373d30b
ER
118 # use ac-updates
119 ignore="$ignore ntp-client ntp"
54c11aa2
ER
120 # php4 only(php-pecl-tidy), for php<5.2(php-pecl-filter)
121 ignore="$ignore php-pecl-tidy php-pecl-filter"
0ead02ef 122
3e963c20
ER
123 # renamed to vim-syntax-txt2tags
124 ignore="$ignore txt2tags-vim"
0ead02ef 125
bec0be2e 126 for a in $ignore; do
eaca9a85
ER
127 args="$args --ignore=$a"
128 done
b15006fb
ER
129 ;;
130 esac
131
70d18f4d 132 poldek $sn --up --upa -q "$@"
6bf0c9cd 133 poldek $sn --uniq --noignore --verify=deps $args "$@"
2e6b7800 134}
a5ab8a8f 135
5e0caa68
ER
136# displays latest used tag for a specfile
137autotag() {
286a9a85
ER
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
d3124c6e 144 git fetch --tags
6e820567
KK
145 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
146 --format='%(refname:short)')
5e0caa68
ER
147 echo "$s:$out"
148 done
7e37b984
ER
149}
150
3bc010e2
ER
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
d6f9dd1b 160 local archlist
3bc010e2
ER
161 case "$dist" in
162 ac)
d6f9dd1b 163 archlist='i686 i586 i386 athlon alpha sparc amd64 ppc'
3bc010e2
ER
164 ;;
165 th)
d6f9dd1b 166 archlist='x86_64 i486 i686'
3bc010e2
ER
167 ;;
168 *)
169 echo >&2 "get-buildlog: $dist buildlogs are /dev/null"
170 return
171 esac
172
aa1d27ff 173 local url arch path ftp=ftp://buildlogs.pld-linux.org
d6f9dd1b
ER
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
3bc010e2 183 echo "OK"
d6f9dd1b 184 mv -f .$p~ $p.$arch.bz2
3bc010e2
ER
185 else
186 echo "SKIP"
187 rm -f .$p~
188 fi
189 done
190}
191
5e0caa68
ER
192fi # no $dist set
193
5e0caa68 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"
5943c926 195alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Tylko\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'"
5e0caa68 196
7e37b984 197# makes diff from PLD CVS urls
d29ef356 198# requires: cvs, tee
7e37b984
ER
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=}
8c550ffc 213 r2=${r2%%[&;]*}
7765da19 214 r1=${r1%%[&;]*}
7e37b984 215 file=${file%\?*}
7765da19 216 file=${file%.diff}
7e37b984
ER
217
218 echo >&2 "$file: $r1 -> $r2"
79aa1413
ER
219
220 if [ -t 1 ]; then
ce56ac3b
ER
221 cvs diff -u -r$r1 -r$r2 $file | tee m.patch | diffcol
222 else
223 cvs diff -u -r$r1 -r$r2 $file
79aa1413 224 fi
7e37b984
ER
225}
226
d29ef356
ER
227# makes diff from kde svn path
228# requires: wget, tee
229kdediff() {
15a4aede 230 local url="$1" r1 r2
d29ef356
ER
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
397a2489 239 # http://websvn.kde.org/branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/aim/aimcontact.cpp?r1=609808&r2=673027&view=patch
d29ef356 240 url=http://websvn.kde.org/${url% *}
397a2489 241 url="$url?r1=$r1&r2=$r2&view=patch"
d29ef356
ER
242
243 if [ -t 1 ]; then
244 wget "$url" -O -| tee m.patch | diffcol
245 else
246 wget "$url" -O -
247 fi
248}
249
5e0caa68
ER
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
7e37b984
ER
258# downloads sourceforge url from specific mirror
259sfget() {
260 local url="$1"
261 url="${url%?download}"
54e1e1fd
ER
262 url="${url%?use_mirror=*}"
263 url="${url#http://downloads.}"
7e37b984
ER
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
88e7bbe5
ER
271dif() {
272 if [ -t 1 ]; then
d6f9dd1b 273 diff -ur -x .svn -x .git -x .bzr -x CVS "$@" | diffcol | less -R
88e7bbe5 274 else
d6f9dd1b 275 diff -ur -x .svn -x .git -x .bzr -x CVS "$@"
88e7bbe5
ER
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&,;
001e6af4 287 s,\r,\e[44m^M\e[49m,g;
88e7bbe5
ER
288 s, , ,g;
289 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
290 s,$,\e[0m,
28cd815f 291' ${1:+"$@"}
88e7bbe5 292}
6ef19b16 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
db7f9310
ER
312# spec name from NVR
313rpm2spec() {
314 sed -re 's,^(.+)-[^-]+-[^-]+$,\1.spec,'
315}
316
e7a82b31 317rpmb() {
15a4aede 318 local SPEC SPECDIR arg
92037b96 319 for arg in "$@"; do
e7a82b31
TP
320 case "$arg" in
321 *.spec) SPEC="$arg"
322 ;;
323 esac
324 done
325 SPECDIR=$(dirname "$(pwd)/${SPEC:-.}")
92037b96 326 command rpmbuild --define "_specdir $SPECDIR" --define "_sourcedir $SPECDIR" "$@"
e7a82b31 327}
This page took 0.076083 seconds and 4 git commands to generate.