summaryrefslogtreecommitdiff
blob: 8ab3ad13d2c4206ec4b848a0f1b04480a8de4a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash

# Author: Gilles Dartiguelongue <eva@gentoo.org>
# Reference: Email sent 11 Aug 2009
# Content:
#
# Ok guys,
#
# it looks like I never sent this to everyone, maybe just pasted a link on
# irc. This is the script I used in the last releases to write nice
# reports for arch teams to know what they had to do. It's of course full
# of bugs, dog ass slow and whatever you want it to be besides efficient.
#
# I always dream of rewriting this shit using portage's python API but
# since I can't figure how to dig into it, it still hasn't happened.
#
# This script can either run on packages you have installed or in a list
# of atoms you pass as argument. It writes a bump.list to /tmp that you
# can then attach to a bug report.

#CVS_PORTDIR=$(portageq portdir)
CVS_PORTDIR="<SET THIS BEFORE USING>"

cd "${CVS_PORTDIR}"

EXPERIMENTAL="s/~\?mips\|~\?sparc-fbsd\|~\?x86-fbsd//g"

if [ -z $1 ]; then
	PACKAGES=$(eix -I --only-names)
else
	PACKAGES=$@
fi

echo ">>> Check dependencies with repoman ? [y/N]"
read repocheck
#repocheck="n"

rm /tmp/bump.list
touch /tmp/bump.list

# Get the complete official arch list
ARCH_LIST=$(cat /usr/portage/profiles/arch.list |xargs echo)

for x in ${PACKAGES}
do
	echo "Reading $x ChangeLog"
	CAT=$x

	LOG=$(sed -n "1,/^\\*/p" ${CAT}/ChangeLog)

	LAST_BUMP=$(echo ${LOG} | tail -n1 |\
		sed -e "s/.* (\([0-9]\{1,2\} [a-zA-Z]\{3\} [0-9]\{4\}\))/\1/")

	TS_BUMP=$(LC_ALL="C" date --date="${LAST_BUMP}" +%s)
	TS_NOW=$(LC_ALL="C" date --date="30 days ago" +%s)

	EBUILD=$(sed -n "/^\\*/,+1p" ${CAT}/ChangeLog|\
		sed "s/^\\*//g;s/ (.*/.ebuild/g"|head -n1)
	VERSION=$(sed -n "/^\\*/,+1p" ${CAT}/ChangeLog|\
		sed "s/^\\*//g;s/ (.*//g;s/.*\?-\([0-9]\)/\1/g"|head -n1)

	KEYWORDS=$(sed -n "/KEYWORDS/,1p" ${CAT}/${EBUILD} |\
		sed -e "${EXPERIMENTAL}"|\
		sed "s/KEYWORDS=\"//g;s/\"//g;s/$/\n/g")

	HERD=$(sed -n "/<herd>/,1p" ${CAT}/metadata.xml |\
		sed "s:</\?herd>::g"|xargs echo)

	echo "$VERSION: ${KEYWORDS}"

#	if [ ${TS_BUMP} -le ${TS_NOW} ] &&
	if [ -n "$(echo ${KEYWORDS}|grep "~")" ]; then
#	   [ -n "$(echo ${HERD} |egrep "gnome(-.*)?|freedesktop|gstreamer")" ]; then

	   	arch_stab=""
		printf '%-45s: ' ${CAT}-${VERSION} >> /tmp/bump.list

		for keyword in ${ARCH_LIST}; do
			# don't take fbsd into account
			k1=$(echo $keyword |sed "s/-fbsd//g")
			k2=$(echo $keyword |sed "s/~//g")
			SIZE=$(echo $keyword |wc -m)

			if [ "$keyword" != "$k1" ]; then
				continue
			fi

			success=0
			for k in ${KEYWORDS}
			do
				if [ "~${keyword}" = "$k" ]; then
					success=1
					break
				fi
			done

			if [ $success -eq 0 ]; then
				printf "%${SIZE}s" "$(echo $keyword | sed "s/./ /g")"  >> /tmp/bump.list
				continue
			fi

			if [ "$k" != "${k2}" ]; then
				printf "%${SIZE}s" "$keyword" >> /tmp/bump.list
				arch_stab="${arch_stab} ${keyword}"
			else
				printf "%${SIZE}s" "$(echo $keyword | sed "s/./ /g")"  >> /tmp/bump.list
			fi
		done
		
		echo -e "" >> /tmp/bump.list

		# Create an overlay for later examination
		case $repocheck in
			"y"|"Y")
				pushd $(pwd) &> /dev/null
				mkdir -p /tmp/portage/${CAT}
				cp -r ${CAT}/* /tmp/portage/${CAT}
				rm /tmp/portage/${CAT}/*.ebuild
				cp ${CAT}/${EBUILD} /tmp/portage/${CAT}/
				cd /tmp/portage/${CAT}

				ekeyword $(echo $arch_stab | tr -s \ ) ${EBUILD}

				ebuild ${EBUILD} manifest

				popd &> /dev/null
				;;
			*)
				;;
		esac

	fi
done

case $repocheck in
	"y"|"Y")

		for x in $(ls /tmp/portage/*/*/*.ebuild)
		do
			pushd $(pwd) &> /dev/null

			cd $(dirname $x)
			ACCEPT_KEYWORDS="amd64" PORTDIR_OVERLAY="${CVS_PORTDIR} /tmp/portage" repoman --without-mask full

			popd &> /dev/null
		done
		;;
	*)
		;;
esac