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