]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - rpm-build.sh
- more sf url formats supported
[packages/rpm-build-tools.git] / rpm-build.sh
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)
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-requires="ipoldek-$dist what-requires"
19 alias $dist-provides="ipoldek-$dist what-provides"
20 alias $dist-tag="./builder -cf -T $(echo $dist | tr '[a-z]' '[A-Z]')-branch -r HEAD"
21 alias $dist-verify=dist-verify
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-verify() {
33         poldek --sn $dist --sn $dist-ready --sn $dist-updates --up
34         poldek --sn $dist --sn $dist-ready --sn $dist-updates --noignore --verify=deps "$@"
35 }
36
37 # displays latest used tag for a specfile
38 autotag() {
39         local out
40         for a in "$@"; do
41                 s=${a%.spec}.spec
42                 out=$(cvs status -v $s | awk "/auto-$dist-/{if (!a++) print \$1}")
43                 echo "$s:$out"
44         done
45 }
46
47 fi # no $dist set
48
49 alias cv='cvs status -v'
50 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"
51 alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'"
52
53 # makes diff from PLD CVS urls
54 # requires: cvs, tee
55 urldiff() {
56         local url="$1"
57         if [ -z "$url" ]; then
58                 echo >&2 "Reading STDIN"
59                 read url
60         fi
61
62         echo >&2 "Process $url"
63         local file="$url"
64         file=${file#*SPECS/}
65         file=${file#*SOURCES/}
66         file=${file##*/}
67         local r1=${file#*r1=}
68         local r2=${r1#*r2=}
69         r2=${r2%%[&;]*}
70         r1=${r1%%[&;]*}
71         file=${file%\?*}
72         file=${file%.diff}
73
74         echo >&2 "$file: $r1 -> $r2"
75
76         if [ -t 1 ]; then
77                 cvs diff -u -r$r1 -r$r2 $file | tee m.patch | diffcol
78         else
79                 cvs diff -u -r$r1 -r$r2 $file
80         fi
81 }
82
83 # makes diff from kde svn path
84 # requires: wget, tee
85 kdediff() {
86         local url="$1"
87         # --- branches/KDE/3.5/kdepim/kpilot/conduits/vcalconduit/vcalRecord.cc #624744:624745
88         url=${url#*--- }
89         echo >&2 "Process $url"
90         r1=${url#*#}
91         r2=${r1#*:}
92         r1=${r1%:*}
93
94         #  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
95         url=http://websvn.kde.org/${url% *}
96         url="$url?r1=$r1&r2=$r2&makepatch=1&diff_format=u"
97
98         if [ -t 1 ]; then
99                 wget "$url" -O -| tee m.patch | diffcol
100         else
101                 wget "$url" -O -
102         fi
103 }
104
105 # merges two patches
106 # requires: patchutils
107 pmerge() {
108         combinediff -p1 $1 $2 > m.patch || return
109         pclean m.patch
110         dif $1 m.patch
111 }
112
113 # downloads sourceforge url from specific mirror
114 sfget() {
115         local url="$1"
116         url="${url%?download}"
117         url="${url%?use_mirror=*}"
118         url="${url#http://downloads.}"
119         url="http://dl.${url#http://prdownloads.}"
120         # use mirror
121         local mirror="http://nchc.dl.sourceforge.net"
122         url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}"
123         wget -c "$url"
124 }
125
126 dif() {
127         if [ -t 1 ]; then
128                 diff -ur "$@" | diffcol | less -R
129         else
130                 diff -ur "$@"
131         fi
132 }
133
134 diffcol() {
135 sed -e '
136         s,\e,\e[44m^[\e[49m,g;
137         s,\a,\e[44m^G\e[49m,g;
138         s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
139         s,^@@ ,\e[33m&,;
140         s,^-,\e[35m&,;
141         s,^+,\e[36m&,;
142         s,\r,\e[44m^M\e[49m,g;
143         s,      ,    ,g;
144         s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
145         s,$,\e[0m,
146 ' "$@"
147 }
148
149 # chdir to file location and do 'cvs log'
150 cvslog() {
151         local f="$1"
152         local d="${f%/*}"
153         [ "$d" = "$f" ] && d=.
154         (builtin cd $d && cvs log ${f##*/})
155 }
156
157 # does diff between FILE and FILE~
158 # the diff can be applied with patch -p1
159 d() {
160         local file="$1"
161         local dir
162         if [[ "$file" = /* ]]; then
163                 # full path -- no idea where to strip
164                 dir=.
165                 diff=$file
166         else
167                 # relative path -- keep one path component from current dir
168                 dir=..
169                 diff=${PWD##*/}/${file}
170         fi
171
172         (builtin cd "$dir"; dif $diff{~,})
173 }
This page took 0.044613 seconds and 3 git commands to generate.