#!/bin/sh

set -x

fsdir=smartbook-rootfs-f13
# prepare root fs
mkdir -p $fsdir/dev
mknod $fsdir/dev/console c 5 1
mknod $fsdir/dev/null c 1 3
mknod $fsdir/dev/zero c 1 5
mkdir -p $fsdir/var/lib/yum
mkdir -p $fsdir/var/log


# install packages
yum --disablerepo=* --enablerepo=f13-local --enablerepo=f13 --enablerepo=f12 --installroot=`pwd`/$fsdir -y install @admin-tools @base @base-x @core @dial-up @fonts @hardware-support @input-methods @printing @xfce-desktop NetworkManager-gnome NetworkManager-openvpn NetworkManager-pptp NetworkManager-vpnc Terminal abiword alsa-plugins-pulseaudio anaconda asunder catfish cheese claws-mail claws-mail-plugins-archive claws-mail-plugins-att-remover claws-mail-plugins-attachwarner claws-mail-plugins-bogofilter claws-mail-plugins-cachesaver claws-mail-plugins-fetchinfo claws-mail-plugins-mailmbox claws-mail-plugins-newmail claws-mail-plugins-notification claws-mail-plugins-pgp claws-mail-plugins-rssyl claws-mail-plugins-smime claws-mail-plugins-spam-report claws-mail-plugins-tnef claws-mail-plugins-vcalendar desktop-backgrounds-compat evince firefox fpaste gcalctool geany gigolo gnome-bluetooth gparted gtk-xfce-engine hal-storage-addon ibus-pinyin-db-android irssi isomd5sum java-1.6.0-openjdk-plugin kernel liferea memtest86+ midori mutt ntfs-3g orage parole parole-mozplugin pavucontrol pidgin powertop quodlibet remmina remmina-plugins-rdp remmina-plugins-vnc ristretto rtorrent seahorse setroubleshoot thunar-media-tags-plugin thunar-volman transmission vim-enhanced wget xarchiver xdg-user-dirs-gtk xfburn xfce4-battery-plugin xfce4-cellmodem-plugin xfce4-clipman-plugin xfce4-cpugraph-plugin xfce4-datetime-plugin xfce4-dict-plugin xfce4-diskperf-plugin xfce4-eyes-plugin xfce4-fsguard-plugin xfce4-genmon-plugin xfce4-mailwatch-plugin xfce4-mount-plugin xfce4-netload-plugin xfce4-notes-plugin xfce4-places-plugin xfce4-power-manager xfce4-quicklauncher-plugin xfce4-screenshooter-plugin xfce4-sensors-plugin xfce4-smartbookmark-plugin xfce4-systemload-plugin xfce4-taskmanager xfce4-time-out-plugin xfce4-timer-plugin xfce4-verve-plugin xfce4-weather-plugin xfce4-websearch-plugin xfce4-xfswitch-plugin xfce4-xkb-plugin xfwm4-themes xscreensaver yum-utils  2>&1 | tee $fsdir.log


# post-processing steps
cat > $fsdir/etc/fstab << EOF
/dev/mmcblk0p2          /                       ext4    defaults        1 1
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
sysfs                   /sys                    sysfs   defaults        0 0
/dev/mmcblk0p1          /boot                   ext3    defaults        1 2
/dev/sda3               swap                    swap    defaults        0 0
EOF

cat > $fsdir/etc/hosts << EOF
127.0.0.1	localhost localhost.localdomain
EOF

perl -pi -e "s/^root:\*:/root::/" $fsdir/etc/passwd

cat > $fsdir/etc/resolv.conf << EOF
nameserver 4.2.2.2
EOF

cat > $fsdir/etc/sysconfig/network << EOF
NETWORKING=yes
HOSTNAME=smartbook-fedora-arm
EOF

chroot $fsdir pwconv
chroot $fsdir chkconfig NetworkManager on
chroot $fsdir chkconfig auditd off
sed -i -e 's/root:\*:/root:$1$FNKzNFc2$uvRDDnuSgeKuuGxho8xvr1:/' $fsdir/etc/shadow

#cat << EOF > $fsdir/etc/sysconfig/network-scripts/ifcfg-eth0
#DEVICE=eth0
#BOOTPROTO=dhcp
#ONBOOT=yes
#EOF


