#!/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