January 21st, 2011 § § permalink
Simplify your bash PATH management with pathmunge. The pathmunge will add a directory to the beginning of your PATH if it is missing from your PATH. This means that you can safely .source ~/.bashrc without ending up with duplicate folders in your path (which you would get if you had used export PATH=/add/this/dir:$PATH). It is also clearer what folders you are adding to your path. This goes in your ~/.bashrc:
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
pathmunge /usr/local/blah/bin
pathmunge ~/bin
export PATH
# now PATH is ~/bin:/usr/local/blah/bin:<old path>
As a bonus, you can use pathmunge /dir/to/add after to append the directory to the end of your path instead of the beginning.
Code from TDLP Bash Beginners Guide
October 23rd, 2008 § § permalink
General instructions to rebuild a Fedora source rpm.
Note: This example uses the vlc source rpm, but it doesn’t work on my Fedora 8 system because there are problems installing dependencies, but the general commands should work on other packages
- Install build tools
su -c 'yum install yum-utils rpmdevtools'
- Download source package. Either use yumdownloader to download from an existing repository:
yumdownloader --source vlc
or download directly from a server
wget -nd ftp://ftp.pbone.net/mirror/rpm.livna.org/fedora/development/SRPMS/\
vlc-0.9.0-0.5.20080802git.lvn10.src.rpm
- Install the source package. This will unpack the source into your /$HOME/rpmbuild directory.
rpm -Uvh vlc-0.8.6i-1.lvn8.src.rpm
- Install build dependencies for the source package
su -c 'yum-builddep vlc-0.8.6i-1.lvn8.src.rpm'
- Edit the spec file
cd ~/rpmbuild/SPECS
vim vlc.spec
- Add the new source package
cd ../SOURCES
wget -nd http://download.videolan.org/pub/videolan/vlc/0.9.2/vlc-0.9.2.tar.bz2
- Build the rpm
cd ../SPECS
rpmbuild -bb vlc.spec
- Install the rpm
cd ../RPMS/x86_64
rpm -Uvh vlc-0.9.2.fc8.x86_64.rpm
References:
Building a kernel from the src rpm
Fedora rpm guide
September 1st, 2008 § § permalink
# install deb build tools
sudo apt-get install build-essential fakeroot dpkg-dev devscripts
# download the source code
# install other packages needed to build
sudo apt-get build-dep package
cd package
# update the version in the changelog
# make any changes to the source
# e.g. vim debian/rules
# then build the new package
dpkg-buildpackage -rfakeroot -uc -b
#install the package
cd ..
sudo dpkg -i package.deb