summaryrefslogtreecommitdiff
blob: 9ca28e5c1fdedb9169583fbe4ff24e0a04a52cd3 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/bash
# a script to filter and sort pcheck dumps

CHECKDIR=/usr/portage/local/layman/sunrise

make_dump() {
	today="$(date +%Y%m%d)-qa-check"
	[[ -d ${today} ]] || mkdir ${today} 
	cd ${today}
	echo "*** Running pcheck on ${CHECKDIR} - will take a while..."
	pcheck -d=pkgcore_checks.unstable_only.UnstableOnlyReport -r /usr/portage ${CHECKDIR} &> dump
	cp dump dump-unparsed
	echo "Done!"
	echo
}

filter_keywords() {
	local all_unstable="all unstable"
	local stabled="stabled"
	local no_change="no change"
	local dropped="dropped"
	local vcs_visible="vcs ebuild visible"
	local stupid="mask instead"
	local redundant="keywords are overshadowed"

	echo "*** Filtering keywords-related stuff..."
	for kwd in "${all_unstable}" "${stabled}" "${no_change}" "${dropped}" "${vcs_visible}" "${stupid}" "${redundant}" ; do
		grep "${kwd}" dump > keywords_"${kwd// /_}".log
		echo -e "Filtering "${kwd}"...\t `grep -c "${kwd}" dump` match(es) found."
		sed -i "/${kwd}/d" dump
	done
	echo "Done!"
	echo
}

filter_depends() {
	local nonexistant="nonexistant"
	local unsolvable="unsolvable"
	local malformed="malformed"

	echo "*** Filtering depends-related stuff..."
	for depends in "${nonexistant}" "${unsolvable}" "${malformed}" ; do
		grep "${depends}" dump > depends_"${depends}".log
		echo -e "depends "${depends}"...\t `grep -c "${depends}" dump` problem(s) found."
		sed -i "/${depends}/d" dump
	done

	echo "Doing further sorting..."
	grep masked depends_${unsolvable}.log > depends_${unsolvable}_masked.log
	sed -i "/masked/d" depends_${unsolvable}.log
	grep ppc-macos depends_${unsolvable}.log > depends_${unsolvable}_ppc-macos.log
	sed -i "/ppc-macos/d" depends_${unsolvable}.log
	grep x86-fbsd depends_${unsolvable}.log > depends_${unsolvable}_x86-fbsd.log
	sed -i "/x86-fbsd/d" depends_${unsolvable}.log
	mv depends_${unsolvable}.log depends_${unsolvable}_other.log
	
	echo "Done!"
	echo
}

filter_eclasses() {
	echo -e "*** Filtering deprecated eclasses... \t\t `grep -c "deprecated eclasses" dump` problem(s) found."
	grep "deprecated eclasses" dump > deprecated_eclasses.log
	sed -i "/deprecated eclasses/d" dump
	echo "Done!"
	echo
}

filter_deprecated_flags() {
	echo -e "*** Filtering deprecated flags... \t\t `grep -c "deprecated flags" dump` problem(s) found."
	grep "deprecated flags" dump > deprecated_flags.log
	sed -i "/deprecated flags/d" dump
	echo "Done!"
	echo
}

filter_mirrors() {
	echo -e "*** Filtering unknown mirrors... \t\t `grep -c "no known mirror tier" dump` problem(s) found."
	grep "no known mirror tier" dump > unknown_mirror.log
	sed -i "/no known mirror tier/d" dump
	echo "Done!"
	echo
}


filter_modularx() {
	local unported="not ported"
	local visibility_unported="visibility induced unported"
	local potentially_remove="potentially remove"

	echo "*** Filtering modular X related stuff..."
	for modularx in "${unported}" "${visibility_unported}" "${potentially_remove}" ; do
		grep "${modularx}" dump > modular_x_"${modularx// /_}".log
		echo -e "modular X "${modularx}"...\t `grep -c "${modularx}" dump` problem(s) found."
		sed -i "/${modularx}/d" dump
	done
	echo "Done!"
	echo
}


