Thursday, January 31, 2008

Install Gentoo VM on Macbook -1

I use Minimum CD, the installation is more hard than using a liveCD, so I failed a bunch of times. And as my learning, I started installation with stage3, so I don't need to catch stage1 and stage2, but even stage3, is a lot to me. Every time with Minimum CD, I have to get stage3 and portage, so at last I save them to another machine that I can easily get with ssh.

0 startup with Minimum CD
vmware: other linux 2.6.x
connected: NAT

1 check network
- ifconfig => eth0
- dhcpcd => some times need it if eth0 did not show ip address
- ssh => connect with my file server where I save stage3 and portage etc.
/etc/init.d/sshd start

2 prepare disks...
- fdisk /dev/sda
=> /dev/sda1 for boot
=> /dev/sda2 for swap
=> /dev/sda3 for / (the root)
mkfs.ext2 /dev/sda1
mkfs.ext3 /dev/sda3
mkswap /dev/sda2
swapon /dev/sda2
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot

3 install stage3 and portage
scp -p -r .
cd /mnt/gentoo
tar xjpf stage3-<>.tar.bz2
tar xjf portage-<>.tar.bz2 -C /mnt/gentoo/usr

4. env setup
vi /mnt/gentoo/etc/make.conf
CFLAGS as "-O2 -march=prescott -fomit-frame-pointer -pipe"
mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
cp -L /etc/resolv.conf /mnt/gentoo/etc
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="{chroot} $PS1"

5. emerge -sync --quiet
emerge vim lilo subversion

6. vi /etc/fstab
7. network
vi /etc/conf.d/hostname => "gentoovm"
vi /etc/conf.d/net => for dhcp: config_eth0="dhcp", but i did not set.
rc-update add net.eth0 default => boot eth0 as default
emerge dhcpcd => MUST
vi /etc/hosts
=> gentoovm.homenetwork gentoovm localhost

8. System
passwd => MUST
emerge syslog-ng vixie-cron
rc-update add syslog-ng default
rc-update add vixie-cron default

9. lilo
vi /etc/lilo.conf
prepare the default kernel (from ssh) and save to /boot

10 reboot

Friday, January 18, 2008

xwd : capture window on linux

xwd is the basic tool to do screen (or window) capture. I used it in my xw manager fvwm2. Here is a shot, but it seems not dump the title part of the window (gvim). Would like to find out the reason.

Wednesday, January 16, 2008

gcc - shared library

When I link the shared library in dynamic mode on FC5 (Fedoral Core 5), I got a failure when run my executables: "cannot restore segment prot after reloc: Permission denied", is it only happend on FC5?

# make compile
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-g++ -x c++ -c -Wall -Wno-unknown-pragmas -fno-common -fbounds-check -pipe -g -Wno-deprecated -pipe -o foo.o foo.cpp
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-g++ -shared -o foo.o -lc
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-ar -rcs libfoo.a foo.o
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-g++ -x c++ -c -Wall -Wno-unknown-pragmas -fno-common -fbounds-check -pipe -g -Wno-deprecated -pipe -o test.o test.cpp
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-g++ -dynamic -L. -lfoo -o test test.o
/opt/crosstool/i686-unknown-linux-gnu/gcc-3.4.1-glibc-2.3.3/bin/i686-unknown-linux-gnu-g++ -static -L. -lfoo -o test.static test.o libfoo.a
# ./test
./test: error while loading shared libraries: ./ cannot restore segment prot after reloc: Permission d[...]

Here is the solution:

# chcon -t textrel_shlib_t ./

Wednesday, January 9, 2008

version controls with cvs

0. I have a simple script to set my working CVSROOT. So when I work on it. I just run the script.


Here is script.(which is just 2 lines)

#! /bin/sh
export CVSROOT=":pserver:user:"

1. Create a branch with tag.

cvs co -P -d foo FOO
cvs tag -b z_markc_unknown

To create a branch, you first need to check out the source code. here FOO is the module name and foo is the checkout directory.

2. Work on a branch.

cvs co -P -d foo -r z_markc_unknown FOO

3. Merge from a branch

cd foo
cvs update -j z_markc_1

It will merge the branch to where you currently work on (can be main trunk or a branch)

4. Commit your changes

cvs update
cvs diff Makefile
cvs commit Makefile

When you merge the code from a branch, it does not commit yet, so you need to commit it.

5. To delete a branch tag. (THIS SHOULD BE VERY CAREFUL!)

cd foo
cvs tag -dB z_markc_1

Tuesday, January 8, 2008

Work on iPAQ 5550 PocketPC

Use the COM port to connect with PC. On Windows, HyperTerminal is perfact for the connection. In most time, it is desire to work on Linux, here is the way to connect througth ssh on my Linux Host:

ssh root@

you need to get the ip address, user name and password to enter into the system.
To find out the ip address, you can start the terminal in iPAQ (GPE installed), and type ifconfig.

Copy files forth and back with scp on Linux Host:

scp foo root@
scp -p -r root@ foo

Right now my iPAQ's ip address is connected to the wireless network, and is associated with an external ip address (NOT 192*), so it can not ping my internel network, but the linux host can ping the external ip address. That is why scp works.

Sunday, January 6, 2008

slckware 12.0 - install Bitstream Vera Fonts

1. Download the font package from here.

Extract it

cd /tmp
tar xjf ~/Desktop/ttf-bitstream-vera-1.10.tar.bz2

2. Copy the font to ~/.fonts

cp -r ttf-bitstream-vera-vera-1.10 ~/.fonts
fc-cache -f -v ~/.fonts
xset fp rehash

Now it's ready to use! just open gvim and select the font.