]> git.wh0rd.org Git - home.git/blob - .profile.d/gentoo.sh
gitconfig: more settings
[home.git] / .profile.d / gentoo.sh
1 alias ebuild-sync='rsync -av ./ /usr/portage/${PWD#/usr/local/src/gentoo/repo/gentoo/} --exclude ChangeLog --exclude CVS --exclude metadata.xml --delete'
2 alias ebuild-emerge='sudo emerge -1av $(echo ${PWD} | awk -F/ "{printf \"%s/%s\", \$(NF-1), \$(NF)}")'
3 alias ekeyword='ekeyword -v -q'
4 alias repoman='repoman -q -q'
5 alias rf='/usr/local/src/gentoo/portage/repoman/bin/repoman.git -q full'
6
7 _echangelog() {
8         [[ ! -e ChangeLog ]] \
9                 && echo "No ChangeLog" \
10                 && return 1
11         echangelog "$@" || return 1
12 }
13 er() {
14         repoman commit "${@:1:$#-1}" -m "${@:$#}" || return 1
15 }
16 ec() {
17         (
18         _echangelog "$@" || exit 1
19         cvs commit -m "$@" || exit 1
20         )
21 }
22
23 att() {
24         while [[ $# -gt 0 ]] ; do
25                 declare url=$1 tmp=$(mktemp) filename || return 1
26                 [[ ${url} == */* ]] || url="http://bugs.gentoo.org/attachment.cgi?id=${url}"
27                 printf '%s -> ' "${url}"
28                 if eval $(wget -S -O"${tmp}" "${url}" 2>&1 |
29                         grep 'Content-disposition:' | sed 's/.* //') && \
30                         mv "${tmp}" "${filename}" && \
31                         chmod $(printf "%03o" "$((0666 & ~$(umask)))") "${filename}" ; then
32                         du -b "${filename}"
33                 else
34                         echo "FAIL"
35                         rm -f "${tmp}"
36                 fi
37                 shift
38         done
39 }
40 arch_emails() {
41         local ret
42         if [[ $@ == *.ebuild* ]] ; then
43                 local e keys
44                 for e in "$@" ; do
45                         keys=$(sed -n '/^[[:space:]]*KEYWORD/{s:.*=::;s:"::g;p}' ${e})
46                         for a in ${keys} ; do
47                                 [[ ${a} != ~* ]] && continue
48                                 case ${a} in
49                                 *-*) continue ;;
50                                 ~arm64|~m68k|~mips|~s390|~sh) continue ;;
51                                 ~*) ret="${ret} ${a}" ;;
52                                 esac
53                         done
54                 done
55         else
56                 ret="$*"
57         fi
58         printf '%s@gentoo.org,' ${ret//\~}
59         echo
60 }
61 stable_arch_emails() {
62         arch_emails "$@" | sed -r -e 's:([^ ]*-[^ ]*|mips)@[^ ]*::g'
63 }
64 eget_maintainer() {
65         local f=${1:-metadata.xml}
66         local maintainer=$(xml sel -t -v pkgmetadata/herd $f)
67         if [[ ${maintainer:-no-herd} == "no-herd" ]] ; then
68                 maintainer=$(xml sel -t -v pkgmetadata/maintainer/email $f)
69         elif [[ -n ${maintainer} ]] ; then
70                 maintainer="${maintainer}@gentoo.org"
71         fi
72         if [[ -z ${maintainer} ]] ; then
73                 echo "No maintainer found in $f"
74                 return 1
75         fi
76         echo ${maintainer}
77         return 0
78 }
79 submit_bug_stable() {
80         local msg="doit"
81         if [[ $1 == "-m" ]] ; then
82                 msg=$2
83                 shift 2
84         fi
85         if [[ -z $1 ]] || [[ -n $2 ]] ; then
86                 echo "Usage: submit_bug_stable <ebuilds>"
87                 return 1
88         fi
89         local maintainer
90         maintainer=$(eget_maintainer) || return 1
91         local cat=$(basename $(dirname $(pwd)))
92         local pkg=${1%.ebuild}
93         local ebuild=${pkg}.ebuild
94         local cc=$(stable_arch_emails ${ebuild})
95         if [[ -z ${cc} ]] ; then
96                 echo "Unable to read ebuild '${ebuild}'"
97                 return 1
98         fi
99         if [[ ${maintainer} == *" "* ]] ; then
100                 cc+=",${maintainer#* }"
101                 maintainer=${maintainer%% *}
102         fi
103         gbugz \
104                 post \
105                 --batch \
106                 -t "${cat}/${pkg}: stabilize" \
107                 -d "${msg}" \
108                 -a "${maintainer}" \
109                 --cc="${cc// /,}" \
110                 -k STABLEREQ \
111                 --product='Gentoo Linux' \
112                 --component=Ebuilds \
113                 --priority=Normal \
114                 --severity=enhancement
115 }
116
117 eskeys() {
118         local k cat
119         if [[ ! -e ChangeLog ]] ; then
120                 # running in a category rather than package
121                 cat="/"
122         fi
123         [[ -z $* ]] && set -- arm64 m68k s390 sh
124         for k in "$@" ; do
125                 ekeyword "${k}=x86" $(grep -l "KEYWORDS.*${k}" *${cat}*.ebuild)
126         done
127 }
128 _erit() {
129         local msg=$1 ; shift
130         [[ $1 == [[:digit:]]* ]] && msg="$msg #$1" && shift
131         echo git commit -m "$(echo $@ | sed 's: :/:g') $msg"
132         git commit -m "$(echo $@ | sed 's: :/:g') $msg"
133 }
134 erstable() { _erit stable "$@" ; }
135 erlove() { _erit love "$@" ; }
136
137 export PORTAGE_INST_UID=${UID}
138 export PORTAGE_INST_GID=`id -g`