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