User:RussK/Create 2007 kurobox Gentoo

Note, this is for the original kurobox or kurobox HG, however it should in theory support the ppc LS boxes too. I'm going to document the steps I'm taking to create a new gentoo 15-minute image. That way someone else can duplicate the steps. It also helps to redo the steps quickly if something goes wrong somewhere along the way.

Create chroot area
I am creating a chroot area and starting with the previous 15-minute image.


 * 1) cd /datafiles/chroots
 * 2) mkdir gentoo-20071104-uboot
 * 3) cd gentoo-20071104-uboot
 * 4) tar xjf ../gentoo-20060907-uboot.tar.bz2

Enter the chroot environment

 * 1) cd /
 * 2) cp /etc/resolv.conf /datafiles/chroots/gentoo-20071104-uboot/etc/resolv.conf
 * 3) mount -t proc none /datafiles/chroots/gentoo-20071104-uboot/proc
 * 4) chroot /datafiles/chroots/gentoo-20071104-uboot /bin/bash
 * 5) env-update
 * 6) source /etc/profile
 * 7) export PS1="(chroot) $PS1"

update the portage tree and portage

 * 1) emerge --sync
 * 2) emerge portage
 * 3) etc-update  # to update config files, just accept all changes

Copy the previous overlay area to a new area for modifying

 * 1) cd /usr/local/portage/
 * 2) mkdir kuro-2007-11-04
 * 3) cd kuro-2006-08-26
 * 4) find . -depth -print | cpio -pdmuv ../kuro-2007-11-04

Copy the previous profile to a new profile

 * 1) cd /usr/local/portage/kuro-2007-11-04/profiles/kurobox-uboot
 * 2) mkdir 2007.0
 * 3) find . -type f -print | cpio -pdmuv 2007.0

Change the parent profile to a newer base

 * 1) cd 2007.0
 * 2) nano parent
 * 3) change the line to: ../../../../../../portage/profiles/default-linux/ppc/ppc32/2007.0

Edit the packages file

 * 1) nano packages
 * 2) remove the second group of lines that pin us to certain versions of packages like baselayout etc

Resulting packages file looks like: -*sys-apps/eject -*sys-apps/fbset -*sys-apps/kbd -*sys-fs/hfsutils -*sys-fs/hfsplusutils -*sys-fs/mac-fdisk -*virtual/bootloader -*virtual/dev-manager -*virtual/os-headers

Edit the virtuals file
I'm not exactly sure what the file is for but I know the kurobox-sources thing does not exist.
 * 1) nano virtuals
 * 2) comment out the virtual line with a '#' sign

Resulting file:
 * 1) virtual/linux-sources  sys-kernel/kurobox-sources

Switch to the newly created profile

 * 1) cd /etc
 * 2) rm -f make.profile
 * 3) ln -s ../usr/local/portage/kuro-2007-11-04/profiles/kurobox-uboot/2007.0 make.profile

Edit the make.conf file for new changes
Change the overlay directory, remove bogus USE flags, remove excludes directive


 * 1) nano make.conf

Resulting file:

CFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char" CXXFLAGS="${CFLAGS}" PORTDIR_OVERLAY="/usr/local/portage/kuro-2007-11-04" USE="-X -gtk -gtk2 -gnome -qt -kde -opengl -motif -xmms -arts -alsa -oss -ipv6 samba cups usb"
 * 1) Kurobox make.conf

Update dhcpcd first
dhcpcd is blocking the baselayout update. This is probably related to the fact that baselayout was pinned in the old profile.


 * 1) emerge --update dhcpcd

Update glibc

 * 1) emerge --update glibc

Run etc-update after glibc
Accept change for nscd
 * 1) etc-update

Completely rebuild everything
This takes a long long time
 * 1) emerge --emptytree system && emerge --emptytree world

Update config files with etc-update
( I selected -3 to automerge and overwrote all files)
 * 1) etc-update

emerge Update Deep world

 * 1) emerge --update --deep world

Fix udev rule for rtc so 'hwclock' command will work

 * 1) cd /etc/udev/rules.d/
 * 2) echo 'KERNEL="rtc0",SYMLINK="rtc"' > rtc.rules

Choose a timezone so uname -a will look right

 * 1) cd /etc
 * 2) rm -f localtime
 * 3) ln -s ../usr/share/zoneinfo/America/New_York localtime

git
(might want to remove this later, it's big)
 * 1) emerge dev-util/git

unzip

 * 1) emerge unzip

