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