]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - shrc.sh
do db-devel replacement on exact match only
[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
17e8d732 4[ -n "$dist" ] || dist=$(lsb_release -sc 2>/dev/null | tr 'A-Z' 'a-z')
c8a54e84
ER
5[ -n "$dist" ] || dist=$(awk '/PLD Linux/ {print tolower($NF)}' /etc/pld-release 2>/dev/null | tr -d '()')
6
eb1eda00
ER
7alias q='rpm -q --qf "%{N}-%|E?{%{E}:}|%{V}-%{R}.%{ARCH}\n"'
8alias 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"
9alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Tylko\|Binary files\|Files\|Common\|index \|Index:\|RCS file\|retrieving\)/d'"
2e6b7800 10
eb1eda00
ER
11# undo spec utf8
12# note: it will do it blindly, so any lang other than -pl is most likely broken
13specutfundo() {
14 local spec="$1"
15 iconv -futf8 -tlatin2 "$spec" > m
16 sed -e 's/\.UTF-8//' m > "$spec"
17 rm -f m
18}
7e37b984 19
eb1eda00
ER
20# merges two patches
21# requires: patchutils
22pmerge() {
23 combinediff -p1 $1 $2 > m.patch || return
24 pclean m.patch
25 dif $1 m.patch
26}
27
28# downloads sourceforge url from specific mirror
29sfget() {
30 local url="$1"
31 url="${url%?download}"
32 url="${url%?use_mirror=*}"
33 url="${url#http://downloads.}"
34 url="http://dl.${url#http://prdownloads.}"
35 # use mirror
36 local mirror="http://nchc.dl.sourceforge.net"
37 url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}"
38 wget -c "$url"
39}
40
41dif() {
42 if [ -t 1 ]; then
43 diff -ur -x .svn -x .git -x .bzr -x CVS "$@" | diffcol | less -R
44 else
45 diff -ur -x .svn -x .git -x .bzr -x CVS "$@"
46 fi
47}
48
49diffcol() {
50sed -e '
51 s,\e,\e[44m^[\e[49m,g;
52 s,\a,\e[44m^G\e[49m,g;
53 s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
54 s,^@@ ,\e[33m&,;
55 s,^-,\e[35m&,;
56 s,^+,\e[36m&,;
57 s,\r,\e[44m^M\e[49m,g;
58 s, , ,g;
59 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
60 s,$,\e[0m,
61' ${1:+"$@"}
62}
63
64# does diff between FILE~ and FILE
65# the diff can be applied with patch -p1
66d() {
67 local file="$1" dir
68 shift
69 if [[ "$file" = /* ]]; then
70 # full path -- no idea where to strip
71 dir=.
72 diff=$file
73 else
74 # relative path -- keep one path component from current dir
75 dir=..
76 diff=${PWD##*/}/${file}
77 fi
78
79 (builtin cd "$dir"; dif $diff{~,} "$@")
80}
81
82# spec name from NVR
83rpm2spec() {
84 sed -re 's,^(.+)-[^-]+-[^-]+$,\1.spec,'
85}
2e6b7800 86
5d6ca156
ER
87# move AC-branch tag to current checkout
88# if AC-branch as branch exists, it is first removed
5d6ca156
ER
89ac-tag() {
90 # see if remote has branch present
1f4470d7 91 local branch=AC-branch
aea94aaf 92 if git show-ref -q refs/remotes/origin/$branch; then
cb59d78d 93 git fetch --tags
68a80586 94 if [ -z "$(git tag --points-at origin/$branch 2>/dev/null)" ]; then
1f4470d7
ER
95 echo >&2 "There's no tag pointing to current $branch; refusing to delete branch"
96 return 1
97 fi
7eac21d3
ER
98 # delete local branch if exists
99 git show-ref -q refs/heads/$branch && git branch -d $branch
100
101 # drop remote branch
1f4470d7 102 git push --delete origin $branch
5d6ca156
ER
103 fi
104
1f4470d7 105 git tag -f $branch
0fbec6c0 106 git push -f origin $branch
5d6ca156
ER
107}
108
eb1eda00 109###### functions/aliases below require $dist to be set ######
7e5ea5ac 110
eb1eda00
ER
111case "$dist" in
112ac|th|ti)
113 ;;
114*)
115 # invalid one ;)
116 dist=
117esac
118
119if [ -z "$dist" ]; then
120 return
121fi
122
123alias ipoldek-$dist="poldek -q --sn $dist --cmd"
124alias $dist-provides="ipoldek-$dist what-provides"
125alias $dist-verify=dist-verify
126alias $dist-requires=dist-requires
6ebe30c9 127
c48232ce
ER
128dist-requires() {
129 local opts deps
130 while [ $# -gt 0 ]; do
131 case "$1" in
132 --sn)
133 opts="$opts $1 $2"
134 shift
135 ;;
136 -*)
137 opts="$opts $1"
138 ;;
139 *)
140 deps="$deps $1"
141 ;;
142 esac
143 shift
144 done
f43b3983
ER
145
146 case "$dist" in
147 ac)
148 opts="$opts --sn=$dist-updates"
149 ;;
150 esac
151
152 poldek -q -Q --sn $dist $opts --cmd what-requires $deps
c48232ce
ER
153}
154
37ae34a0 155dist-verify() {
70d18f4d
ER
156 local args sn
157 sn="--sn $dist"
3e963c20 158
b15006fb
ER
159 case "$dist" in
160 ac)
70d18f4d
ER
161 sn="$sn --sn $dist-updates"
162
bec0be2e 163 local a ignore
eaca9a85
ER
164 # typo
165 ignore="$ignore kdenetwork-kopete-tool-conectionstatus"
25fd7f1b 166 # obsoleted
eaca9a85
ER
167 ignore="$ignore gimp-plugin-swfdec wine-drv-arts ntp-ntptrace"
168 # quake2@MAIN is now quake2forge, original quake2 restored to quake2
169 ignore="$ignore quake2-3dfx quake2-sdl quake2-sgl quake2-snd-alsa quake2-snd-ao quake2-snd-oss quake2-snd-sdl quake2-static"
25fd7f1b
ER
170 # obsoleted
171 ignore="$ignore mozilla-firefox-lang-en apache1-mod_perl-devel libyasm-static"
eb06631a
ER
172 # renamed (courier-authlib.spec, r1.54)
173 ignore="$ignore courier-authlib-userdb courier-authlib-pipe"
4876f0af
ER
174 # obsoleted, squid 2.6
175 ignore="$ignore squid-winbind_acl squid-winbind_auth"
6bf0c9cd
ER
176 # obsoleted with 1.0.4
177 ignore="$ignore python-numpy-FFT python-numpy-MA python-numpy-RNG"
a7498178
ER
178 # subpkgs renamed
179 ignore="$ignore apache1-doc apache1-index"
0e1522d9
ER
180 # obsoleted by kadu-module-mediaplayer-amarok
181 ignore="$ignore kadu-module-amarok"
182 # obsoleted by kadu-module-mediaplayer-xmms
183 ignore="$ignore kadu-module-xmms"
184 # obsoleted by kadu 0.6.0
92a62be8 185 ignore="$ignore kadu-theme-icons-crystal16 kadu-theme-icons-crystal22 kadu-theme-icons-nuvola16 kadu-theme-icons-nuvola22 kadu-module-iwait4u"
c937c6db
ER
186 # obsoleted pear test packages
187 ignore="$ignore php-*-tests"
0ead02ef
ER
188 # obsoleted
189 ignore="$ignore nmap-X11"
190 # mksd dependency not distributale
191 ignore="$ignore samba-vfs-vscan-mks"
192 # ibbackup is not distributale
193 ignore="$ignore innobackup"
3373d30b
ER
194 # use ac-updates
195 ignore="$ignore ntp-client ntp"
54c11aa2
ER
196 # php4 only(php-pecl-tidy), for php<5.2(php-pecl-filter)
197 ignore="$ignore php-pecl-tidy php-pecl-filter"
0ead02ef 198
3e963c20
ER
199 # renamed to vim-syntax-txt2tags
200 ignore="$ignore txt2tags-vim"
0ead02ef 201
bec0be2e 202 for a in $ignore; do
eaca9a85
ER
203 args="$args --ignore=$a"
204 done
b15006fb
ER
205 ;;
206 esac
207
70d18f4d 208 poldek $sn --up --upa -q "$@"
6bf0c9cd 209 poldek $sn --uniq --noignore --verify=deps $args "$@"
2e6b7800 210}
a5ab8a8f 211
5e0caa68
ER
212# displays latest used tag for a specfile
213autotag() {
286a9a85
ER
214 local out s
215 for s in "$@"; do
216 # strip branches
217 s=${s%:*}
218 # ensure package ends with .spec
219 s=${s%.spec}.spec
d3124c6e 220 git fetch --tags
6e820567
KK
221 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
222 --format='%(refname:short)')
5e0caa68
ER
223 echo "$s:$out"
224 done
7e37b984
ER
225}
226
3bc010e2
ER
227get-buildlog() {
228 local p=$1
229 if [ -z "$p" ]; then
230 echo >&2 "Usage: get-buildlog PACKAGE"
231 echo >&2 ""
232 echo >&2 "Grabs buildlogs from pld builder for all arch."
233 return
234 fi
235
d6f9dd1b 236 local archlist
3bc010e2
ER
237 case "$dist" in
238 ac)
d6f9dd1b 239 archlist='i686 i586 i386 athlon alpha sparc amd64 ppc'
3bc010e2
ER
240 ;;
241 th)
d6f9dd1b 242 archlist='x86_64 i486 i686'
3bc010e2
ER
243 ;;
244 *)
245 echo >&2 "get-buildlog: $dist buildlogs are /dev/null"
246 return
247 esac
248
aa1d27ff 249 local url arch path ftp=ftp://buildlogs.pld-linux.org
d6f9dd1b
ER
250 for arch in $archlist; do
251 [ "$arch" ] || continue
252 path=${url#$ftp}
253 echo -n "Checking $p.$arch... "
254 url=$(lftp -c "debug 0;open $ftp; cls --sort=date -r /$dist/$arch/OK/$p,*.bz2 /$dist/$arch/FAIL/$p,*.bz2 | tail -n1")
255 url=$ftp$url
256
257 echo -n "$url... "
258 if wget -q $url -O .$p~; then
3bc010e2 259 echo "OK"
d6f9dd1b 260 mv -f .$p~ $p.$arch.bz2
3bc010e2
ER
261 else
262 echo "SKIP"
263 rm -f .$p~
264 fi
265 done
266}
267
This page took 0.085865 seconds and 4 git commands to generate.