]>
Commit | Line | Data |
---|---|---|
1 | # shell aliases and functions for PLD Developer | |
2 | # $Id$ | |
3 | ||
4 | # set $dist, used by functions below | |
5 | [ -n "$dist" ] || dist=$(awk '/PLD Linux/ {print tolower($NF)}' /etc/pld-release 2>/dev/null | tr -d '()') | |
6 | ||
7 | case "$dist" in | |
8 | ac|th|ti) | |
9 | ;; | |
10 | *) | |
11 | # invalid one ;) | |
12 | dist= | |
13 | esac | |
14 | ||
15 | if [ "$dist" ]; then | |
16 | ||
17 | alias ipoldek-$dist="poldek -q --sn $dist --cmd" | |
18 | alias $dist-provides="ipoldek-$dist what-provides" | |
19 | alias $dist-tag="./builder -cf -T $(echo $dist | tr '[a-z]' '[A-Z]')-branch -r HEAD" | |
20 | alias $dist-verify=dist-verify | |
21 | alias $dist-requires=dist-requires | |
22 | ||
23 | # undo spec utf8 | |
24 | # note: it will do it blindly, so any lang other than -pl is most likely broken | |
25 | specutfundo() { | |
26 | local spec="$1" | |
27 | iconv -futf8 -tlatin2 "$spec" > m | |
28 | sed -e 's/\.UTF-8//' m > "$spec" | |
29 | rm -f m | |
30 | } | |
31 | ||
32 | dist-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 | |
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 | |
57 | } | |
58 | ||
59 | dist-verify() { | |
60 | local args sn | |
61 | sn="--sn $dist" | |
62 | case "$dist" in | |
63 | ac) | |
64 | sn="$sn --sn $dist-updates" | |
65 | ||
66 | local a ignore | |
67 | # typo | |
68 | ignore="$ignore kdenetwork-kopete-tool-conectionstatus" | |
69 | # obsoleted | |
70 | ignore="$ignore gimp-plugin-swfdec wine-drv-arts ntp-ntptrace" | |
71 | # quake2@MAIN is now quake2forge, original quake2 restored to quake2 | |
72 | ignore="$ignore quake2-3dfx quake2-sdl quake2-sgl quake2-snd-alsa quake2-snd-ao quake2-snd-oss quake2-snd-sdl quake2-static" | |
73 | # obsoleted | |
74 | ignore="$ignore mozilla-firefox-lang-en apache1-mod_perl-devel libyasm-static" | |
75 | # renamed (courier-authlib.spec, r1.54) | |
76 | ignore="$ignore courier-authlib-userdb courier-authlib-pipe" | |
77 | # obsoleted, squid 2.6 | |
78 | ignore="$ignore squid-winbind_acl squid-winbind_auth" | |
79 | # obsoleted with 1.0.4 | |
80 | ignore="$ignore python-numpy-FFT python-numpy-MA python-numpy-RNG" | |
81 | # subpkgs renamed | |
82 | ignore="$ignore apache1-doc apache1-index" | |
83 | # obsoleted by kadu-module-mediaplayer-amarok | |
84 | ignore="$ignore kadu-module-amarok" | |
85 | # obsoleted by kadu-module-mediaplayer-xmms | |
86 | ignore="$ignore kadu-module-xmms" | |
87 | # obsoleted by kadu 0.6.0 | |
88 | ignore="$ignore kadu-theme-icons-crystal16 kadu-theme-icons-crystal22 kadu-theme-icons-nuvola16 kadu-theme-icons-nuvola22 kadu-module-iwait4u" | |
89 | # obsoleted | |
90 | ignore="$ignore php-pear-Net_Ping-tests" | |
91 | for a in $ignore; do | |
92 | args="$args --ignore=$a" | |
93 | done | |
94 | ;; | |
95 | esac | |
96 | ||
97 | poldek $sn --up --upa -q "$@" | |
98 | poldek $sn --uniq --noignore --verify=deps $args "$@" | |
99 | } | |
100 | ||
101 | # displays latest used tag for a specfile | |
102 | autotag() { | |
103 | local out | |
104 | for a in "$@"; do | |
105 | s=${a%.spec}.spec | |
106 | out=$(cvs status -v $s | awk "!/Sticky/&&/auto-$dist-/{if (!a++) print \$1}") | |
107 | echo "$s:$out" | |
108 | done | |
109 | } | |
110 | ||
111 | fi # no $dist set | |
112 | ||
113 | alias cv='cvs status -v' | |
114 | 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" | |
115 | alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'" | |
116 | ||
117 | # makes diff from PLD CVS urls | |
118 | # requires: cvs, tee | |
119 | urldiff() { | |
120 | local url="$1" | |
121 | if [ -z "$url" ]; then | |
122 | echo >&2 "Reading STDIN" | |
123 | read url | |
124 | fi | |
125 | ||
126 | echo >&2 "Process $url" | |
127 | local file="$url" | |
128 | file=${file#*SPECS/} | |
129 | file=${file#*SOURCES/} | |
130 | file=${file##*/} | |
131 | local r1=${file#*r1=} | |
132 | local r2=${r1#*r2=} | |
133 | r2=${r2%%[&;]*} | |
134 | r1=${r1%%[&;]*} | |
135 | file=${file%\?*} | |
136 | file=${file%.diff} | |
137 | ||
138 | echo >&2 "$file: $r1 -> $r2" | |
139 | ||
140 | if [ -t 1 ]; then | |
141 | cvs diff -u -r$r1 -r$r2 $file | tee m.patch | diffcol | |
142 | else | |
143 | cvs diff -u -r$r1 -r$r2 $file | |
144 | fi | |
145 | } | |
146 | ||
147 | # makes diff from kde svn path | |
148 | # requires: wget, tee | |
149 | kdediff() { | |
150 | local url="$1" | |
151 | # --- branches/KDE/3.5/kdepim/kpilot/conduits/vcalconduit/vcalRecord.cc #624744:624745 | |
152 | url=${url#*--- } | |
153 | echo >&2 "Process $url" | |
154 | r1=${url#*#} | |
155 | r2=${r1#*:} | |
156 | r1=${r1%:*} | |
157 | ||
158 | # http://websvn.kde.org/branches/KDE/3.5/kdepim/kpilot/conduits/vcalconduit/vcalRecord.cc?rev=624745&r1=612579&r2=624745&makepatch=1&diff_format=u | |
159 | # http://websvn.kde.org/branches/KDE/3.5/kdenetwork/kopete/protocols/oscar/aim/aimcontact.cpp?r1=609808&r2=673027&view=patch | |
160 | url=http://websvn.kde.org/${url% *} | |
161 | url="$url?r1=$r1&r2=$r2&view=patch" | |
162 | ||
163 | if [ -t 1 ]; then | |
164 | wget "$url" -O -| tee m.patch | diffcol | |
165 | else | |
166 | wget "$url" -O - | |
167 | fi | |
168 | } | |
169 | ||
170 | # merges two patches | |
171 | # requires: patchutils | |
172 | pmerge() { | |
173 | combinediff -p1 $1 $2 > m.patch || return | |
174 | pclean m.patch | |
175 | dif $1 m.patch | |
176 | } | |
177 | ||
178 | # downloads sourceforge url from specific mirror | |
179 | sfget() { | |
180 | local url="$1" | |
181 | url="${url%?download}" | |
182 | url="${url%?use_mirror=*}" | |
183 | url="${url#http://downloads.}" | |
184 | url="http://dl.${url#http://prdownloads.}" | |
185 | # use mirror | |
186 | local mirror="http://nchc.dl.sourceforge.net" | |
187 | url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}" | |
188 | wget -c "$url" | |
189 | } | |
190 | ||
191 | dif() { | |
192 | if [ -t 1 ]; then | |
193 | diff -ur "$@" | diffcol | less -R | |
194 | else | |
195 | diff -ur "$@" | |
196 | fi | |
197 | } | |
198 | ||
199 | diffcol() { | |
200 | sed -e ' | |
201 | s,\e,\e[44m^[\e[49m,g; | |
202 | s,\a,\e[44m^G\e[49m,g; | |
203 | s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,; | |
204 | s,^@@ ,\e[33m&,; | |
205 | s,^-,\e[35m&,; | |
206 | s,^+,\e[36m&,; | |
207 | s,\r,\e[44m^M\e[49m,g; | |
208 | s, , ,g; | |
209 | s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g; | |
210 | s,$,\e[0m, | |
211 | ' "$@" | |
212 | } | |
213 | ||
214 | # chdir to file location and do 'cvs log' | |
215 | cvslog() { | |
216 | local f="$1" | |
217 | local d="${f%/*}" | |
218 | [ "$d" = "$f" ] && d=. | |
219 | (builtin cd $d && cvs log ${f##*/}) | |
220 | } | |
221 | ||
222 | # does diff between FILE and FILE~ | |
223 | # the diff can be applied with patch -p1 | |
224 | d() { | |
225 | local file="$1" | |
226 | local dir | |
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{~,}) | |
238 | } |