uboot
(Follow the instruction for configuring and building u-boot on )
 * 1) cd /usr/src
 * 2) git clone git://www.jdl.com/software/u-boot-86xx.git u-boot-86xx
 * 3) wget http://www.kurobox.com/revolution/downloads/contest/patches.zip
 * 4) unzip patches.zip
 * 5) perl -pi -e 's/\r//' u-boot*.patch
 * 6) cd u-boot-86xx
 * 7) patch -p1 <../u-boot-kurobox.patch
 * 8) patch -p1 <../u-boot-kurobox-fdt.patch


 * 1) cp /usr/src/u-boot-86xx/tools/mkimage /usr/local/bin

And now, since I've decided the 15-minute image will not include u-boot, remove the u-boot stuff. It can be gotten from other sources, or the user can follow the instructions for building it himself. At least this step was useful for getting the mkimage tool which is necessary for building uImage kernels.


 * 1) cd /usr/src
 * 2) rm -rf u-boot-*
 * 3) rm patches.zip
 * 4) rm kurobox_powerpc-20061105_target.gitdiff

dtc
(errors on install for fdt.h and libfdt.h are ok for our purposes) (should print /usr/local/bin/dtc)
 * 1) cd /usr/src
 * 2) git clone git://www.jdl.com/software/dtc.git dtc
 * 3) cd /usr/src/dtc
 * 4) make
 * 5) make DESTDIR=/usr/local PREFIX="" install
 * 1) which dtc

gentoo-sources

 * 1) emerge gentoo-sources

build the kernel

 * 1) cd /usr/src/linux
 * 2) cp arch/powerpc/configs/linkstation_defconfig .config
 * 3) make menuconfig
 * 4) make uImage && make modules && make modules_install
 * 5) cp arch/powerpc/boot/uImage /boot/vmlinux.UBoot
 * 6) cp arch/powerpc/boot/dts/kurobox*.dts /boot/
 * 7) cp .config /boot/config
 * 8) cp System.map /boot
 * 9) cd /boot
 * 10) dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts
 * 11) dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts

remove git
(Trying to get the image size down)


 * 1) emerge --unmerge dev-util/git

emerge vim
[I hate nano, and as image creator, it's my prerogative to install my favorite editor ;-) ]


 * 1) emerge vim

emerge gentoolkit
(Necessary for revdep-rebuild step coming up soon)


 * 1) emerge gentookit

unmerge gcc-3.4.4-r1
(I don't expect anyone will need this, and it takes up space. They can emerge a gcc-3 compiler if they need one)


 * 1) emerge --unmerge =sys-devel/gcc-3.4.4-r1

depclean
(Clean out unneeded dependencies)


 * 1) emerge --depclean

revdep-rebuild
(Fix any broken dependencies)


 * 1) revdep-rebuild

remove gentoo-sources
(It's a shame it's so big - 359M)


 * 1) emerge --ummerge gentoo-sources
 * 2) cd /usr/src
 * 3) rm -rf linux linux-2.6.22-gentoo-r5

remove tmp files

 * 1) cd /var/tmp
 * 2) rm -rf *
 * 3) cd /tmp
 * 4) rm -rf *
 * 5) cd /usr/portage/distfiles
 * 6) rm -f *

avr_evtd
An ebuild for avr_evtd has been prepared. Place it in /usr/local/portage/kuro-2007-11-04/sys-apps with associated files. (I did this by tarring in the tarfile from outside the chroot environment)


 * 1) emerge avr_evtd
 * 2) rc-update add avr_evtd default

kuro-avr-init
This is leftover from the old profile and won't be needed with modern kernels.


 * 1) rc-update del kuro-avr-init boot
 * 2) cd /etc/init.d
 * 3) rm kuro-avr-init

fstab
Since the image is targeted at in-stream kernels, need to change hda to sda. Also, since the kuro/LS is a NAS, it seems like three partitions is fine: one for root, one for swap, and one for datafiles. Users can change this to their liking at install time.

(change hda to sda throughout) (delete /dev/sda for /var) (change /dev/sda4 to /dev/sda3 for /datafiles)
 * 1) vi /etc/fstab

Important lines from resulting file: /dev/sda1      /               ext3            defaults                0 1 /dev/sda2      none            swap            sw                      0 0 /dev/sda3      /datafiles      ext3            defaults                0 2 none           /proc           proc            defaults                0 0
 * 1) NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
 * 1) NOTE: The next line is critical for boot!

inittab
Since the instream kernel uses ttyS0 for the AVR, need to update the inittab to start getty on ttyS1 instead of ttyS0.

(change ttyS0 to ttyS1 throughout)
 * 1) vi /etc/inittab

Resulting important line in inittab:

c0:12345:respawn:/sbin/agetty 57600 ttyS1 vt100

/etc/conf.d/net
I noticed that if dhcp fails, the box is not on the network. This is not a good situation for a headless box. Change the net file to have a fallback IP.

