clean-up and removal of steps out of scope of strict installation

This commit is contained in:
Gwenhael Le Moine 2014-02-26 14:46:08 +01:00
parent 1d66fa8379
commit 3ceb185949

157
build.sh
View file

@ -13,6 +13,9 @@
# * TODO organize patches by corresponding sources # * TODO organize patches by corresponding sources
# * TODO review $CWD/scripts/resize2fs-arch.sh # * TODO review $CWD/scripts/resize2fs-arch.sh
set -e
# --- Check environment --------------------------------------------------------
if [ ! -x /usr/bin/mkimage ]; then if [ ! -x /usr/bin/mkimage ]; then
echo "Missing u-boot tools" echo "Missing u-boot tools"
echo "Please install them from http://www.slackware.com/~alien/slackbuilds/u-boot-tools/" echo "Please install them from http://www.slackware.com/~alien/slackbuilds/u-boot-tools/"
@ -23,8 +26,6 @@ fi
#change to your needs #change to your needs
IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"} IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"}
VERSION=${VERSION:-0.2} VERSION=${VERSION:-0.2}
DEST_LANG=${DEST_LANG:-"en_US"}
DEST_LANGUAGE=${DEST_LANGUAGE:-"us"}
COMPILE=${COMPILE:-"true"} COMPILE=${COMPILE:-"true"}
DEST=${DEST:-~/cubieslack} DEST=${DEST:-~/cubieslack}
DISPLAY=${DISPLAY:-3} # "3:hdmi; 4:vga" DISPLAY=${DISPLAY:-3} # "3:hdmi; 4:vga"
@ -32,17 +33,16 @@ IMAGE_SIZE_MB=${IMAGE_SIZE_MB:-2000}
SLACKWARE_VERSION=${SLACKWARE_VERSION:-14.1} SLACKWARE_VERSION=${SLACKWARE_VERSION:-14.1}
ROOTFS_VERSION=${ROOTFS_VERSION:-04Nov13} ROOTFS_VERSION=${ROOTFS_VERSION:-04Nov13}
CONFIG_HZ=${CONFIG_HZ:-300HZ} # 250HZ, 300HZ or 1000HZ CONFIG_HZ=${CONFIG_HZ:-300HZ} # 250HZ, 300HZ or 1000HZ
TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION:-4.8-2013.10}
TOOLCHAIN_URL_RANDOM_NUMBER=${TOOLCHAIN_URL_RANDOM_NUMBER:-155358238}
# --- Script -------------------------------------------------------------------- # --- Script --------------------------------------------------------------------
SRC=$(pwd)
CWD=$(pwd) CWD=$(pwd)
set -e
mkdir -p $DEST mkdir -p $DEST
#Requires root .. #Requires root ..
if [ "$UID" -ne 0 ] if [ "$UID" -ne 0 ]; then echo "Please run as root"
then echo "Please run as root"
exitssid=CUBIE exitssid=CUBIE
interface=wlan0 interface=wlan0
hw_mode=g hw_mode=g
@ -64,7 +64,7 @@ then echo "Please run as root"
macaddr_acl=0 macaddr_acl=0
fi fi
echo "Building Cubietruck-Slackware in $DEST from $SRC" echo "Building Cubietruck-Slackware in $DEST from $CWD"
sleep 3 sleep 3
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
@ -74,48 +74,49 @@ echo "------ Downloading cross-compiler"
#Read this for further information if you run into problems with gcc compiler #Read this for further information if you run into problems with gcc compiler
#http://linux-sunxi.org/Toolchain #http://linux-sunxi.org/Toolchain
wget -c https://launchpadlibrarian.net/155358238/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux.tar.xz wget -c https://launchpadlibrarian.net/$TOOLCHAIN_URL_RANDOM_NUMBER/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz
tar xf gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux.tar.xz tar xf gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz
CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf- CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf-
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
# Preparing output / destination files # Preparing output / destination files
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
echo "------ Fetching files from github" echo "------ Clone / Pull sources and patch"
mkdir -p $DEST/output mkdir -p $DEST/output
cp output/uEnv.txt $DEST/output cp output/uEnv.txt $DEST/output
# # u-boot tools # # u-boot tools
# if [ -d "$DEST/u-boot" ]; then # if [ -d "$DEST/u-boot" ]; then
# (cd $DEST/u-boot; # ( cd $DEST/u-boot;
# git pull) # git pull )
# else # else
# git clone git://git.denx.de/u-boot.git $DEST/u-boot # git clone git://git.denx.de/u-boot.git $DEST/u-boot
# fi # fi
# Boot loader # Boot loader
if [ -d "$DEST/u-boot-sunxi" ] if [ -d "$DEST/u-boot-sunxi" ]; then
then ( cd $DEST/u-boot-sunxi;
cd $DEST/u-boot-sunxi ; git pull; cd $SRC git pull )
else else
git clone https://github.com/cubieboard/u-boot-sunxi $DEST/u-boot-sunxi git clone https://github.com/cubieboard/u-boot-sunxi $DEST/u-boot-sunxi
# Applying Patch for 2gb memory # Applying Patch for 2gb memory
patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $SRC/patch/memory.patch || true patch -f $DEST/u-boot-sunxi/include/configs/sunxi-common.h < $CWD/patch/memory.patch || true
fi fi
# Allwinner tools # Allwinner tools
if [ -d "$DEST/sunxi-tools" ] if [ -d "$DEST/sunxi-tools" ]; then
then ( cd $DEST/sunxi-tools;
cd $DEST/sunxi-tools; git pull; cd $SRC git pull )
else else
git clone https://github.com/linux-sunxi/sunxi-tools.git $DEST/sunxi-tools git clone https://github.com/linux-sunxi/sunxi-tools.git $DEST/sunxi-tools
fi fi
# Hardware configurations # Hardware configurations
if [ -d "$DEST/cubie_configs" ] if [ -d "$DEST/cubie_configs" ]; then
then ( cd $DEST/cubie_configs;
cd $DEST/cubie_configs; git pull; cd $SRC git pull )
else else
git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs git clone https://github.com/cubieboard/cubie_configs $DEST/cubie_configs
@ -128,14 +129,14 @@ else
fi fi
# Patwood's kernel 3.4.75+ # Patwood's kernel 3.4.75+
if [ -d "$DEST/linux-sunxi" ] if [ -d "$DEST/linux-sunxi" ]; then
then ( cd $DEST/linux-sunxi;
cd $DEST/linux-sunxi; git pull -f; cd $SRC git pull -f )
else else
git clone https://github.com/patrickhwood/linux-sunxi $DEST/linux-sunxi git clone https://github.com/patrickhwood/linux-sunxi $DEST/linux-sunxi
###PATCH kernel CONFIG_HZ, Arm dfault is hardcoded 100hz (10ms latency!). For mulitimedia and desktop a higher frequency is recomended. ###PATCH kernel CONFIG_HZ, Arm dfault is hardcoded 100hz (10ms latency!). For mulitimedia and desktop a higher frequency is recomended.
test -f $SRC/patch/$CONFIG_HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $SRC/patch/$CONFIG_HZ.patch test -f $CWD/patch/$CONFIG_HZ.patch && patch -f $DEST/linux-sunxi/arch/arm/Kconfig < $CWD/patch/$CONFIG_HZ.patch
fi fi
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
@ -144,7 +145,7 @@ fi
echo "------ Compiling kernel boot loaderb" echo "------ Compiling kernel boot loaderb"
# Copying Kernel config # Copying Kernel config
cp $SRC/config/kernel.config $DEST/linux-sunxi/ cp $CWD/config/kernel.config $DEST/linux-sunxi/
# echo "------ Compiling mkimage" # echo "------ Compiling mkimage"
# cd $DEST/u-boot # cd $DEST/u-boot
@ -164,9 +165,7 @@ make -j2 'cubietruck' CROSS_COMPILE=$CROSS_COMPILE
echo "------ Compiling sunxi tools" echo "------ Compiling sunxi tools"
cd $DEST/sunxi-tools cd $DEST/sunxi-tools
make clean make clean fex2bin bin2fex
make fex2bin
make bin2fex
mkdir -p $CWD/bin/ mkdir -p $CWD/bin/
cp fex2bin bin2fex $CWD/bin/ cp fex2bin bin2fex $CWD/bin/
@ -184,7 +183,7 @@ if [ "$COMPILE" = "true" ]; then
# Adding wlan firmware to kernel source # Adding wlan firmware to kernel source
cd $DEST/linux-sunxi/firmware; cd $DEST/linux-sunxi/firmware;
unzip -o $SRC/bin/ap6210.zip unzip -o $CWD/bin/ap6210.zip
cd $DEST/linux-sunxi cd $DEST/linux-sunxi
make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE sun7i_defconfig make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE sun7i_defconfig
@ -247,7 +246,7 @@ cat > $DEST/output/sdcard/etc/motd <<EOF
EOF EOF
# script to turn off the LED blinking # script to turn off the LED blinking
cp $SRC/scripts/disable_led.sh $DEST/output/sdcard/bin/disable_led.sh cp $CWD/scripts/disable_led.sh $DEST/output/sdcard/bin/disable_led.sh
# make it executable # make it executable
chmod +x $DEST/output/sdcard/bin/disable_led.sh chmod +x $DEST/output/sdcard/bin/disable_led.sh
@ -255,26 +254,15 @@ chmod +x $DEST/output/sdcard/bin/disable_led.sh
echo disable_led.sh > $DEST/output/sdcard/etc/rc.d/rc.local echo disable_led.sh > $DEST/output/sdcard/etc/rc.d/rc.local
# scripts for autoresize at first boot from cubian # scripts for autoresize at first boot from cubian
cp $SRC/scripts/resize2fs-arch.sh $DEST/output/sdcard/root/resize2fs-root.sh cp $CWD/scripts/resize2fs-arch.sh $DEST/output/sdcard/root/resize2fs-root.sh
# make it executable # make it executable
chmod +x $DEST/output/sdcard/root/resize2fs-root.sh chmod +x $DEST/output/sdcard/root/resize2fs-root.sh
# and startable on boot just execute it once not on every boot!!! # and startable on boot just execute it once not on every boot!!!
#echo cubian-resize2fs > $DEST/output/sdcard/etc/rc.conf #echo cubian-resize2fs > $DEST/output/sdcard/etc/rc.conf
# script to install to NAND # script to install to NAND
cp $SRC/scripts/nand-install.sh $DEST/output/sdcard/root cp $CWD/scripts/nand-install.sh $DEST/output/sdcard/root
cp $SRC/bin/nand1-boot-cubietruck-arch.tgz $DEST/output/sdcard/root cp $CWD/bin/nand1-boot-cubietruck-arch.tgz $DEST/output/sdcard/root
# install and configure locales
#echo LANG='$DEST_LANG'.UTF-8 > $DEST/output/sdcard/etc/default.conf
#echo KEYMAP=us > $DEST/output/sdcard/etc/vconsole.conf
#use this command when System runs
# sudo timedatectl set-timezone Zone/SubZone
# when setup preferred gui like openbox then use loadkeys de
# i recommend you to change this urgently + add a proper user for the System!!!
# default passwort for user "root" is "root"
#echo 1234;echo 1234; | passwd root
# set hostname # set hostname
echo darkstar > $DEST/output/sdcard/etc/HOSTNAME echo darkstar > $DEST/output/sdcard/etc/HOSTNAME
@ -285,19 +273,10 @@ echo '/dev/mmcblk0p1 / ext4 defaults 1 1' >> $DEST/output/sdcard/etc/fstab
### mount /tmp as tmpfs ### mount /tmp as tmpfs
echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/output/sdcard/etc/fstab echo 'tmpfs /tmp tmpfs defaults,nosuid,size=30% 0 0' >> $DEST/output/sdcard/etc/fstab
### Optional /var/log
#echo 'tmpfs /var/log tmpfs defaults,nosuid 0 0' >> $DEST/output/sdcard/etc/fstab
##disable IPV6 and reduce timeout from 30s to 5 on dhcp daemon
#echo "ipv4only" >> /etc/dhcpcd.conf
#echo "noipv6rs" >> /etc/dhcpcd.conf
echo "timeout 5" >> /etc/dhcpcd.conf
# modules to load
# load modules you may load them per sysctl
cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT
#!/bin/sh #!/bin/sh
@ -309,46 +288,6 @@ cat >> $DEST/output/sdcard/etc/rc.d/rc.modules <<EOT
#/sbin/modprobe sunxi_gmac #/sbin/modprobe sunxi_gmac
EOT EOT
# edit this to your personal needs/network configs take the ones from /etc/netctl/examples/ folder
# create interfaces configuration
#cat > $DEST/output/sdcard/etc/netctl/interfaces/eth0 <<EOT
#auto eth0
#allow-hotplug eth0
#iface eth0 inet dhcp
# hwaddress ether #for AP use
#
#EOT
#use wifi-menu wlan0 to configure
#cat > $DEST/output/sdcard/etc/netctl/wlan0 <<EOT
#auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet dhcp
# wpa-ssid SSID
# wpa-psk xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# to generate proper encrypted key: wpa_passphrase yourSSID yourpassword
#EOT
# create interfaces if you want to have AP. /etc/modules must be: bcmdhd op_mode=2
#cat <<EOT >> $DEST/output/sdcard/etc/network/interfaces.hostapd
#auto lo br0
#iface lo inet loopback
#allow-hotplug eth0
#iface eth0 inet manual
#allow-hotplug wlan0
#iface wlan0 inet manual
#iface br0 inet dhcp
#bridge_ports eth0 wlan0
#hwaddress ether # will be added at first boot
#EOT
# enable serial console (Debian/sysvinit way)
#echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> $DEST/output/sdcard/etc/inittab
#remove the preconfigured boot from the image and use the one we want #remove the preconfigured boot from the image and use the one we want
rm -rf $DEST/output/sdcard/boot/ rm -rf $DEST/output/sdcard/boot/
mkdir -p $DEST/output/sdcard/boot/ mkdir -p $DEST/output/sdcard/boot/
@ -365,30 +304,6 @@ fi
cp -R $DEST/linux-sunxi/output/lib/modules $DEST/output/sdcard/lib/ cp -R $DEST/linux-sunxi/output/lib/modules $DEST/output/sdcard/lib/
cp -R $DEST/linux-sunxi/output/lib/firmware/ $DEST/output/sdcard/lib/ cp -R $DEST/linux-sunxi/output/lib/firmware/ $DEST/output/sdcard/lib/
# USB redirector tools http://www.incentivespro.com
#cd $DEST
#wget http://www.incentivespro.com/usb-redirector-linux-arm-eabi.tar.gz
#tar xvfz usb-redirector-linux-arm-eabi.tar.gz
#rm usb-redirector-linux-arm-eabi.tar.gz
#cd $DEST/usb-redirector-linux-arm-eabi/files/modules/src/tusbd
#make -j2 ARCH=arm CROSS_COMPILE=$CROSS_COMPILE KERNELDIR=$DEST/linux-sunxi/
# configure USB redirector
#sed -e 's/%INSTALLDIR_TAG%/\/usr\/local/g' $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1
#sed -e 's/%PIDFILE_TAG%/\/var\/run\/usbsrvd.pid/g' $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd
#sed -e 's/%STUBNAME_TAG%/tusbd/g' $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1
#sed -e 's/%DAEMONNAME_TAG%/usbsrvd/g' $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd
#chmod +x $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd
# copy to root
#cp $DEST/usb-redirector-linux-arm-eabi/files/usb* $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $DEST/output/sdcard/usr/local/bin/
#cp $DEST/usb-redirector-linux-arm-eabi/files/rc.usbsrvd $DEST/output/sdcard/etc/modules-load.d/
# started by default
# hostapd from testing binary replace.
# cd $DEST/output/sdcard/usr/sbin/
# tar xvfz $SRC/bin/hostapd21.tgz
# cp $SRC/config/hostapd.conf $DEST/output/sdcard/etc/
# sunxi-tools # sunxi-tools
cd $DEST/sunxi-tools cd $DEST/sunxi-tools
make clean make clean