diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-01-28 00:06:03 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-01-28 00:06:03 +0100 |
commit | 248328f31a47a10deeb1be3801d259e846cc16d2 (patch) | |
tree | 2b7c8a2bdf4532acd02bda7a007dc9ba4e68109f /sbin/keyword_package | |
parent | cb84977c082cb3a7d8d0400a17e157f96eb478ad (diff) | |
download | helper-scripts-248328f31a47a10deeb1be3801d259e846cc16d2.tar.gz helper-scripts-248328f31a47a10deeb1be3801d259e846cc16d2.tar.xz helper-scripts-248328f31a47a10deeb1be3801d259e846cc16d2.zip |
new version of keyword_package
new features:
- ~arch is determined via portageq
- /etc/portage/package.keywords is created if it does not exists
- small general improvements in source
Diffstat (limited to 'sbin/keyword_package')
-rwxr-xr-x | sbin/keyword_package | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/sbin/keyword_package b/sbin/keyword_package index 93b93d9..4ecb034 100755 --- a/sbin/keyword_package +++ b/sbin/keyword_package @@ -1,26 +1,52 @@ #!/bin/sh -SPECIAL_LINE_COUNT=$(grep -nE "(/\*)|(\*/)" /etc/portage/package.keywords | tail -n 1 | awk -F: '{ print $1 }') + +# collecting required information +ARCH="$(portageq envvar ARCH)" +PORTCONF_DIR="/etc/portage" + +# check if keywords file exists +if [ ! -f ${PORTCONF_DIR}/package.keywords ] +then + echo "Creating ${PORTCONF_DIR}/package.keywords..." + touch ${PORTCONF_DIR}/package.keywords +fi + +# check if special lines in keyword file exists +SPECIAL_LINE_COUNT="$(grep -nE "(/\*)|(\*/)|(^[ \t]*#)" ${PORTCONF_DIR}/package.keywords | tail -n 1 | awk -F: '{ print $1 }')" +if [ -z "${SPECIAL_LINE_COUNT}" ] +then + SPECIAL_LINE_COUNT=0 +fi + +# create tmpfile TMP_FILE=$(mktemp) -head -n $SPECIAL_LINE_COUNT /etc/portage/package.keywords > $TMP_FILE +# copy untouched special lines to new file +head -n $SPECIAL_LINE_COUNT ${PORTCONF_DIR}/package.keywords > $TMP_FILE ( while [ -n "${1}" ] ; do - LINE="${1} ~x86" - if [ -z "$(grep "^${LINE}$" /etc/portage/package.keywords)" ] + LINE="${1} ~${ARCH}" + if [ -z "$(grep "^${LINE}$" ${PORTCONF_DIR}/package.keywords)" ] then + # adding requested package echo "${LINE}" - echo "adding \"${LINE}\" to /etc/portage/package.keywords" | logger -st $(basename $0) + echo "adding \"${LINE}\" to ${PORTCONF_DIR}/package.keywords" | logger -st $(basename $0) else + # requested package already there 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 + # listing all remaining packages in file + tail -n $(($(cat ${PORTCONF_DIR}/package.keywords | wc -l)-$SPECIAL_LINE_COUNT)) ${PORTCONF_DIR}/package.keywords + +# sort packages and seperate categories by new line ) | 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 +# creatbackup and move temporary file to destination +mv ${PORTCONF_DIR}/package.keywords ${PORTCONF_DIR}/package.keywords.bak +mv $TMP_FILE ${PORTCONF_DIR}/package.keywords +chmod +r ${PORTCONF_DIR}/package.keywords |