(change the file to look as below)
 * 1) vi /etc/conf.d/net

config_eth0=(  "dhcp" ) fallback_eth0=(  "192.168.11.150/24" )
 * 1) This configuration will use DHCP for eth0 but fallback to the
 * 2) well-known 192.168.11.150 if DHCP fails

re-emerge dhcpcd
I guess the depclean removed it - whoops.


 * 1) emerge dhcpcd

Move overlay to layman
This is a really cool way to maintain the overlay and distribute new ebuilds to people running gentoo on the LS/kurobox. I put the overlay on the SVN server at sourceforge.

emerge subversion
layman needs subversion but it's not an explicit a dependency, so emerge it explicitly. This pulls in 8 additional packages including apache. I think the apache dependency could be squashed with the right USE flags for subversion but maybe a lot of people will want apache anyway.


 * 1) emerge subversion

emerge layman

 * 1) emerge layman

/etc/layman/layman.cfg
We're going to put the storage in /usr/local/portage/layman and use a list from there called layman-local.txt.

(change storage setting to be: storage    : /usr/local/portage/layman) (add a line to the overlays setting : file://%(storage)s/layman-local.txt)
 * 1) vi /etc/layman/layman.cfg

The /etc/layman/layman.cfg file will look like this when modified: [MAIN] #--- config_dir: /etc/layman #--- storage  : /usr/local/portage/layman #--- cache    : %(storage)s/cache #--- local_list: %(storage)s/overlays.xml #--- make_conf : %(storage)s/make.conf #--- # overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt file://%(storage)s/layman-local.txt #--- # #--- # # nocheck : no
 * 1) Path to the config directory
 * 1) Defines the directory where overlays should be installed
 * 1) Remote overlay lists will be stored here
 * 2) layman will append _md5(url).xml to each filename
 * 1) The list of locally installed overlays
 * 1) Path to the make.conf file that should be modified by
 * 2) layman
 * 1) URLs of the remote lists of overlays (one per line) or
 * 2) local overlay definitions
 * 1) overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt
 * 2)            http://dev.gentoo.org/~wrobel/layman/global-overlays.xml
 * 3)            http://mydomain.org/my-layman-list.xml
 * 4)            file:///usr/portage/local/layman/my-list.xml
 * 1) Proxy support
 * 1) proxy : http://www.my-proxy.org:3128
 * 1) Strict checking of overlay definitions
 * 1) Set either to "yes" or "no". If "no" layman will issue
 * 2) warnings if an overlay definition is missing either
 * 3) description or contact information.

/usr/local/portage/layman/layman-local.txt
This is the file that tells layman where to find the overlay on sourceforge and put it in the filesystem with name "ls-wiki".

  The Linkstationwiki ppc overlay provides ebuilds adapted for running Gentoo on Buffalo PPC Linkstations and Kuroboxes.

Check the setup now with:

* ls-wiki                  [Subversion] (source: http://linkstationwiki.svn...)
 * 1) layman -L | grep ls-wiki

layman -a ls-wiki
Add the ls-wiki overlay with:


 * 1) layman -a ls-wiki

/etc/make.conf
Need to add a line to make.conf:

(remove the old line with PORTDIR_OVERLAY="/usr/local/portage/kuro-2007-11-04")
 * 1) echo "source /usr/local/portage/layman/make.conf" >> /etc/make.conf
 * 2) vi /etc/make.conf

The contents of the file is now: CFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char" CXXFLAGS="${CFLAGS}" USE="-X -gtk -gtk2 -gnome -qt -kde -opengl -motif -xmms -arts -alsa -oss -ipv6 samba cups usb" source /usr/local/portage/layman/make.conf
 * 1) Kurobox make.conf

switch to the profile in the ls-wiki overlay

 * 1) cd /etc
 * 2) rm make.profile
 * 3) ln -s ../usr/local/portage/layman/ls-wiki/profiles/kurobox-uboot/2007.0/ make.profile

emerge --info
Check that everything is ok with:


 * 1) emerge --info

emerge --sync, emerge --update

 * 1) emerge --sync
 * 2) emerge --update --deep world

remove old overlays now that layman is working

 * 1) cd /usr/local/portage
 * 2) rm -rf kuro-*

Create tarfile
We're going to create the tarfile without the portage tree since it goes stale quickly. The instructions will say to download the latest portage snapshot.

--exclude "./usr/portage/*" --exclude "./proc/*" --exclude "./tmp/*" --exclude "./root/*".
 * 1) exit # (leave the chroot environment)
 * 2) umount /datafiles/chroots/gentoo-20071104-uboot/proc
 * 3) cd /datafiles/chroots/gentoo-20071104-uboot
 * 4) tar cjf ../gentoo-20071104-uboot.tar.bz2 \