Saturday, 7 April 2007

Backup Script

Since I'd got my hands dirty with the portage script already, I decided to automate my backups, which are conveniently small scaled. This Perl script is but a serial execution of widely available shell tools, namely rsync, rm, mv and tar. What it does is it synchronizes the folder you feed in with another one hardcoded into the script (I will change that obviously), in the way such that feeding in /etc will result in $HARDCODEDFOLDER/etc, and an _etc.tar.bz2 in this folder. the tarballs are named with their names, slashes ('/') translated into underscores ('_'). Every time the script is run, first it tries to extract the tarball to $HARDCODEDFOLDER (so that it is extracted as the proper subdirectory), then rsync synchronizes the destination folder to the source folder. It skips identical files, so yay. Finally, it compresses the synchronized version into a tarball and kicks it to its folder.

Download it here.

Portage package.use Helper Script

I have sort of switched to Gentoo; I use it all the time except when I have to rescue Gentoo... It is more hands-on, but tools are definitely stronger. Compiling everything on installation offers a slight speed improvement, but what I really enjoy is the flexibility. You can choose the flags before compilation, compiling features in/out.

The file that you use to inform Portage (Gentoo's package manager) of your choices regarding these flags (USE flags) is /etc/portage/package.use by default. You have to add lines to it all the time, both to compile the source to fit your needs and to keep these settings for when you update this software later on. Syntax is [=]pkg-type/pkgname[version] flagyouwant -flagyoudontwant; the square brackets are for version-specific flags, you have to use them both for the version specific function to work. pkg-type is about the way packages are organized in Portage, examples are media-sound, X11-wm, kde-base.

The problem is, it is cumbersome to use echo "blah/blah flag mlag clag" >> /etc/portage/package.use all the time. Furthermore, if you use this, you will probably end up with duplicate entries (whose consequences, if there are any, I have no idea about), and your package.use file will be really messy; hard to review and modify.

Although I am pretty sure that there is a monstrously strong piece of program available in Portage for this task, I was feeling a bit rusty, so I decided to write a small executable Perl script to handle this. It is called, here's the twist, "use".

You are free to use/manipulate/silently mock it any way you want (oh yeah?). Use it once per package, execute as use [blah/]blah flag mlag -clag. The script will scan package.use file, if there is an existing entry, it will modify it to suit your choice. If not, it will create one. Then it will output in the right syntax back into the file, both lines and use flags sorted alphabetically (in a primitive way).

And feel free to give me feedback. Download it here.

Sunday, 18 March 2007

Wine: DC++ #2

There are some problems with the settings menu in the wine installation of DC++. Although buttons work, checkboxes don't, which is a shame for the verbose configuration menus of DC++. The file hashing works as well, in fact it is trying to hash some 40 gigs right now, it works smoothly, as I have said so often lately.

I also added export PATH=$PATH:~/.wine/drive_c/bin to the /etc/bash.bashrc file so that I can put scripts that run my wine programs into wine's C:\bin, and I can run them from console without having to track down where the executable is. The command that runs DC++, for instance, is:

wine ~/.wine/drive_c/Program\ Files/DC++/DCPlusPlus.exe


I put this in a file, and put the file into C:\bin. I also gave everybody the permission to execute it. I could connect to my servers as well, receive the chat just as perfectly. But I still have a connection problem as I have expected, and these things won me nothing in the short term. Well, long live the "do unnecessary things to avoid doing the necessary stuff" way of thinking.

Wine: DC++

Due to some problems I have been facing with Linux ports of DC++, I decided to try out the Windows version over wine. I am pretty sure that even if this works, my problems are in a lower level and thus won't be fixed. Yet, it's for the thrills as always.

I experimented with an already install DC++ on my Windows partition, it ran just fine on wine.

I will use version 0.698 of wine, just because I ran into it in my download heap and am too lazy to grab one from the net right now.

Installation was smooth as expected. No difference from the original Windows installation. It even polluted my "Other" category in the XFCE menu with its icons. Only two lines were dumped:

fixme:shell:SHAutoComplete SHAutoComplete stub fixme:shell:BrsFolder_OnCreate flags 40 not implemented

Then I ran the program. The initial dump was:

fixme:commctrl:InitCommonControlsEx Unknown class! dwICC=0x4000
fixme:htmlhelp:HtmlHelpW HH case HH_INITIALIZE not handled.
fixme:listview:LISTVIEW_SetColumnOrderArray iCount 11 lpiArray 0x53bad0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
fixme:propsheet:PROPSHEET_UnImplementedFlags PSH_RTLREADING
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0
err:toolbar:TOOLBAR_GetImageListForDrawing bitmap for ID 0, index 0 is not valid, number of bitmaps in imagelist: 0

The GUI is right here, just for the glory:

Saturday, 3 March 2007

Installing JACK

So I wanted to use Rosebud, a music production software, a couple of months ago. It needed some mysterious sound server called JACK. I had a load of trouble trying to get audio and midi work, and I gave it up. Today, I will try again and I will write whatever I do here. Sources are at the end of the post.

So, there are two packages apparently, jackd and oss2jack. First one is the jack daemon, the second one is the OSS emulator for JACK. Here we go.

1. Update the apt sources file so that we can install jackd and oss2jack. Add the line

deb http://neogate.homelinux.org/debian/ edgy sound

to /etc/apt/sources.list file, change edgy to whatever version you have. Also refresh your package list as well by typing

$ sudo apt-get update

to the shell.

2. Install the packages and eventually launch the oss2jack configuration by typing
$ sudo apt-get install jackd oss2jack

It should look something like this:


3. The configuration program asks whether it should replace the alsa oss modules. Since this was my intention to begin with, I said yes. You might say yes to see how it works first.

4. The setup should be done now.

Now apparently we also need a kernel module named fusd-kor. I could not find any precompiled module for my kernel, but you might see for yourself by typing the command

$ sudo apt-get install fusd-kor-module-`uname -r` fusd-kor

So now with what I did:

1. First we install the module assistant:

$ sudo apt-get install module-assistant
$ sudo m-a prepare
$ sudo apt-get install gcc-`grep LINUX_COMPILER /usr/src/linux/include/linux/compile.h | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/'`

2. Then we let the assistant do our dirty work of configuring, building and installing the module:
$ sudo apt-get install fusd-kor-source
$ sudo m-a a-i fusd-kor
$ sudo apt-get install fusd-kor

3. We're done.

Just for kicks, and for higher performance, let's also install the realtime kernel module. You know the drill, but here it goes anyway.

1. Type
sudo apt-get install realtime-lsm-module-`uname -r` realtime-lsm

If it works, yay! Otherwise, proceed.

2. Install the module assistant.
sudo apt-get install module-assistant
sudo m-a prepare
sudo apt-get install gcc-`grep LINUX_COMPILER /usr/src/linux/include/linux/compile.h | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/'`

3. Let the good times roll.
sudo apt-get install realtime-lsm-source realtime-lsm
sudo m-a a-i realtime-lsm

4. Done again.

We have to rechannel esd output from ALSA to our beloved JACK. We do this by installing the package libesd0.
sudo apt-get install libesd0

Remember to make yourself a member of the audio group by:
sudo adduser  audio

if you had not done so previously.

Finally, let's make jackd fire up at every boot. You may not want to do this, some programs like Amarok don't have JACK support. I did not do this.

Edit the /etc/rc.local to have the following lines just before "exit 0".

# Start jackd
nice -n -1 jackd -R -d alsa -p 256 > /dev/null 2>&1 &

# Waiting for jackd to become ready
ISR=0
C=0
while [ "$ISR" = "0" -o "$C" = 4 ]; do
C=$(($C + 1))
jack_lsp TEST > /dev/null 2>&1 && ISR=1
if [ "$ISR" = "0" ]; then
sleep 1
fi
done

# Starting oss2jack
nice -n -1 oss2jack > /dev/null 2>&1 &

# Wait for oss2jack to become ready
# FIXME: make/use a small OSS client, to determine of the OSS device is ready ...
sleep 1

# GNOME will start esd now - wait for it,
# then wait for esd to exit (at the end of session) and kill jackd and oss2jack
sh -c "while [ \"\$(pidof esd)\" = \"\" ]; do sleep 1; done; while [ ! \"\$(pidof esd)\" = \"\" ]; do sleep 3; done; kill $(pidof jackd) $(pidof oss2jack)" &

This is the contents of the script /usr/share/doc/oss2jack/examples/.gnomerc, obviously originally intended as a replacement for ~/.gnomerc in Gnome. I copied this script to my home directory with the name .oss2jack.sh. Whenever I want to use JACK, to use Rosebud for example, I type:

$sudo sh ~/.oss2jack.sh

When I'm done, I terminate the daemon by typing:

$sudo killall jackd

Done with the installation. Configuration may follow.


Sources:
http://www.ubuntuforums.org/showthread.php?t=208488&highlight=jack+install
http://www.linux.com/article.pl?sid=06/01/03/1728227

Friday, 2 March 2007

Configuring xserver-xorg

A simple walkthrough for sudo dpkg-reconfigure xserver-xorg.

1. Well, the configuration starts with a screen that lists graphics card drivers. You do need to know this, but I will just demonstrate through my configuration. If you need to find out what you are using you can go to your computer manufacturer's website, or if you have another OS, could check it from there as well. I will go with nvidia.

Note to NVidia users: There are (probably) two drivers for you here; nv and nvidia. nvidia is the official linux driver, and works flawlessly as far as I can tell. nv is a user-developed driver, and it has presented me with problems when it comes to glx, so I would recommend against it unless you know that it's not the case for you or you know how to tweak to get it right. If you do, let me know.

If you don't have nvidia drivers in the list, you might want to get automatix2 installed (sudo apt-get install automatix2). It is an easy way to automate the installation of commonly used packages such as the nvidia drivers.

2. Coming soon...

Thursday, 1 March 2007

Basic X Tasks

Restarting the X Server: Press Ctrl+Alt+Backspace

Starting the X Server from Terminal:
$
startx

Configuration Tool for xorg.conf:
$
sudo dpkg-reconfigure -phigh xserver-xorg