Blog

Tracking Config Files with Git, Cogito and Gitweb

01.11.2005 at 11:31

I recently took a look at the gitweb interface 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 dot files 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 -I

Afterwards you can continue by adding further files as you like, if an error occurs during the initial commit you should add the -C option.

cg-add .bash_profile

Now 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 gitweb

Gitweb expects the git repositories 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 a default web server configuration).

Marc

read more comments

CMus a Curses Based Music Player

22.10.2005 at 21:16

I like console based programs because they usually have a decent interface which can be controlled only by keyboard facilitating usage in any environment including SSH sessions when no X server is available. 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 useful console application 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 ALSA dmix plugin

As I covered in an another blog entry the ALSA dmix plugin can be used to control access to the sound device and allow 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 ~/.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

Marc

read more comments

Creating Debian Packages from Source with Checkinstall

21.10.2005 at 20:38

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 with a mess.

Here comes checkinstall in, it will observe all modification to the system during package installation and then create a distribution specific package which can be installed as usual.

Below is an usage example, the -D options tells checkinstall to create a Debian package. See the documentation for more options.

configure --prefix=/usr
make
checkinstall -D

Instead 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

read more comments

Source Controll Management with Bazaar-ng

14.10.2005 at 12:09

I recently took a look at bazaar-ng, the installation is plain simple (well on Debian anyway it's just apt-get install bzr) and the user interface is also straight forward (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

I hope you see how easy it is to handle your source files with bazaar-ng I might use it for a new project.

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

read more comments

Compiling Qemu with KQemu to Run Windows 98 on Debian Sid

02.10.2005 at 14:09

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 module (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 yet compile with it. I had to point it to an older version as follows:

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 install

To meet a few dependencies I had to further install the two following packages.

apt-get  install libsdl1.2-dev
apt-get install zlib1g-dev

Per 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: CRC32

Afterwards 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 virtual disk image

Qemu uses a file to represent the content of the virtual hard disk which can be created as follows.

qemu-img create -f raw win98.img 1000M

The 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 a

With slightly different options qemu boots from CD.

qemu -hda win98.img -cdrom /dev/hdc -boot d

Additionally 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 an empty primary partition on the hard disk with fdisk, then reboot and proceed with 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 c

You 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/cdrom

you can see the changes with

info block

to 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 privileges 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 MASQUERADE

Then 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 initial configuration of your VM I would recommend to make 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 the free OS zoo which provides various ready-to-run qemu images.

Marc

read more comments

<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 >>