-
Notifications
You must be signed in to change notification settings - Fork 0
/
scantree-enewusergroup.bash
executable file
·65 lines (57 loc) · 1.65 KB
/
scantree-enewusergroup.bash
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
#!/bin/bash
PORTDIR="${PORTDIR:-$(paludis --configuration-variable gentoo location)}"
PORTDIR="${PORTDIR:-$(portageq envvar PORTDIR)}"
PORTDIR="${PORTDIR:-/usr/portage}"
echo -n "Creating temp files: " 1>&2
# Temporary files
echo -n "." 1>&2
ebuild_list=$(mktemp -t ebuild.XXXXXX)
echo -n "." 1>&2
eclass_list=$(mktemp -t eclass.XXXXXX)
echo -n "." 1>&2
ebuild_grep_cmd=$(mktemp -t ebuild_grep_cmd.XXXXXX)
echo " done." 1>&2
pushd $PORTDIR >/dev/null
echo -n "Generating eclass list: " 1>&2
# Generate list of matching eclasses
for ec in eclass/*.eclass ; do
# Skip this false positive
[[ "$ec" == *eutils.eclass ]] && continue
if grep -l -e enewuser -e enewgroup $ec >> $eclass_list ; then
echo -n "+" 1>&2
else
echo -n "." 1>&2
fi
done
echo " done." 1>&2
echo -n "Generating ebuild grep command: " 1>&2
# Build the arguments for our grep of each ebuild, so we only have to touch
# each ebuild once.
echo -n "-l -e enewuser -e enewgroup" >> $ebuild_grep_cmd
for ec in $(< $eclass_list) ; do
ec=${ec/eclass\/}
ec=${ec/.eclass}
echo -n "." 1>&2
echo -n " -einherit.\\\\*$ec" >> $ebuild_grep_cmd
done
echo >> $ebuild_grep_cmd
echo " done." 1>&2
echo -n "Generating ebuild list: " 1>&2
i=0
# Generate list of matching ebuilds
for c in $(< profiles/categories) ; do
for e in $c/*/*.ebuild ; do
[[ -f "${e}" ]] || continue
i=$(( $i + 1 ))
[[ $(( $i % 100 )) == 0 ]] && echo -n "." 1>&2
grep $(< $ebuild_grep_cmd) $e >> $ebuild_list \
&& echo -n "+" 1>&2
done
done
echo " done." 1>&2
echo "Generating final list: " 1>&2
# Generate our final list
cat $eclass_list $ebuild_list
echo " done." 1>&2
popd >/dev/null
rm -f $ebuild_list $eclass_list $ebuild_grep_cmd