Skip to content

Instantly share code, notes, and snippets.

@garymacindoe
Created April 15, 2015 12:13
Show Gist options
  • Save garymacindoe/0182fa994b358aaa844c to your computer and use it in GitHub Desktop.
Save garymacindoe/0182fa994b358aaa844c to your computer and use it in GitHub Desktop.
Checks for invalid/obsolete keywords in Gentoo Portage's packages.accept_keywords files
#!/bin/bash
#
# Author: Gary Macindoe
# Date: May 2013
files="/etc/portage/package.accept_keywords /etc/portage/package.keywords"
fs=""
for f in ${files}
do
if [ -d "${f}" ]
then
fs+="${f}/*"
fi
done
files="${fs}"
for file in ${files}
do
echo -e "\E[1;33;40m${file}:"
grep -Ev '^[ \t]*#|^$' ${file} | while read atom keywords
do
packages="$(equery -q l ${atom} 2>/dev/null)"
if [ $? -ne 0 ]
then
echo -e "\E[0;31;40mNo package installed matching ${atom}"
fi
for package in ${packages}
do
keyword="$(equery -q --no-color l ${package} -F\$mask2 2>/dev/null)"
if [ $? -ne 0 ]
then
echo -e "\E[0;31;40mUnable to find keyword for ${package} (most likely the ebuild has been removed)"
else
echo -ne " \E[0;36;40m$(echo ${atom} | cut -d'/' -f1)/\E[0;32;40m$(echo ${atom} | cut -d'/' -f2)"
for k in ${keywords}
do
if [ "${k}" = "${keyword}" ]
then
echo -e " \E[1;32;40m${k}"
else
echo -e " \E[1;31;40m${k}"
fi
done
fi
done
done
done
echo -e "\E[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment