]> git.pld-linux.org Git - packages/rpm-pld-macros.git/blame - rpm-build.sh
add q alias
[packages/rpm-pld-macros.git] / rpm-build.sh
CommitLineData
c8e059d2
ER
1# shell aliases and functions for PLD Developer
2
6fe6a2a4 3# set $dist, used by functions below
5c2093ec
ER
4[ -n "$dist" ] || dist=$(awk '/PLD Linux/ {print tolower($NF)}' /etc/pld-release 2>/dev/null | tr -d '()')
5
6case "$dist" in
11e54cf5 7ac|th|ti)
5c2093ec
ER
8 ;;
9*)
10 # invalid one ;)
11 dist=
12esac
6fe6a2a4 13
e85b9743 14if [ "$dist" ]; then
c8e059d2 15
289dcc48 16alias ipoldek-$dist="poldek -q --sn $dist --cmd"
289dcc48 17alias $dist-provides="ipoldek-$dist what-provides"
6fe6a2a4
ER
18alias $dist-tag="./builder -cf -T $(echo $dist | tr '[a-z]' '[A-Z]')-branch -r HEAD"
19alias $dist-verify=dist-verify
2ff8f00f 20alias $dist-requires=dist-requires
6fe6a2a4 21
74d337fc
ER
22alias q='rpm -q --qf "%{N}-%|E?{%{E}:}|%{V}-%{R}.%{ARCH}\n"'
23
e847eeee
ER
24# undo spec utf8
25# note: it will do it blindly, so any lang other than -pl is most likely broken
26specutfundo() {
27 local spec="$1"
28 iconv -futf8 -tlatin2 "$spec" > m
29 sed -e 's/\.UTF-8//' m > "$spec"
30 rm -f m
31}
32
2ff8f00f
ER
33dist-requires() {
34 local opts deps
35 while [ $# -gt 0 ]; do
36 case "$1" in
37 --sn)
38 opts="$opts $1 $2"
39 shift
40 ;;
41 -*)
42 opts="$opts $1"
43 ;;
44 *)
45 deps="$deps $1"
46 ;;
47 esac
48 shift
49 done
42247974
ER
50
51 case "$dist" in
52 ac)
53 opts="$opts --sn=$dist-updates"
54 ;;
55 esac
56
57 poldek -q -Q --sn $dist $opts --cmd what-requires $deps
2ff8f00f
ER
58}
59
d2023b7e 60dist-verify() {
c7cc2f51
ER
61 local args sn
62 sn="--sn $dist"
9b29c511 63
170b0c4e
ER
64 case "$dist" in
65 ac)
c7cc2f51
ER
66 sn="$sn --sn $dist-updates"
67
1b711b9b 68 local a ignore
89154c5e
ER
69 # typo
70 ignore="$ignore kdenetwork-kopete-tool-conectionstatus"
dfc86fae 71 # obsoleted
89154c5e
ER
72 ignore="$ignore gimp-plugin-swfdec wine-drv-arts ntp-ntptrace"
73 # quake2@MAIN is now quake2forge, original quake2 restored to quake2
74 ignore="$ignore quake2-3dfx quake2-sdl quake2-sgl quake2-snd-alsa quake2-snd-ao quake2-snd-oss quake2-snd-sdl quake2-static"
dfc86fae
ER
75 # obsoleted
76 ignore="$ignore mozilla-firefox-lang-en apache1-mod_perl-devel libyasm-static"
85aaae49
ER
77 # renamed (courier-authlib.spec, r1.54)
78 ignore="$ignore courier-authlib-userdb courier-authlib-pipe"
e9d3e2d8
ER
79 # obsoleted, squid 2.6
80 ignore="$ignore squid-winbind_acl squid-winbind_auth"
244bbad5
ER
81 # obsoleted with 1.0.4
82 ignore="$ignore python-numpy-FFT python-numpy-MA python-numpy-RNG"
6ef2e403
ER
83 # subpkgs renamed
84 ignore="$ignore apache1-doc apache1-index"
6907d101
ER
85 # obsoleted by kadu-module-mediaplayer-amarok
86 ignore="$ignore kadu-module-amarok"
87 # obsoleted by kadu-module-mediaplayer-xmms
88 ignore="$ignore kadu-module-xmms"
89 # obsoleted by kadu 0.6.0
60b0bd8e 90 ignore="$ignore kadu-theme-icons-crystal16 kadu-theme-icons-crystal22 kadu-theme-icons-nuvola16 kadu-theme-icons-nuvola22 kadu-module-iwait4u"
aa114e03
ER
91 # obsoleted pear test packages
92 ignore="$ignore php-*-tests"
58d9cf15
ER
93 # obsoleted
94 ignore="$ignore nmap-X11"
95 # mksd dependency not distributale
96 ignore="$ignore samba-vfs-vscan-mks"
97 # ibbackup is not distributale
98 ignore="$ignore innobackup"
b7123842
ER
99 # use ac-updates
100 ignore="$ignore ntp-client ntp"
99fac578
ER
101 # php4 only(php-pecl-tidy), for php<5.2(php-pecl-filter)
102 ignore="$ignore php-pecl-tidy php-pecl-filter"
58d9cf15 103
9b29c511
ER
104 # renamed to vim-syntax-txt2tags
105 ignore="$ignore txt2tags-vim"
58d9cf15 106
1b711b9b 107 for a in $ignore; do
89154c5e
ER
108 args="$args --ignore=$a"
109 done
170b0c4e
ER
110 ;;
111 esac
112
c7cc2f51 113 poldek $sn --up --upa -q "$@"
244bbad5 114 poldek $sn --uniq --noignore --verify=deps $args "$@"
6fe6a2a4 115}
8a437893 116
e85b9743
ER
117# displays latest used tag for a specfile
118autotag() {
8fe80bb5
ER
119 local out s
120 for s in "$@"; do
121 # strip branches
122 s=${s%:*}
123 # ensure package ends with .spec
124 s=${s%.spec}.spec
39da278c 125 git fetch --tags
b425fbbb
KK
126 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
127 --format='%(refname:short)')
e85b9743
ER
128 echo "$s:$out"
129 done
c8e059d2
ER
130}
131
80a3ce11
ER
132get-buildlog() {
133 local p=$1
134 if [ -z "$p" ]; then
135 echo >&2 "Usage: get-buildlog PACKAGE"
136 echo >&2 ""
137 echo >&2 "Grabs buildlogs from pld builder for all arch."
138 return
139 fi
140
6acf1a17 141 local archlist
80a3ce11
ER
142 case "$dist" in
143 ac)
6acf1a17 144 archlist='i686 i586 i386 athlon alpha sparc amd64 ppc'
80a3ce11
ER
145 ;;
146 th)
6acf1a17 147 archlist='x86_64 i486 i686'
80a3ce11
ER
148 ;;
149 *)
150 echo >&2 "get-buildlog: $dist buildlogs are /dev/null"
151 return
152 esac
153
b45b491a 154 local url arch path ftp=ftp://buildlogs.pld-linux.org
6acf1a17
ER
155 for arch in $archlist; do
156 [ "$arch" ] || continue
157 path=${url#$ftp}
158 echo -n "Checking $p.$arch... "
159 url=$(lftp -c "debug 0;open $ftp; cls --sort=date -r /$dist/$arch/OK/$p,*.bz2 /$dist/$arch/FAIL/$p,*.bz2 | tail -n1")
160 url=$ftp$url
161
162 echo -n "$url... "
163 if wget -q $url -O .$p~; then
80a3ce11 164 echo "OK"
6acf1a17 165 mv -f .$p~ $p.$arch.bz2
80a3ce11
ER
166 else
167 echo "SKIP"
168 rm -f .$p~
169 fi
170 done
171}
172
e85b9743
ER
173fi # no $dist set
174
e85b9743
ER
175alias 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"
176alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'"
177
e85b9743
ER
178# merges two patches
179# requires: patchutils
180pmerge() {
181 combinediff -p1 $1 $2 > m.patch || return
182 pclean m.patch
183 dif $1 m.patch
184}
185
c8e059d2
ER
186# downloads sourceforge url from specific mirror
187sfget() {
188 local url="$1"
189 url="${url%?download}"
8ba44595
ER
190 url="${url%?use_mirror=*}"
191 url="${url#http://downloads.}"
c8e059d2
ER
192 url="http://dl.${url#http://prdownloads.}"
193 # use mirror
194 local mirror="http://nchc.dl.sourceforge.net"
195 url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}"
196 wget -c "$url"
197}
198
aa560f74
ER
199dif() {
200 if [ -t 1 ]; then
6acf1a17 201 diff -ur -x .svn -x .git -x .bzr -x CVS "$@" | diffcol | less -R
aa560f74 202 else
6acf1a17 203 diff -ur -x .svn -x .git -x .bzr -x CVS "$@"
aa560f74
ER
204 fi
205}
206
207diffcol() {
208sed -e '
209 s,\e,\e[44m^[\e[49m,g;
210 s,\a,\e[44m^G\e[49m,g;
211 s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
212 s,^@@ ,\e[33m&,;
213 s,^-,\e[35m&,;
214 s,^+,\e[36m&,;
22aa10d1 215 s,\r,\e[44m^M\e[49m,g;
aa560f74
ER
216 s, , ,g;
217 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
218 s,$,\e[0m,
f16cde9f 219' ${1:+"$@"}
aa560f74 220}
bb13b717 221
25a7905e 222# does diff between FILE~ and FILE
524e21d9 223# the diff can be applied with patch -p1
ed1023ef 224d() {
524e21d9 225 local file="$1"
3ae49993 226 local dir diff
524e21d9
ER
227 if [[ "$file" = /* ]]; then
228 # full path -- no idea where to strip
229 dir=.
230 diff=$file
231 else
232 # relative path -- keep one path component from current dir
233 dir=..
234 diff=${PWD##*/}/${file}
235 fi
236
237 (builtin cd "$dir"; dif $diff{~,})
ed1023ef 238}
This page took 0.0602 seconds and 4 git commands to generate.