Recently in Gentoo GNU/Linux Category

Using Gentoo on a server without C++ compiler

| 1 Comment | No TrackBacks

After reading a post by Diego E. Pettenò about replacing groff with heirloom-doctools leading to having nearly no C++ programs in a Gentoo system, I tried to rebuild all packages on my Gentoo-using server without C++. The main difference is that my computer compiles all packages instead of using another system for this, so I need also all build dependencies of useful packages compiling and working without C++.

I started by adding the nocxx -cxx USE flags to everything except GCC. Rebuilding affected packages showed that app-arch/lzma-utils has programs written in C++ for everything except decompression. So I checked on my unstable Gentoo workstation that its app-arch/xz-utils does not have programs linking to libstdc++, which is nearly equivalent to using C++. Therefore I added app-arch/xz-utils to /etc/portage/package.keywords and installed it. Now both LZMA and XZ compression formats may be both compressed and decompressed, without any C++ code.

Since C++ support is assumed to be in every system, the package manager cannot determine which packages use it. Therefore I decided to check which programs link to the C++ standard library. The following shell script lists all files on $PATH which link to libraries containing ++ in their names:

#!/bin/sh

for directory in `echo $PATH | sed 's/:/ /g'`;
do
  for f in $directory/*
  do
    if file $f | grep ELF > /dev/null
    then
      list=`readelf -dw $f | grep Shared \
        | sed -r 's/^.*\[(.*)\].*$/\1/' | fgrep ++`
      if [ $? = 0 ]
      then
        echo $f
      fi
    fi
  done
done

Passing the output of the script to xargs qfile -q | sort -u listed packages having these files.

The only necessary packages on my system listed by the above pipe were app-arch/lzma-utils and sys-apps/groff, but they can be easily replaced by app-arch/xz-utils and app-doc/heirloom-doctools.

Then I compiled sys-devel/gcc with the nocxx USE flag and ran emerge -ev --keep-going world.

Next day I saw that build failed for 27 packages. Some of them, like sys-apps/sed had just failing tests for completely unrelated reasons. Many other packages, like sys-devel/libtool have tests using C++. So I recompiled all such packages with FEATURES=-test. Now only 12 packages failed.

The rest failed mostly when running the configure script, with messages like this:

checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check

These were caused by useless checks for C++ compiler made by older versions of libtool. In case of dev-libs/popt and sys-apps/shadow updating to the testing version solved this, but for some other packages adding eautoreconf to their ebuilds was necessary.

After these changes the only packages with build errors were dev-libs/apr, net-libs/courier-authlib and net-mail/courier-imap. The first one also fails at the configure check, while the rest uses some C++ code which is not installed.

The modified ebuilds are available in my overlay. I haven’t reported any of the problems observed to the Gentoo Bugzilla, since I cannot access it today and the changes would just make compilation slower in all normal uses.

Installing ReactOS on KVM virtual machine on Gentoo

| No Comments | 2 TrackBacks

It is useful to access more then one operating system when writing a program designed to be used with a different one. This is one of situations where platform virtualization is helpful. This post describes how I used KVM on a Gentoo GNU/Linux host to use ReactOS on a virtual machine.

In Gentoo’s Portage tree KVM userspace part is available as app-emulation/kvm. By default it uses its own modules, but this can be disabled by emerging it with USE flags havekernel -modules when the kernel has appropriate options enabled.

The ebuild states that user running KVM must be in the kvm group. So I added my user to this group using recommended gpasswd -a <USER> kvm To avoid logging out, I used su - <USER> in a terminal emulator, but this did not solve the problem. Then I read that this package also added rules for udev changing the group of /dev/kvm to kvm. Since I hadn’t restarted udev, I used chgrp kvm /dev/kvm as root to have this set before next reboot. Then KVM worked correctly.

KVM looks simple to use without reading the whole manual. The command kvm-img create c.img 4G made a disk image of $ GiB in the file named c.img, then I could use KVM with this by just specifying this file as a disk of the virtual machine. I used kvm -hda c.img -cdrom ReactOS.iso to install this system. It worked correctly and except for nicer keybindings similar to installation of Microsoft Windows.

After starting the newly installed system I noticed a trivial problem, kvm by default uses UTC time, while ReactOS (like Windows) supports only localtime. After checking it in the man page, I added the -localtime option to this command.

Since network access would be useful, I tried to configure it. Fortunately, KVM has not only a man page but also several HOWTOs on its website, one of them shows how to configure networking. I used user networking with additional options -net nic -net user, since it is the simplest to configure. But ReactOS didn’t have a driver for the default virtual NIC. When I had similar problem with Windows XP on real hardware, I changed the NIC to a different one, then another (from newest to oldest one), then to a one with a CD containing drivers. ReactOS website has a list of supported NICs which shows that most of them require downloading non-free drivers. But PCnet has included drivers and is supported by KVM, so I changed -net nic to -net nic,model=pcnet and it worked correctly.

Documentation of KVM shows that much more can be done in this case. It is nice to use working software with man pages encouraging learning about it.

Using distcc with Gentoo

| No Comments | No TrackBacks

In home I use a computer with a quad-core AMD Phenom processor. Outside I use a laptop with a slow dual-core AMD Athlon 64 and only 2 GiB of RAM. Both are using Gentoo GNU/Linux. Since I update software on the laptop less often then once per week, it spends much time compiling it. Today I decided to use distcc for the Phenom-based computer to do some of this work instead of the laptop.

I used the official Gentoo Distcc Documentation to configure it. In my case it is simpler then described there. On the ‘slave’ computer I just installed distcc by emerge distcc, then changed the allowed IPs to my IPs in /etc/conf.d/distccd and started the service by /etc/init.d/distccd start (then rc-update add distccd default requested it to be started at each boot).

On the laptop I did the above and also edited the list of hosts used in /etc/distcc/hosts and two parameters for Portage integration in /etc/make.conf. Both required some experimentation to have load average on both computers below their number of cores. In the first one I finally specified only the IP of the Phenom-using machine. In the second one I added distcc to FEATURES and set MAKEOPTS to -j9 which was recommended by the documentation when using 4 cores.

top shows that this works. I should also change this configuration for packages which do not support distcc.

Most electronic mail clients support storing mail in folders; all of these which I used support filtering new mails into appropriate folders. When mail is divided into several folders, e.g. for some mailing lists to which I’m subscribed or for some automatically sent messages, it is easier to manage it. I prefer to read more important mail before the less important one (or less important first?) and these folders make it nicer.

It’s fine with one computer running a mail client, but the situation becomes more complicated with two computers. Then IMAP is necessary (excluding the use of webmails, but they usually use only a single computer). It is the protocol which stores mail on the server, is fast and allows realtime notifications for new messages (this feature is not currently supported by Kmail, but is planned).

I use IMAP since I first configured my mail server. Initially because most free software webmails require IMAP, but about a year later I began to access my mail from two computers. The filters were done by only one of the mail clients, so they became less useful. I could have configured them on both of my client computers, but it would require sharing the settings.

I have only one mail server, so I decided to filter the mail on the server. Quickly I found the well-known Procmail program used for that. Since I use Gentoo GNU/Linux operating system, I installed the mail-filter/procmail package. To my Postfix SMTP server configuration file /etc/postfix/main.cf I added

mailbox_command = /usr/bin/procmail

just as the comment in the file shows (as stated by the comment, I forward root’s mail to my normal user). Then the command /etc/init.d/postfix reload requested Postfix to reload the configuration file.

In my home directory I put a file .procmailrc instructing Procmail what to do with my mail. It begins with

MAILDIR=$HOME/.maildir/
LOGFILE=$HOME/.procmaillog
LOGABSTRACT=no
VERBOSE=off

which contains generic parameters used by Procmail. I use maildirs with the default Gentoo path of $HOME/.maildir. For all maildirs the trailing slash should be used in Procmail configuration, since it specifies the file format. I learned it by finding an mbox file when the slash was omitted.

Then specific recipes are stated. One of the ones which I use is

:0
* ^From: *forum-mods@gentoo\.org$
$MAILDIR/.gentoo-forums/

The first line begins with :0 and may contain specific flags which I don’t use in this recipe. The lines beginning with an asterisk contain an extended regular expression which is by default matched in the mail headers (in this case the sender address). If all conditions are satisfied, then the action specified in the last line is performed. Here it moves the mail to the gentoo-forums folder in my mailbox.

I don’t use more complicated recipes in my .procmailrc file. See the procmailrc(5) man page for the complete syntax of these files. Features explicitly stated in the man page look similar to filtering features of the Kmail mail client, but there are much larger possibilities.

Why I use Gentoo

| No Comments | No TrackBacks

Today I found a website encouraging using GNU/Linux instead of non-free operating systems (not exactly true, but not more incorrect than the popular use of ‘Linux’). It presents Ubuntu, Fedora and gNewSense as appropriate distributions for new users. I used the first two of these distributions some years ago (before the gNewSense project began), so I decided to write how my attitude towards the user-friendliness of them changed.

Initially I used a GNU/Linux distribution made by RedHat (I don’t remember if I called it like that, but probably I knew the reasons for this). Then I used one made by Mandriva, it had better support for some hardware. Some time later I used Fedora, since the previous distribution was difficult to update.

Then I discovered the reason for which now I don’t use Fedora or similar distributions – it was new twice per year, later only small changes were made. I did not like frequent reinstalling of operating systems.

Later a failing hard disk encouraged me to try a different operating system. I installed FreeBSD (then version 5.4; it was the only operating system for which I paid). It did not require reinstalling for a CD, but still the core system had to be completely rebuilt for any change. FreeBSD also has a source-based package manager which makes software installation slower, but leading to more optimal software for the machine on which it was used. I previously wrote about an advantage of source-based systems, but then I didn’t use these features (I did not have a DVD player and I knew much less about fonts).

Later I used Kubuntu. It had better support for hardware which I used. It also had many patches to popular software which probably were not used in FreeBSD. Maybe it was easy to use for a user of Microsoft Windows, but for me it was difficult. I wrote about some problems which apply to it just like to Debian Sid which I now use on my laptop.

Since 2007 I use Gentoo, although in that year I used also Ubuntu and now I use Debian on one of my three computers. Gentoo has several advantages for which I still use it:

  • it is a continuous distribution – a release is only for installing (and for news sites), then all of them may be updated to the newest system
  • USE flags allow simple selection of needed features of installed software
  • it is so fast that Firefox is usable
  • newer than officially released software may be used easily, necessary for kernel and graphics drivers on some hardware
  • it is simple to improve, writing ebuilds is easy after reading some
  • it had no working GUI installer when I installed it for first time, so no data was lost and I knew exactly what was done
  • it may be easily administered remotely (clear structure of /etc, no GUI configuration tools are necessary)
  • only necessary software is installed by default, nearly all services enabled are necessary

Gentoo is useful for learning how GNU/Linux works. Of course, this is the main reason against using it, and the time needed to compile KDE or GCC is the second one.