#!/bin/bash # Script to setup the LinHES development enviroment # ./setup_env.sh ( i586|i686|x86_64 ) devID # This script assumes that /tmp is usable. #MIRROR_DIR=../pkg_repo MIRROR_DIR=../pkg_repo SDIR=`pwd` function arg_check { case $1 in i586) ARCH=$1 ;; i686) ARCH=$1 ;; x86_64) ARCH=$1 ;; *) echo "invalid arch specified" echo "valid options include i586, i686 and x86_64" echo "EX: ./setup_env.sh i686 " exit 1 ;; esac case $2 in release) BENV="release" ;; testing) BENV="testing" ;; *) echo "invalid env specified" echo "valid options include release, testing" echo "EX: ./setup_env.sh i686 testing" exit 1 ;; esac if [ ! x$3 = x ] then USER=$3 #check if developer template is present if [ -d templates/developers/$3 ] then echo "found the template for $3 " FOUNDTEMPLATE="TRUE" else echo "couldn't find templates/developers/$3" # exit 2 fi fi } function static-pacman () { echo "downloading pacman to tmp" cd /tmp wget http://www.knoppmyth.net/repo/$ARCH/pacman-static.tgz status=$? if [ ! $status = 0 ] then echo "couldn't download pacman static" exit 1 fi tar -zxvf pacman-static.tgz export PATH=$PATH:/tmp/pacman.static/run cd - } function pacman_check { which pacman status=$? if [ ! $status = 0 ] then echo "Can not find pacman in the path." echo "Trying to use static version" static-pacman fi } function checkout_repo { mkdir -p $BENV/$ARCH cd $BENV/$ARCH git clone git@linhes.org:linhes_dev git clone git@linhes.org:linhes_pkgbuild # git clone $USER@knoppmyth.net:linhes_pkgbuild # git clone $USER@knoppmyth.net:linhes_dev if [ $BENV == "testing" ] then echo "=====================================" echo "switching linhes_pkgbuild to testing" pwd cd linhes_pkgbuild pwd git checkout -b testing origin/testing cd - echo "=====================================" fi if [ $BENV == "testing" ] then echo "=====================================" echo "switching linhes_dev to testing" pwd cd linhes_dev pwd git checkout -b testing origin/testing cd - echo "=====================================" fi } #----------------------------------------------- arg_check $1 $2 $3 #findme checkout_repo pacman_check #cd build_tools/clarch #./setup_links.sh #cd - #create the local pkg dir's for mirror and creating pkg's [ -e $MIRROR_DIR ] || mkdir -p $MIRROR_DIR for i in i586 i686 x86_64 do [ -e $MIRROR_DIR/$i ] || mkdir -p $MIRROR_DIR/$i for y in core extra core-testing extra-testing do [ -e $MIRROR_DIR/$i/$y ] || mkdir -p $MIRROR_DIR/$i/$y [ -e $MIRROR_DIR/src_packages/$y ] || mkdir -p $MIRROR_DIR/src_packages/$y done done [ -e $MIRROR_DIR/sources ] || mkdir -p $MIRROR_DIR/sources [ -e $MIRROR_DIR/packages ] || mkdir -p $MIRROR_DIR/packages #correct pacman.conf to use the correct ARCH to build the chroot cd $SDIR/$BENV/$ARCH cd linhes_dev sed -e "s/REPLACEME/$ARCH/g" templates/pacman.conf.chroot > /tmp/pacman.conf.chroot #create the chroot pwd echo "Creating dev chroot, this requires root access" echo "please type your root pass" mkdir -p /tmp/cache/pacman su -c "./mkarchroot -f -C /tmp/pacman.conf.chroot ../build_root.$ARCH base base-devel openssh git python2 dosfstools rsync squashfs-tools libisoburn python2-gitpython parched unison arch-install-scripts lynx" status=$? if [ ! $status = 0 ] then printf "\n" printf "%s\n" "********************************************************" printf "*** %-48s ***\n" " An error occured creating the chroot" printf "%s\n" "********************************************************" exit 1 fi #clear out the default resolve.conf su -c "mv -f ../build_root.$ARCH/etc/resolv.conf ../build_root.$ARCH/etc/resolv.conf.orig" if [ x$FOUNDTEMPLATE = xTRUE ] then #check for login run if [ -f templates/developers/$3/loginrun.sh ] then cp -f templates/developers/$3/loginrun.sh ../build_root.$ARCH/root/loginrun.sh fi if [ -f templates/developers/$3/custom_chroot.sh ] then cd templates/developers/$3 ./custom_chroot.sh $ARCH cd - fi fi #create custom enter_dev_chroot.sh script #sed -e "s/REPLACEME/$ARCH/g" templates/enter_dev_chroot.sh > ../enter_dev_chroot.$ARCH.sh su -c "cp templates/enter_dev_chroot.sh ../enter_dev_chroot.$ARCH" su -c "chmod 755 ../enter_dev_chroot.$ARCH" printf "%s\n" "********************************************************" printf "** %-50s **\n" " To enter the chroot (build_root.$ARCH) run:" printf "** %-50s **\n" " cd $BENV/$ARCH" printf "** %-50s **\n" " ./enter_dev_chroot.$ARCH" printf "** %-50s **\n" " First time setup only: " printf "** %-50s **\n" " after entering chroot run:" printf "** %-50s **\n" " cd /build_tools/archiso/archiso " printf "** %-50s **\n" " make install" printf "** %-50s **\n" " (it will error out but thats ok) " printf "%s\n" "********************************************************" #copy makepkg.conf into the chroot su -c "sed -e "s/REPLACEME/$ARCH/g" templates/makepkg.conf > ../build_root.$ARCH/etc/makepkg.conf" #correct underscore to dash for march for 64 bit su -c "sed -i "s/-march=x86_64/-march=x86-64/g" ../build_root.$ARCH/etc/makepkg.conf" #copy pacman.conf into the chroot su -c "sed -e "s/REPLACEME/$ARCH/g" templates/pacman.conf.chroot > ../build_root.$ARCH/etc/pacman.conf" cd ..