Monday, June 9, 2008

Problems after installing lfs

Whether building linux from scratch manually or automatically, there are many opportunities to work on linux problem solving skills.

A newly built LFS system may not be easy to boot after shutdown unless you properly prepare a boot loader. The section in the book about Making the LFS System Bootable provides some examples as guidance.

A newly built LFS system will not have any gui until you install the X Window System from the BLFS book.

If these do not get installed and set up before shutting down, it can be difficult to boot and all work would be done in the dark with only text console logins. However, I found that jhalfs can run from within the text console environment and I wanted to try that.

Entering the chroot environment from the host system provides a means to install and set up things that did not get done before. Software from the BLFS book can be installed on the new system from within the chroot environment. Though it is possible to install from the BLFS book using a text browser like lynx, this is extreme.

After the LFS build had finished, I had several occasions to retreat to the host system and chroot to the new one. I created a text file to use as guidance:
export LFS=/mnt/build_dir &&
mount -v --bind /dev $LFS/dev &&
mount -vt devpts devpts $LFS/dev/pts &&
mount -vt tmpfs shm $LFS/dev/shm &&
mount -vt proc proc $LFS/proc &&
mount -vt sysfs sysfs $LFS/sys &&
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login +h

- Set a password for the root user.

- Edit or create /etc/fstab, /etc/hosts, /etc/sysconfig/clock, /etc/sysconfig/console, /etc/sysconfig/network, etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and any other configuration file required to suit your needs.

- Likely, dhcp will be needed for network access on the new system. From the chroot, I installed dhcpcd-2.0.8 as per the BLFS book.

Here's my /etc/sysconfig/network-devices/ifconfig.eth0/dhcpcd
ONBOOT="yes"
SERVICE="dhcpcd"
DHCP_START=""
DHCP_STOP="-k "
# Set PRINTIP="yes" to have the script print
# the DHCP assigned IP address
PRINTIP="no"
# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
PRINTALL="no"

I wanted to try installing from xfce4 the BLFS book with jhalfs. I have learned from previous attempts what is also needed to build xfce4, so I installed these from the chroot:
wget-1.10.2
bc-1.06
lynx2-8-6
libxml2-2.6.26
libxslt-1.1.17
HTML Tidy-051026
Subversion-1.3.1
DocBook XSL Stylesheets-1.69.1
URI-1.35
Python-2.4.4
XML-Parser-2.34
which-2.16
hicolor-icon-theme
shared-mime info

- Then I could get the jhalfs-2.2.tar.bz2 from http://www.linuxfromscratch.org/alfs/downloads with wget and try jhalfs-2.2 to build BLFS packages on the new system.

I found in the "make" screen that one of the dependencies could be changed from xorg7 to xorg. I made that change because that is xorg6 which had worked for me before.

The jhalfs software solved the dependencies for xfce which included setting up the install of xorg. Durring the build, it bombed a few times and I had to investigate the logs and other resources so that the build could continue.

Once it managed to get through the building of xorg6, I found that I could get to a gui by running startx which started up twm. This showed a glimmer of daylight that was welcome while I continued to struggle to get xfce to build.

Had trouble building glib2 because /etc/profile.d was missing.
Pango didn't build right unless I did ldconfig /usr/X11R6/lib.
Those 2 things should have reminded me to go back and work through the BLFS book chapter 3 section about the bash shell startup files.

The jhalfs script for xfce didn't work and had to be modified. It needed a "do loop" to install the sub-packages in xfce in the correct order. Also, I wanted to install xfce-4.4.1 instead of xfce-4.2.3.2, so I modified it accordingly.
This is the scripts/019-z-xfce that mostly worked:
#!/bin/bash
set -e

SRC_ARCHIVE=$SRC_ARCHIVE
FTP_SERVER=$FTP_SERVER

PACKAGE=xfce-4.4.1-src.tar.bz2
PKG_DIR=xfce
SRC_DIR=$SRC_DIR

mkdir -p $SRC_DIR/$PKG_DIR
cd $SRC_DIR/$PKG_DIR
if [[ ! -f $PACKAGE ]] ; then
if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then
cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE $PACKAGE
elif [[ -f $SRC_ARCHIVE/$PACKAGE ]] ; then
cp $SRC_ARCHIVE/$PACKAGE $PACKAGE
else
wget ${FTP_SERVER}conglomeration/$PKG_DIR/$PACKAGE || \
wget http://downloads.sourceforge.net/xfce/xfce-4.4.1-src.tar.bz2
fi
fi
echo "dfb3e3c1bdaa4eb94301c0de5a67b9de $PACKAGE" | md5sum -c -

if [[ -e unpacked ]] ; then
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
rm -rf $UNPACKDIR
fi
tar -xvf $PACKAGE > unpacked
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
cd $UNPACKDIR

SUB_DIR=$UNPACKDIR

for SUB_PACKAGE in xfce4-dev-tools-4.4.0.tar.bz2 libxfce4util-4.4.1.tar.bz2 libxfcegui4-4.4.1.tar.bz2 libxfce4mcs-4.4.1.tar.bz2 exo-0.3.2.tar.bz2 xfce-mcs-manager-4.4.1.tar.bz2 xfce-mcs-plugins-4.4.1.tar.bz2 xfce4-panel-4.4.1.tar.bz2 Thunar-0.8.0.tar.bz2 xfce4-session-4.4.1.tar.bz2 xfwm4-4.4.1.tar.bz2 xfdesktop-4.4.1.tar.bz2 xfce-utils-4.4.1.tar.bz2 gtk-xfce-engine-2.4.1.tar.bz2 mousepad-0.2.12.tar.bz2 xfce4-appfinder-4.4.1.tar.bz2 xfwm4-themes-4.4.1.tar.bz2 xfce4-icon-theme-4.4.1.tar.bz2
do

cd $SRC_DIR/$PKG_DIR/$SUB_DIR/src

if [[ -e unpacked ]] ; then
SUB_UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
rm -rf $SUB_UNPACKDIR
fi
tar -xvjf $SUB_PACKAGE > unpacked
SUB_UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
cd $SUB_UNPACKDIR
./configure --prefix=/usr --sysconfdir=/etc &&
make
make install
ldconfig

cd $SRC_DIR/$PKG_DIR/$SUB_DIR/src
rm -rf $SUB_UNPACKDIR unpacked

done

cd $SRC_DIR/$PKG_DIR
rm -rf $UNPACKDIR unpacked

exit


Things were working well while I was naughtily running as root. When I ran startxfce4 as a regular user I got the annoying surprise that the directory /tmp/.ICE-unix must be owned by root and it was not. As a result, ICE crashed it back down to the text console.
The error messages were:
_IceTransmkdir: ERROR: Owner of /tmp/.ICE-unix must be set to root
_IceTransSocketUNIXCreateListener: mkdir(/tmp/.ICE-unix) failed, errno = 1
_IceTransMakeAllCOTSServerListeners: failed to create listener for local
xfce4-session: Unable to establish ICE listeners: Cannot establish any listening sockets


After some searching, I was inspired to read the BLFS book section for X Window System Components where I found the fix which
creates the /tmp/.ICE-unix with owner root in one of the startup scripts.

Apparently, the Inter Client Exchange library for X (libICE) creates the .ICE-unix directory when it is first needed, and it will get the permissions of a regular user if the regular user is the first to need it. It insists that the directory must be owned by root. On a typical system, all (or most) of the contents of the tmp directory are cleared out when the system shuts down. This includes removing the .ICE-unix directory. So, there needs to be some mechanism to create this directory at system startup when the de-facto user is root. I am not sure if an X Display Manager like XDM, GDM, KDM would take care of this. That remains as an experiment to do someday.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Click blog title for the latest post