View previous topic :: View next topic |
Author |
Message |
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Mon Jan 05, 2009 2:27 pm Post subject: Cleaning world - umerge.sh |
|
|
Many times when I search for a certain kind of program I usually emerge many candidates. Finally when I have decided what program to use I forget to unmerge all the other programs that I installed for testing. I want to keep my system clean - only keeping the apps I really need. This is why I did a simple bash script that reads trough the world file and then gives you a list of packages to get rid of. It always uses --ask for emerge, so you can safely test it first.
Here's the source: Code: | #!/bin/bash
# umerge.sh - unmerge packages easily
# v0.0.2b
UMERGELIST=`mktemp -t "unmerge_list_XXXXX"`
dialog --title 'Dialog unmerger' --single-quoted --checklist 'Select packages to unmerge' 0 0 0 `while read LINE; do echo -n "$LINE | off "; done < /var/lib/portage/world | sort` 2> "$UMERGELIST"
clear
sed -i "s/'//g" $UMERGELIST
emerge -vaC `cat $UMERGELIST`
rm $UMERGELIST |
After you have unmerged packages, you can run 'emerge -va --depclean' to remove all the useless depencies that were needed by the packages you just unmerged.
At least this works on my PC. ;) _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
Last edited by Zucca on Sat May 16, 2009 10:36 am; edited 3 times in total |
|
Back to top |
|
|
spindle Apprentice
Joined: 01 Dec 2003 Posts: 245
|
Posted: Mon Jan 05, 2009 3:57 pm Post subject: |
|
|
This should be handy, I usually do this by hand. Thanks Zucca. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Mon Jan 05, 2009 4:29 pm Post subject: |
|
|
This can be useful also: Code: | /path/to/unmerge.sh && emerge -va --depclean && revdep-rebuild -- -va |
Basically: remove packages of your choice --> remove the deps of those packages (if no other package uses them) --> check deps after --depclean _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Tue Jan 06, 2009 10:02 pm Post subject: |
|
|
I also made merge.sh for installing packages. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
imake n00b
Joined: 08 Jan 2009 Posts: 7
|
Posted: Tue Jan 13, 2009 5:21 pm Post subject: Re: Cleaning world - umerge.sh |
|
|
It's very useful,thanks a lot~ |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Tue Jan 13, 2009 6:11 pm Post subject: |
|
|
Nice to see people finding this useful. :) _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Sat May 16, 2009 10:37 am Post subject: |
|
|
UPDATE: Just made it working with the new emerge command. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Wed Dec 14, 2016 2:46 pm Post subject: |
|
|
Once again I had a need for this script.
I modified it to fit this decade and tested. Seems to work.
Any feedback is welcome.
I might develop a feature that let's user to read description and other information of a package... But for now it just removes packages user has selected.
Code: | #!/bin/bash
# umerge.sh - unmerge packages easily
# v0.1.0a
umlist="$(mktemp --suffix=".lst" "umerge_list_XXXXX")"
dialog --title 'Dialog unmerger' --single-quoted --no-items --checklist 'Select packages to unmerge' 0 0 0 --file <(awk '{sub(/:/,"-"); print $0 " off"}' /var/lib/portage/world | sort) 2> "$umlist" || exit 1
clear
sed -i "s/'//g" $umlist
emerge -vac $(cat $umlist)
rm "$umlist" |
|
|
Back to top |
|
|
saboya Guru
Joined: 28 Nov 2006 Posts: 552 Location: Brazil
|
Posted: Thu Dec 15, 2016 2:29 am Post subject: |
|
|
Why don't you use emerge -1 and emerge --depclean later? Am I missing something? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Thu Dec 15, 2016 3:19 am Post subject: |
|
|
I would rewrite the script as follows (untested):
Code: | #!/bin/bash
# unchanged
umlist="$(mktemp --suffix=".lst" "umerge_list_XXXXX")"
# preserve exit code
dialog --title 'Dialog unmerger' --single-quoted --no-items --checklist 'Select packages to unmerge' 0 0 0 --file <(awk '{sub(/:/,"-"); print $0 " off"}' /var/lib/portage/world | sort) 2> "$umlist" || exit $?
clear
# Avoid UUOC; avoid in-place sed; unlink $umlist sooner
xargs -a <( sed -e "s/'//g" < "$umlist" ; rm "$umlist") emerge -vac
|
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Thu Dec 15, 2016 10:54 am Post subject: |
|
|
Thanks Hu.
I planned to use xrags, but I had earlier experience that interactive (--ask) programs can't take input when run from xargs. I could just remember incorrectly. But I'll try your version as I get back to my PC.
saboya wrote: | Why don't you use emerge -1 and emerge --depclean later? Am I missing something? | I'm not that perfect. ;)
Also with that method I'd forget to add packages I want to stay in the system to the world file. :P |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Fri Dec 16, 2016 2:46 am Post subject: |
|
|
When xargs gets the argument list from stdin, the child processes run with stdin redirected to /dev/null to prevent them trying to consume input meant for xargs. However, if xargs is run with --arg-file (short name -a), then child processes get access to stdin as normal because xargs reads from the named file, not from stdin. |
|
Back to top |
|
|
|