rpmdepclean – Uninstalling unnecessary RPMs

I spent a couple of sleepless nights to switch from Gentoo Linux to Fedora Core, since I became a Red Hat employee. Although Fedora Core is really a nice Linux distribution, I still miss the concept of ‘world’ in Gentoo.
When a user installs a Gentoo package, the name of the installed package is appended the ‘world’ file. What’s interesting is that the dependencies of the installed package are not added to the ‘world’ file. What happens when you uninstall the package registered in the world file is that the name of the package is removed. It’s very simple, but it’s powerful when you don’t want unnecessary packages take up disk space. (Yeah, I am a paranoid. 🙂
Now, from the world file, we know what packages were installed by our own request and what were installed just as dependencies, so Gentoo can identify the unnecessary packages that is safe to be removed. Consequently, running ‘emerge --depclean‘ cleans up all the unnecessary packages.
Can’t we do this in Fedora Core or any RPM-based Linux distribution? The answer is yes.
First off, you have to install ‘rpmorphan‘. rpmorphan has the ‘keep’ file which does the same role with the ‘world’ file. It’s located at /var/lib/rpmorphan/keep, which should be empty initially.
Let’s try to find what packages are unnecessary:

$ rpmorphan -all

Unfortunately, you will see so many essential packages that you want to keep. It’s just because you didn’t add them to the ‘keep’ file yet. For example, you can add ‘gnome-terminal’ to the keep file like the following:

$ rpmorphan -add-keep gnome-terminal

Once you finished adding all the packages that you want to keep to the keep file, now you are ready to run the following shell script file (rpmdepclean).

#!/bin/sh
# rpmdepclean
while true; do
    ORPHANS1="`rpmorphan --all | xargs echo`"
    if [ -n "$ORPHANS1" ]; then
        echo -n "$ORPHANS1 "
        yum -q -y remove $ORPHANS1 > /dev/null 2>&1 || exit 1
    fi
    ORPHANS2="`rpmorphan --guess-all | xargs echo`"
    if [ -n "$ORPHANS2" ]; then
        echo -n "$ORPHANS2 "
        yum -q -y remove $ORPHANS2 > /dev/null 2>&1 || exit 1
    fi
    if [ -z "$ORPHANS1" ] && [ -z "$ORPHANS2" ]; then
        echo
        exit 0
    fi
done

Please double-check you added required packages to the keep file. Otherwise, things can go screwed up. You have been warned. If you are in doubt, you can always run yum remove manually, which is safer.

My Favorite Text Editor – SciTE

Finally, I’ve found the text editor that fits exactly to me, highly-customizable, feature-rich and fast-launching. It’s called ‘SciTE‘. Because the command is not so comfortable to type, I created two symbolic links after uninstalling gedit.

$ ln -s /usr/bin/scite notepad
$ ln -s /usr/bin/scite gedit

The following is my ~/.SciTEUser.properties:

code.page=65001
output.code.page=65001
LC_CTYPE=ko_KR.UTF-8
position.width=850
position.height=700
check.if.already.open=1
buffered.draw=1
tabbar.visible=1
tqabbar.multiline=1
toolbar.visible=1
toolbar.usestockicons=1
statusbar.visible=1
caret.fore=#FF0000
caret.width=2
caret.line.back=#00FF00
caret.line.back.alpha=20
line.margin.visible=1
line.margin.width=4
margin.width=16
blank.margin.left=4
blank.margin.right=4
wrap=1
wrap.style=2
cache.layout=3
output.wrap=1
output.cache.layout=3
wrap.visual.flags=1
wrap.visual.flags.location=0
wrap.visual.startindent=0
edge.column=79
edge.mode=1
edge.colour=#C0DCC0
selection.fore=#006000
braces.check=1
braces.sloppy=1
# Brace highlight
style.*.34=fore:#0000FF,back:#C0DCC0,bold
tabsize=4
indent.size=4
use.tabs=0
tab.indents=1
quit.on.close.last=1
default.file.ext=.txt
strip.trailing.spaces=1
ensure.consistent.line.ends=1
find.replace.advanced=1
find.files=*.java *.xml *.txt *.c *.h *.cpp *.hpp
font.base=font:!Liberation Mono,size:11
font.small=${font.base}
font.comment=${font.base}
font.code.comment.box=$(font.comment)
font.code.comment.line=$(font.comment)
font.code.comment.doc=$(font.comment)
font.code.comment.nested=$(font.comment)
font.text=${font.base}
font.text.comment=${font.comment}
font.embedded.base=${font.base}
font.embedded.comment=${font.base}
font.monospace=${font.base}
font.vbs=${font.base}
# Printing
command.print.*=paps --font="Monospace 10" "$(FileNameExt)" | lpr

Please note that I chose Liberation Mono as the default font. You might want to use other alternatives like DejaVu Sans Mono, Monaco, and Consolas.

The Reason Why Time Goes By So Fast Like This

… is probably because I am having really great time in Red Hat. There was a Remoting team meeting in Switzerland last month and I also attended the October new hire orientation in Singapore. Both countries were fantastic to me. People, city … almost everything. Especially, I can’t forget the moment with my wife in Switzerland. I’d love to visit there again whenever there’s a chance.

Working at remote is much more exciting than I expected. People might think working at remote makes one lazy, but it’s exactly opposite. I get to keep watching myself to make sure that I am not wasting time. Although it is not really comfortable that all my teammates and manager are not in a close time zone (two in the US and one in Switzerland), it’s also one of the factors that make me do my best to catch up all the events occurring in the division. I must admit it’s somewhat difficult to catch up everything, but hopefully I will be used to this new world, and moreover, it means that Red Hat / JBoss is a very dynamic workplace that will accelerate my experience.

MINA community is also growing up very nicely. Hopefully we will be able to release the first milestone of 2.0.0 before OSSummit Asia 2007, where I will attend as a speaker. (and that might be why I am working so hard on MINA. 😉

In the middle of the fast-flowing time, I often think about many things I have never thought about before. The thoughts are somewhat fragmented to describe, but it is sure that it’s about ‘growing up’ – becoming a better and more mature person. At least I hope so.