Restore package.keywords
Yeah, call me stupid. Today I wanted to upgrade a few packages to a version that's marked with the ~x86 keyword. So, normally you add those packages to the /etc/portage/package.keywords file with the right keyword. But by mistake, I entered this line:
echo "=media-video/vlc-0.8.2-r2 ~x86" > /etc/portage/package.keywords"
Whoops! My whole package.keywords file overwritten with that one stupid rule!
As I had quite a lot packages in that file, for example the whole gnome tree, I sure wanted to restore it, but that'ld be lots of work. So, why not automate the whole thing? With some help from Ikke and the Bash Guide for Beginners, I constructed the following script:
for i in `emerge -uDp world | grep D] | sed "s/.*D]\ /=/" | sed "s/-[0-9].*\[/-/" | sed "s/]//" `;
do
echo "${i} ~x86" >> /etc/portage/package.keywords;done;test=`emerge -uDp world | grep masked\ by.*keyword`
while [ "$test" ];
do
emerge -uDp world | grep masked\ by.*keyword | sed "s/^-\ /=/" | sed "s/\ (masked.*$/\ ~x86/" >> /etc/portage/package.keywords
done
So it'll add every package that should be downgraded to the package.keywords file, and check all those dependencies and add them to the file too. My whole file was restored in just a few seconds :-)
One know bug for now: when I check manually for "emerge -uDp world | grep masked\ by.*keyword", I don't recieve any results so the string should be empty. But in the script, the string isn't seen as empty and the program stays in the loop until you manually kill the process. If anyone has an idea to fix this, please be my guest. Of course, everyone is free to use, modify and share it, but please, leave a comment if you do so. Thanks.


0 reacties
Plaats een nieuwe reactie