Blog
Monitoring config files with git/cogito and displaying them nicely with gitweb
I recently took a look at the git-webinterface on kernel.org and it really attracted me. I thought it would be nice to manage the config files in my home directory with git and make them available on the net via gitweb.
If you are new to git/cogito i would strongly recommend to investigate a few minutes and work through the README.
In debian you can install git and cogito with apt-get install cogito. And then proceed as explained in the README.
Per default cg-init adds all files in the current directory to the repository which is actually not that useful for monitoring config files in a home directory where only dotfiles are of interest. However newer version of cogito provide a few command line options for us -I is especially handy because it doesn't perform an initial commit at all.
So we are able to set up a git repository without any files by running
cg-init -IAfterwards you can continue by adding further files as you like, if an error occurs at the initional commit you should add the -C option.
cg-add .bash_profileNow that the files are added we can do an initial commit.
cg-commit -m"Initial commit"
For further help with cogito or git read the corresponding manual pages.
So now lets install gitweb.
apt-get install gitwebGitweb expects the git-repostries in /var/cache/git but this can easily be changed by editing /etc/gitweb.conf. However i prefer to symlink the content from my home directory to the default gitweb project directory as shown below.
ln -s /home/marc/.git /var/cache/git/config-files.git
That's it you can know view your repository on http://localhost/cgi-bin/gitweb.cgi (assuming that apache is configured properly of course).
Here is my final git repository to handle my configfiles.
Marc
CMus a ncurses based music player
For those of you who don't know i like ncurses based apps because they usually have a decent interface which can be handled only by keyboard. Therefore the apps can be used almost everywhere even over ssh when no x-server is running and with screen you even have some kind of window manager.
I regularly use vim, mutt and sometimes irssi and now it seems that i have found another great console app the CMus - C* Music Player. It is a full featured music player for the console with support for various file formats, a intuitive interface including playlist handling (sorting,grouping,searching etc.), directory browser, vim-like command line syntax with tab expansion, extremely powerful playlist filters and a lot more.
I suggest you just check it out and read the documentation which is included in the source tarball, it really is a good piece of software.
Configuring CMus to use the also dmix plugin
As i covered in an another blog entry the also dmix plugin can be used to control the access to the sound device and allowing multiple applications to use it at the same time. To configure CMus to use the dmix plugin we just have to change one option in it's config file which is per default located in ~/.config/cmus/config
dsp.alsa.device = "plug:dmix"This could also be done by issuing the following command within cmus in command line mode.
:set dsp.alsa.device=plug:dmix
Hope you enjoy using this cool app.
Marc.
Creating Debian Packages from source with checkinstall
With APT package installation in Debian is really easy. But sometimes you simply can't avoid to install a package from source probably because there is no *.deb package available, it is outdated or you would like to compile it with specific compiler options.
This causes some problems because when you install packages from source the package management software doesn't know about them and therefore you can't really upgrade or remove them in a smooth way. The usual approach to this problem is to install all packages in /usr/local but it actually doesn't really solve the problem either, if you install lots of such packages you will almost certainly end up in a mess.
Here comes checkinstall in, it will observe all modification to the system during package installation and then create a distribuation specific package which can be installed as usual.
Below is an usage example, the -D options tells checkinstall to create a *.deb package. See the documentation for more options.
configure --prefix=/usr
make
checkinstall -DInstead of make install you just type checkinstall or if the build command differs
checkinstall -D make install_command_or_whatever
Checkinstall will ask you a few question and then create and install a regular *.deb file which means that the package is now fully integrated into the package management system and can be removed as usual with apt or dpkg.
Marc
Source Controll Management with bazaar-ng
I recently took a look at bazaar-ng and i am quite impressed, the installation is plain simple (well on debian anyway it's just apt-get install bzr) and the user interface is straight forward either (commands are more or less named as expected).
As an introduction i recommend reading through their wiki. To get started just initialize a new branch and then add further files. With bzr help [command] you get some information about the specified command.
cd your_project_dir
bzr init
bzr add your_file
bzr status
bzr commit your_file -m "Initional commit." # make some changes
bzr status
bzr diff
bzr commit your_file -m "Your comment."
bzr log
So i hope you see how easy it is to handle your source files with bazaar-ng i will use it for a new project and probably blog about my experience with it in daily use later on.
If you have to choose a SCM-System then this comparison might be useful although some newly created ones such as bazaar-ng or git are not yet listed there.
Marc.
Compiling Qemu with Kqemu to run Windows 98 on Debian Sid
For those of you who don't already know qemu is a fast and free emulator comparable with VMWare. Of course there are Debian packages available which you could just install as usual but they do not include the closed source kernel modul (kqemu) which provides major performance enhancements. So we will compile qemu from source.
Compiling qemu from source
Fetch the qemu source code from the webpage and compile it according to the documentation. Adjust the configure flag as you like, for example i basically just need support for i386 and since debian sid is now using GCC 4.x but qemu doesn't compile with it yet i had to point it to an older version so i did the following
cd /tmp
tar zxvf qemu-0.7.2.tar.gz
cd qemu-0.7.2
tar zxvf /tmp/kqemu-0.7.2.tar.gz
./configure --cc=/usr/bin/gcc-3.3 --target-list=i386-softmmu
make
# and as root
make installTo meet a few dependencies i had to further install the two following packages.
apt-get install libsdl1.2-dev
apt-get install zlib1g-devPer default qemu will be installed in /usr/local, a new device node /dev/kqemu should automatically be created if this is not the case you should do it manually.
mknod --mode=0666 /dev/kqemu c 250 0
Preparing the kernel for network support via tun/tap devices
If you want your virtual machine connected to the host there are two different ways to accomplish this. One is with the -user-net command line switch which will set up a dhcp server for you (refer to the documentation for further information), the other is to use tun/tap devices. For the latter you obviously need tun/tap support activated in your kernel, below are the relevant settings.
Symbol: TUN [=y]
Prompt: Universal TUN/TAP device driver support
Defined at drivers/net/Kconfig:85
Depends on: NETDEVICES
Location:
-> Device Drivers
-> Network device support
-> Network device support (NETDEVICES [=y])
Selects: CRC32Afterwards you may have to set appropriate permissions for your /dev/net/tun device.
chgrp users /dev/net/tun
chmod 660 /dev/net/tun
Creating a virutal disk image
Qemu uses a file to represent the content of the virutal harddisk which can be created as follows.
qemu-img create -f raw win98.img 1000MThe file will grow as more software gets installed to the system.
Installing Windows 98 from a bootable CD
To install Windows you can either boot from the CD or use a boot floppy if you don't have one download one from here. Then run qemu with the floppy drive and virtual disk image connected and let it boot from floopy (-boot a). Make sure that you launch the newly compiled qemu which per default is located in /usr/local/bin.
qemu -hda win98.img -fda /dev/fd0 -boot aWith slightly different options qemu boots from CD.
qemu -hda win98.img -cdrom /dev/hdc -boot dAdditionally you can add an option for your keyboard layout for example
-k de-ch
take a look in /usr/locale/share/qemu/keymaps for valid values.
When Windows first boots up go to the command line by pressing SHIFT + F5 and create a empty primary partion on the harddisk with fdisk, then reboot and process the installation from CD-ROM as you would do it on a normal computer.
I would recommend to keep the cdrom drive connected to the VM until you successfully logged in the system for the first time, because Windows will need various drivers from it.
When the installation is completed you can boot your image with the command below.
qemu -hda win98.img -boot cYou will probably notice that with Windows 98 as guest the cpu load is very high even if you do nothing special in your VM, this is a known problem and here is the solution.
Qemu monitor
If you want to change the cdrom while your VM is running then switch to the QEMU monitor by pressing CTRL+ALT+2 and issue the following command.
eject cdrom
change cdrom /dev/cdromyou can see the changes with
info blockto switch back to the VM use CTRL+ALT+1
Set up networking for the virual machine
My network looks like this.
+-------------------------+ +----------------------+
| host pc with debian/sid | ==============> | Router with NAT/DHCP |
| eth0: 192.168.1.2/24 | | 192.168.1.1/24 |
| tun0: 192.168.2.1/24 | +----------------------+
| gw: 192.168.1.1/24 | ||
| dns: 192.168.1.1/24 | ||
+-------------------------+ \/
/\ +----------+
|| | Internet |
|| +----------+
+-------------------------+
| qemu with windows 98 |
| eth0: 192.168.2.2/24 |
| gw: 192.168.2.1/24 |
| dns: 192.168.1.1/24 |
+-------------------------+
So i had to set up a iptables rule to translate the 192.168.2.x IPs so that the internet is accessible from the Windows box.
Qemu will try to execute /etc/qemu-ifup on startup to configure the tun device. The commands in there need root privilleges so i created another file called /etc/qemu-net-config containing the following.
#!/bin/sh
# $1 => tun0
/sbin/ifconfig $1 192.168.2.1 up
echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEThen i configured sudo to allow the user to execute this file without prompting for a password. Therefore my /etc/qemu-ifup (which gets executed by qemu) look like this.
#!/bin/sh
sudo /etc/qemu-net-config $1
As a last step i had to configure the network in Windows ip: 192.168.2.2 gateway: 192.168.2.1 and finally dns: 192.168.1.1.
With this setup everything worked as expected. After the initional configuration of your VM i would recommend making a copy of your disk image so you can always switch back to a clean install.
Hope you get it to work too. As a last point i would like to mention http://free.oszoo.org/ which provides various ready-to-run qemu images.
Marc.
