Restore package.keywords

(tags: )

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

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web- en e-mail adressen worden automatisch omgezet in links.
  • Toegestane HTML tags: <a> <acronym> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <ins> <i> <b> <u> <blockquote>
  • Je mag code posten dmv <code>...</code> (generiek) of <?php ... ?> (highlighted PHP) tags.
  • Op het einde van de lijn of paragraaf wordt automatisch een nieuwe lijn begonnen.

Meer informatie over opmaak mogelijkheden

Syndicate content

Politiek engagement

N-VA logo

Kortjes

Blik op mijn agenda

Je vindt me ook terug op

Facebook logo
Twitter logo
YouTube logo
Vimeo logo
GarageTV logo
Flickr logo

Laatste reacties

Syndicate content

Laatste foto's

Meer foto's hier.

Contact

Je kan me steeds contacteren via het contactformulier of rechtstreeks:
Kleine Kerkstraat 24, 9050 Gent
Peter@peterdedecker.eu
0486/152320

Disclaimer

Dit is de website van Peter Dedecker. Alle teksten mogen, tenzij anders vermeld, overgenomen worden mits bronvermelding. Een link wordt altijd geapprecieerd. Dit alles is mijn persoonlijke opinie. Organisaties waar ik lid van (geweest) ben of voor (ge)werk(t heb) kunnen in geen geval aansprakelijk gesteld worden voor wat ik hier schrijf. Zie de volledige disclaimer.