]> git.pld-linux.org Git - packages/rpm-pld-macros.git/blob - rpm-build.sh
- use also $dist in alias names
[packages/rpm-pld-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 '{print tolower($NF)}' /etc/pld-release 2>/dev/null | tr -d '()')
6
7 alias cv='cvs status -v'
8 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"
9 alias pclean="sed -i~ -e '/^\(?\|=\+$\|unchanged:\|diff\|only\|Only\|Files\|Common\|Index:\|RCS file\|retrieving\)/d'"
10
11 alias $dist="poldek -q --sn $dist --cmd"
12 alias $dist-requires="$dist what-requires"
13 alias $dist-provides="$dist what-provides"
14 alias $dist-tag="./builder -cf -T $(echo $dist | tr '[a-z]' '[A-Z]')-branch -r HEAD"
15 alias $dist-verify=dist-verify
16
17 function dist-verify() {
18         poldek --sn $dist --sn $dist-ready --up
19         poldek --sn $dist --sn $dist-ready --verify=deps
20 }
21
22 # merges two patches
23 # requires: patchutils
24 pmerge() {
25         combinediff -p1 $1 $2 > m.patch || return
26         pclean m.patch
27         dif $1 m.patch
28 }
29
30 # makes diff from PLD CVS urls
31 urldiff() {
32         local url="$1"
33         if [ -z "$url" ]; then
34                 echo >&2 "Reading STDIN"
35                 read url
36         fi
37
38         echo >&2 "Process $url"
39         local file="$url"
40         file=${file#*SPECS/}
41         file=${file#*SOURCES/}
42         file=${file##*/}
43         local r1=${file#*r1=}
44         local r2=${r1#*r2=}
45         r2=${r2%[&;]*}
46         r1=${r1%%[&;]*}
47         file=${file%\?*}
48         file=${file%.diff}
49
50         echo >&2 "$file: $r1 -> $r2"
51
52         if [ -t 1 ]; then
53                 cvs diff -u -r$r1 -r$r2 $file | tee m.patch | diffcol
54         else
55                 cvs diff -u -r$r1 -r$r2 $file
56         fi
57 }
58
59 # downloads sourceforge url from specific mirror
60 sfget() {
61         local url="$1"
62         url="${url%?download}"
63         url="http://dl.${url#http://prdownloads.}"
64         # use mirror
65         local mirror="http://nchc.dl.sourceforge.net"
66         url="$mirror/sourceforge/${url#http://dl.sourceforge.net/}"
67         wget -c "$url"
68 }
69
70 # displays latest used tag for a specfile
71 autotag() {
72         local out
73         for a in "$@"; do
74                 s=${a%.spec}.spec
75                 out=$(cvs status -v $s | awk "/auto-$distro-/{if (!a++) print \$1}")
76                 echo "$s:$out"
77         done
78 }
79
80 dif() {
81         if [ -t 1 ]; then
82                 diff -ur "$@" | diffcol | less -R
83         else
84                 diff -ur "$@"
85         fi
86 }
87
88 diffcol() {
89 sed -e '
90         s,\e,\e[44m^[\e[49m,g;
91         s,\a,\e[44m^G\e[49m,g;
92         s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
93         s,^@@ ,\e[33m&,;
94         s,^-,\e[35m&,;
95         s,^+,\e[36m&,;
96         s,\r,\e[44m^M\e[49m,g;
97         s,      ,    ,g;
98         s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
99         s,$,\e[0m,
100 ' "$@"
101 }
102
103 # chdir to file location and do 'cvs log'
104 cvslog() {
105         local f="$1"
106         local d="${f%/*}"
107         [ "$d" = "$f" ] && d=.
108         (builtin cd $d && cvs log ${f##*/})
109 }
This page took 0.032439 seconds and 4 git commands to generate.