filter_description() {
	local generic="eclass defined"
	local too_long="over 250 chars"
	local stupid="using the pkg name"
	
	echo "*** Filtering description-related stuff..."
	for desc in "${generic}" "${too_long}" "${stupid}" ; do
		grep "${desc}" dump > description_"${desc// /_}".log
		echo -e "description "${desc}"...\t `grep -c "${desc}" dump` problem(s) found."
		sed -i "/${desc}/d" dump
	done
	echo "Done!"
	echo
}

filter_metadata() {
	local executable="executable"

	echo "*** Filtering metadata-related stuff..."
	for meta in "${executable}" ; do
		grep "${meta}" dump > metadata_"${meta}".log
		echo -e "metadata "${meta}"...\t `grep -c "${meta}" dump` problem(s) found."
		sed -i "/${meta}/d" dump
	done
	echo "Done!"
	echo
}
	

filter_files() {
	local too_big="exceeds 20k"

	echo "*** Filtering files-related stuff..."
	for files in "${too_big}" ; do
		grep "${files}" dump > files_"${files/ /_}".log
		echo -e "filesdir "${files}"...\t `grep -c "${files}" dump` problem(s) found."
		sed -i "/${files}/d" dump
	done
	echo "Done!"
	echo
}

filter_flags() {
	local unstated="unstated flags"
	local unknown="unknown flags"
	local unused="unused flag"
	
	echo "*** Filtering use flags-related stuff..."
	for flags in "${unstated}" "${unknown}" "${unused}" ; do
		grep "${flags}" dump > "${flags/ /_}".log
		echo -e ""${flags}"...\t `grep -c "${flags}" dump` problem(s) found."
		sed -i "/${flags}/d" dump
	done
	echo "Done!"
	echo
}


filter_restrict() {
	local unknown="unknown"
	local deprecated="deprecated"

	echo "*** Filtering restrict-related stuff..."
	for restrict in "${unknown}" "${deprecated}" ; do
		grep "${restrict}" dump > restrict_"${restrict}".log
		echo -e "restrict "${restrict}"...\t `grep -c "${restrict}" dump` problem(s) found."
	done
	for restrict in "${unknown}" "${deprecated}" ; do
		sed -i "/${restrict}/d" dump
	done
	echo "Done!"
	echo
}


filter_vulnerable() {
	echo -e "*** Filtering vulnerable ebuilds... \t\t `grep -c "vulnerable" dump` problem(s) found."
	grep "vulnerable" dump > vulnerable.log
	sed -i "/vulnerable/d" dump
	echo "Done!"
	echo
}

filter_licenses() {
	echo -e "*** Filtering unused licenses... \t\t `grep -c "unused license" dump` match(es) found."
	grep "unused license" dump > unused_licenses.log
	sed -i "/unused license/d" dump
	echo "Done!"
	echo
}


filter_digests() {
	echo -e "*** Filtering digest overlaps... \t\t `grep -c "conflicts with" dump` problem(s) found."
	grep "conflicts with" dump > digest_overlap.log
	sed -i "/conflicts with/d" dump
	echo "Done!"
	echo
}


vdb_hardcoded() {
	echo "*** Checking for hardcoded VDB stuff..."
	local pdir="$(portageq envvar PORTDIR)"
	find "${pdir}" -name '*.eclass' -o -name '*.ebuild' | xargs grep -H var/db/pkg | tee vdb_hardcoded.log >/dev/null 2>&1
}

filter_remaining() {
	echo "*** Filtering remaining stuff"
	local reversed="is reversed in"
	grep "${reversed}" dump > profiles_reversed.log
	sed -i "/${reversed}/d" dump
	echo "*** The rest is unsorted..."
	echo
	mv dump remaining_unsorted.log
}

cleanup() {
	echo "*** Cleaning up empty logs..."
	for log in `ls *.log` ; do
		[[ -s "${log}" ]] || ( echo "Deleting empty log: ${log} ..." && rm -f "${log}" )
	done
	echo
	echo "*****************"
        echo "*** ALL DONE! ***"
	echo "*****************"
}


make_dump
filter_keywords
filter_depends
filter_eclasses
filter_deprecated_flags
filter_mirrors
filter_modularx
filter_description
filter_metadata
filter_files
filter_flags
filter_restrict
filter_vulnerable
filter_licenses
filter_digests
#vdb_hardcoded
filter_remaining
cleanup