summaryrefslogtreecommitdiffstats
path: root/sbin/keyword_package
blob: 93b93d9b670b332b48efabcfbb3971621923d4aa (plain) (blame)
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
#!/bin/sh
SPECIAL_LINE_COUNT=$(grep -nE "(/\*)|(\*/)" /etc/portage/package.keywords | tail -n 1 | awk -F: '{ print $1 }')
TMP_FILE=$(mktemp)

head -n $SPECIAL_LINE_COUNT /etc/portage/package.keywords > $TMP_FILE

(
	while [ -n "${1}" ] ; do
		LINE="${1} ~x86"
		if [ -z "$(grep "^${LINE}$" /etc/portage/package.keywords)" ]
		then
			echo "${LINE}"
			echo "adding \"${LINE}\" to /etc/portage/package.keywords" | logger -st $(basename $0)
		else
			echo "Don't adding \"${1}\". Already there." > /dev/stderr
		fi

		shift 1
	done
	
	tail -n $(($(cat /etc/portage/package.keywords | wc -l)-$SPECIAL_LINE_COUNT)) /etc/portage/package.keywords
) | grep -v "^$" | sort | awk -F/ '{ if (OLD_PREFIX!=$1) print "";  OLD_PREFIX=$1 ; print }' >> $TMP_FILE

mv /etc/portage/package.keywords /etc/portage/package.keywords.bak
mv $TMP_FILE /etc/portage/package.keywords
chmod +r /etc/portage/package.keywords