]> git.wh0rd.org - home.git/blame - .profile.d/gentoo.sh
gitignore: ignore more stuff
[home.git] / .profile.d / gentoo.sh
CommitLineData
a810f714 1alias ebuild-sync='rsync -av ./ /usr/portage/${PWD#/usr/local/src/gentoo/repo/gentoo/} --exclude ChangeLog --exclude CVS --exclude metadata.xml --delete'
eca710ea 2alias ebuild-emerge='sudo emerge -1av $(echo ${PWD} | awk -F/ "{printf \"%s/%s\", \$(NF-1), \$(NF)}")'
6d0816bf 3alias ekeyword='ekeyword -v -q'
051c2832
MF
4alias repoman='repoman -q -q'
5alias rf='/usr/local/src/gentoo/portage/repoman/bin/repoman.git -q full'
eca710ea 6
2239c239 7_echangelog() {
1afdf944
MF
8 [[ ! -e ChangeLog ]] \
9 && echo "No ChangeLog" \
10 && return 1
11 echangelog "$@" || return 1
2239c239
MF
12}
13er() {
a810f714 14 repoman commit "${@:1:$#-1}" -m "${@:$#}" || return 1
1afdf944 15}
2239c239 16ec() {
369dd755
MF
17 (
18 _echangelog "$@" || exit 1
19 cvs commit -m "$@" || exit 1
20 )
2239c239
MF
21}
22
1afdf944 23att() {
294704a2
MF
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
1afdf944
MF
39}
40arch_emails() {
ef325790 41 local ret
1afdf944
MF
42 if [[ $@ == *.ebuild* ]] ; then
43 local e keys
44 for e in "$@" ; do
39d58573 45 keys=$(sed -n '/^[[:space:]]*KEYWORD/{s:.*=::;s:"::g;p}' ${e})
1afdf944
MF
46 for a in ${keys} ; do
47 [[ ${a} != ~* ]] && continue
ef325790 48 ret="${ret} ${a}"
1afdf944
MF
49 done
50 done
51 else
ef325790 52 ret="$*"
1afdf944 53 fi
ef325790
MF
54 printf '%s@gentoo.org ' ${ret//\~}
55 echo
1afdf944 56}
8ef7abb4
MF
57stable_arch_emails() {
58 arch_emails "$@" | sed -r -e 's:([^ ]*-[^ ]*|mips)@[^ ]*::g'
59}
036bd914
MF
60eget_maintainer() {
61 local f=${1:-metadata.xml}
62 local maintainer=$(xml sel -t -v pkgmetadata/herd $f)
63 if [[ ${maintainer:-no-herd} == "no-herd" ]] ; then
64 maintainer=$(xml sel -t -v pkgmetadata/maintainer/email $f)
65 elif [[ -n ${maintainer} ]] ; then
66 maintainer="${maintainer}@gentoo.org"
67 fi
68 if [[ -z ${maintainer} ]] ; then
69 echo "No maintainer found in $f"
70 return 1
71 fi
94696975 72 echo ${maintainer}
036bd914
MF
73 return 0
74}
1afdf944
MF
75submit_bug_stable() {
76 local msg="doit"
77 if [[ $1 == "-m" ]] ; then
78 msg=$2
79 shift 2
80 fi
81 if [[ -z $1 ]] || [[ -n $2 ]] ; then
82 echo "Usage: submit_bug_stable <ebuilds>"
83 return 1
84 fi
036bd914
MF
85 local maintainer
86 maintainer=$(eget_maintainer) || return 1
1afdf944
MF
87 local cat=$(basename $(dirname $(pwd)))
88 local pkg=${1%.ebuild}
89 local ebuild=${pkg}.ebuild
8ef7abb4 90 local cc=$(stable_arch_emails ${ebuild})
1afdf944
MF
91 if [[ -z ${cc} ]] ; then
92 echo "Unable to read ebuild '${ebuild}'"
93 return 1
94 fi
94696975
MF
95 if [[ ${maintainer} == *" "* ]] ; then
96 cc+=",${maintainer#* }"
97 maintainer=${maintainer%% *}
98 fi
ef325790
MF
99 gbugz \
100 post \
5b85a493 101 --batch \
ef325790 102 -t "${cat}/${pkg}: stabilize" \
1afdf944
MF
103 -d "${msg}" \
104 -a "${maintainer}" \
ef325790 105 --cc="${cc// /,}" \
39d58573
MF
106 -k STABLEREQ \
107 --product='Gentoo Linux' \
108 --component=Ebuilds \
ef325790 109 --priority=Normal \
39d58573 110 --severity=enhancement
1afdf944
MF
111}
112
113eskeys() {
114 local k cat
115 if [[ ! -e ChangeLog ]] ; then
116 # running in a category rather than package
117 cat="/"
118 fi
d040ef70 119 [[ -z $* ]] && set -- arm64 m68k s390 sh
1afdf944 120 for k in "$@" ; do
d040ef70 121 ekeyword "${k}=x86" $(grep -l "KEYWORDS.*${k}" *${cat}*.ebuild)
1afdf944
MF
122 done
123}
124_erit() {
125 local msg=$1 ; shift
126 [[ $1 == [[:digit:]]* ]] && msg="$msg #$1" && shift
051c2832
MF
127 echo git commit -m "$(echo $@ | sed 's: :/:g') $msg"
128 git commit -m "$(echo $@ | sed 's: :/:g') $msg"
1afdf944
MF
129}
130erstable() { _erit stable "$@" ; }
131erlove() { _erit love "$@" ; }
8ef7abb4
MF
132
133export PORTAGE_INST_UID=${UID}
134export PORTAGE_INST_GID=`id -g`