]> git.wh0rd.org Git - home.git/blob - .profile.d/gentoo.sh
export LANG first before testing
[home.git] / .profile.d / gentoo.sh
1 cvs_gentoo_url() {
2 _cvs_gentoo_url() {
3         if [[ -n $2 ]] ; then
4                 echo "Usage: cvs_gentoo_url <file>[:rev1[:rev2]]"
5                 return 1
6         fi
7
8         # spec has the form file:rev1[:rev2]
9         # rev2 defaults to rev1-1
10         export IFS=:
11         set -- $1
12         unset IFS
13
14         local file=$1
15         if [[ ! -e ${file} ]] ; then
16                 echo "file '${file}' does not exist"
17                 return 1
18         fi
19         local dir="."
20         [[ ${file} == */* ]] && dir=${file%/*}
21         file=${file##*/}
22
23         local rev2=$2
24         if [[ -z ${rev2} ]] ; then
25                 rev2=$(
26                         cd ${dir}
27                         export IFS=/
28                         set -- $(grep /${file}/ CVS/Entries)
29                         unset IFS
30                         echo $3
31                 )
32                 if [[ ${rev2} == "0" ]] ; then
33                         # new file
34                         rev2="1.1"
35                 else
36                         # existing file, bump rev automatically
37                         rev2="1.$((${rev2#1.}+1))"
38                 fi
39         fi
40         local rev2r=${rev2#1.}
41         local rev1=${3:-1.$((rev2r - 1))}
42
43         local cvsroot=$(<${dir}/CVS/Repository)
44         if [[ ${cvsroot} == gentoo-x86* ]] ; then
45                 cvsroot=${cvsroot#gentoo-x86}
46                 cvsroot=${cvsroot#/}
47         fi
48
49         local urirev
50         [[ ${rev2} == "1.1" || ${rev1} == "${rev2}" ]] \
51                 && urirev="?rev=${rev2}" \
52                 || urirev="?r1=${rev1}&r2=${rev2}"
53         echo "http://sources.gentoo.org/${cvsroot}/${file}${urirev}"
54 }
55         local f
56         for f in "$@" ; do
57                 _cvs_gentoo_url "${f}"
58         done
59         unset _cvs_gentoo_url
60 }
61 git_gentoo_url() {
62         local repo=$(git config remote.origin.url | sed 's:.*git.overlays.gentoo.org/::')
63         git log -n3 ${1:-HEAD} | \
64                 sed "s,^commit ,http://git.overlays.gentoo.org/gitweb/?p=${repo};a=commitdiff;h=,"
65 }
66
67 er() {
68         [[ ! -e ChangeLog ]] \
69                 && echo "No ChangeLog" \
70                 && return 1
71         echangelog "$@" || return 1
72         repoman commit -m "$@" || return 1
73 }
74 att() {
75         declare url=$1 tmp=$(mktemp) filename || return 1
76         [[ $url == */* ]] || url="http://bugs.gentoo.org/attachment.cgi?id=$url"
77         eval $(wget -S -O"$tmp" "$url" 2>&1 | tee /dev/tty | \
78                grep 'Content-disposition:' | sed 's/.* //') && \
79                 mv "$tmp" "$filename" && \
80                 chmod $(printf "%03o" "$((0666 & ~$(umask)))") "$filename" && \
81                 ls -l "$filename" && \
82                 return 0
83         rm -f "$tmp"
84         return 1
85 }
86 arch_emails() {
87         local a ret=""
88         if [[ $@ == *.ebuild* ]] ; then
89                 local e keys
90                 for e in "$@" ; do
91                         keys=$(sed -n '/^KEYWORD/{s:.*=::;s:"::g;p}' ${e})
92                         for a in ${keys} ; do
93                                 [[ ${a} != ~* ]] && continue
94                                 ret="${ret} ${a/\~}@gentoo.org"
95                         done
96                 done
97         else
98                 for a in "$@" ; do
99                         ret="${ret} ${a/\~}@gentoo.org"
100                 done
101         fi
102         echo ${ret}
103 }
104 submit_bug_stable() {
105         local msg="doit"
106         if [[ $1 == "-m" ]] ; then
107                 msg=$2
108                 shift 2
109         fi
110         if [[ -z $1 ]] || [[ -n $2 ]] ; then
111                 echo "Usage: submit_bug_stable <ebuilds>"
112                 return 1
113         fi
114         local maintainer=$(xml sel -t -v pkgmetadata/herd metadata.xml)
115         if [[ ${maintainer} == "no-herd" ]] ; then
116                 maintainer=$(xml sel -t -v pkgmetadata/maintainer/email metadata.xml)
117         elif [[ -n ${maintainer} ]] ; then
118                 maintainer="${maintainer}@gentoo.org"
119         fi
120         if [[ -z ${maintainer} ]] ; then
121                 echo "No maintainer found in metadata.xml"
122                 return 1
123         fi
124         local cat=$(basename $(dirname $(pwd)))
125         local pkg=${1%.ebuild}
126         local ebuild=${pkg}.ebuild
127         local cc=$(arch_emails ${ebuild} | sed -r -e 's:([^ ]*-fbsd|mips)@[^ ]*::g')
128         if [[ -z ${cc} ]] ; then
129                 echo "Unable to read ebuild '${ebuild}'"
130                 return 1
131         fi
132         bugz post \
133                 -u vapier@gentoo.org \
134                 -t "Stabilize ${cat}/${pkg}" \
135                 -d "${msg}" \
136                 -a "${maintainer}" \
137                 --cc="${cc}" \
138                 -U "" \
139                 -k STABLEREQ
140 }
141
142 eskeys() {
143         local k cat
144         if [[ ! -e ChangeLog ]] ; then
145                 # running in a category rather than package
146                 cat="/"
147         fi
148         [[ -z $* ]] && set -- arm m68k s390 sh
149         for k in "$@" ; do
150                 local list="$(grep "^KEYWORDS=.*~${k}\>.*[^~]x86" *${cat}*d -l)"
151                 [[ -z ${list} ]] && continue
152                 sed -i "1s:.*:# Copyright 1999-$(date +%Y) Gentoo Foundation:" ${list}
153                 ekeyword ${k} ${list}
154         done
155 }
156 _erit() {
157         local msg=$1 ; shift
158         [[ $1 == [[:digit:]]* ]] && msg="$msg #$1" && shift
159         echo repoman commit -m "$(echo $@ | sed 's: :/:g') $msg"
160         repoman commit -m "$(echo $@ | sed 's: :/:g') $msg"
161 }
162 erstable() { _erit stable "$@" ; }
163 erlove() { _erit love "$@" ; }