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