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