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