diff options
| author | James Meyer <James.meyer@operamail.com> | 2008-10-02 03:23:45 (GMT) | 
|---|---|---|
| committer | James Meyer <James.meyer@operamail.com> | 2008-10-02 03:23:45 (GMT) | 
| commit | 618d4ad515a93d1e48934be5846edd71270171ec (patch) | |
| tree | a22a9294af81215d4a7b1053e5fdb4d746f39d41 /build_tools/clarch/larch/run/mklarch | |
| download | linhes_dev-618d4ad515a93d1e48934be5846edd71270171ec.zip | |
initital import
Diffstat (limited to 'build_tools/clarch/larch/run/mklarch')
| -rwxr-xr-x | build_tools/clarch/larch/run/mklarch | 281 | 
1 files changed, 281 insertions, 0 deletions
| diff --git a/build_tools/clarch/larch/run/mklarch b/build_tools/clarch/larch/run/mklarch new file mode 100755 index 0000000..2a1c574 --- /dev/null +++ b/build_tools/clarch/larch/run/mklarch @@ -0,0 +1,281 @@ +#! /bin/bash +# +# mklarch +# +# Author: Michael Towers <gradgrind[at]online[dot]de> +# +# This file is part of the larch project. +# +#    larch is free software; you can redistribute it and/or modify +#    it under the terms of the GNU General Public License as published by +#    the Free Software Foundation; either version 2 of the License, or +#    (at your option) any later version. +# +#    larch is distributed in the hope that it will be useful, +#    but WITHOUT ANY WARRANTY; without even the implied warranty of +#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +#    GNU General Public License for more details. +# +#    You should have received a copy of the GNU General Public License +#    along with larch; if not, write to the Free Software Foundation, Inc., +#    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA +# +#---------------------------------------------------------------------------- +# 2008.06.22 + +# directory to use for building the CD - the installation root +# It must have LOTS of space, ~ 4GB for a 700MB CD +INSTLDIR=/home/larchroot + +# Default path to larch5 repositories (architecture is sub-directory) +larch5path="ftp://ftp.berlios.de/pub/larch/larch5.3" + +APP=$( basename $0 ) +# Get path to larch base directory, via the location of this script +FULLPATH=$( readlink -f $0 ) +SCRIPTDIR=$( dirname ${FULLPATH} ) +LARCHDATA=$( dirname ${SCRIPTDIR} ) + +startdir=$( pwd ) +# cd to ensure that the following test works even if '.' is in PATH +cd / +apppath="$( which ${APP} 2>/dev/null )" +if [ $? -ne 0 ] || [ "${apppath}" != "${FULLPATH}" ]; then +    PATH=${SCRIPTDIR}:${PATH} +fi +cd ${startdir} + +usage () { +    echo +    echo "Usage:" +    echo "  ${APP} -h     # Show this message" +    echo +    echo "  ${APP} -a  [-f] [-p <profile directory>]" +    echo "                  [-c <package cache directory>]" +    echo "                  [-y <path to pacman database directories>]" +    echo "                  [<build directory>]" +    echo +    echo "  ${APP} [-ugf]   [-p <profile directory>]" +    echo "                  [-c <package cache directory>]" +    echo "                  [-y <path to pacman database directories>]" +    echo "                  [<build directory>]" +    echo +    echo "          -a    Stop after installing Arch system (don't build live system)." +    echo +    echo "          -p    Use the 'profile' in the given directory." +    echo +    echo "          -c    Use an alternative package cache directory" +    echo "                (default is /var/cache/pacman/pkg, on host)" +    echo "          -y    Use existing pacman package database instead" +    echo "                of performing 'pacman -Sy'." +    echo +    echo "          -u    Don't build iso, but install to USB-stick instead" +    echo "          -g    Use GRUB bootloader (default is isolinux/syslinux)" +    echo +    echo "          -f    No interaction. (not recommended)" +    echo "                The script will just plough straight on and destroy" +    echo "                your file-system without first asking." +    echo +    echo "${APP} is the master script for the larch live CD / live USB-stick" +    echo "builder." +    echo +    echo "<build directory> is the directory in which all the building will" +    echo "be done, by default '${INSTLDIR}'" +    echo +    echo "A profile is a directory containing all the necessary" +    echo "configuration details for a larch build. See documentation" +    echo "and examples." +    echo +    echo "If you want to rebuild a live system without reinstalling it" +    echo "(for example if you make minor changes to the profile which" +    echo "don't affect the packages, or if you want a USB-stick instead" +    echo "of a CD, or if writing to the USB-stick failed for some reason)" +    echo "you should look at the 'larchify' script - run it with the '-h'" +    echo "option for usage notes." +    echo +    exit +} + +pROFILE="" +DONTASK="" +NOLIVE="" +USB="" +GRUB="" +PKGCACHE=/var/cache/pacman/pkg +# Options to 'inpacs': +INPACSO="" +while getopts ":p:ac:y:ugf" Option +do +  case ${Option} in +    p ) PROFILE="$( readlink -f ${OPTARG} )" ;; +    a ) NOLIVE="-a" ;; +    c ) PKGCACHE="$( readlink -f ${OPTARG} )" ;; +    y ) INPACSO="${INPACSO} -y $( readlink -f ${OPTARG} )" ;; +    u ) USB="-u" ;; +    g ) GRUB="-g" ;; +    f ) DONTASK="-f" ;; +    * ) usage ;; +  esac +done +shift $((${OPTIND} - 1)) +if ! [ -d "${PKGCACHE}" ]; then +    echo "Creating package cache: ${PKGCACHE}" +    if ! mkdir -p "${PKGCACHE}"; then +        echo "ERROR: Couldn't create ${PKGCACHE}" +        exit 1 +    fi +fi +INPACSO="${INPACSO} -c ${PKGCACHE}" + +if [ -n "$1" ]; then +    INSTLDIR=$1 +fi +LARCHBUILD="${INSTLDIR}/.larch" + +if [ -z "${PROFILE}" ]; then +    PROFILE=${startdir}/profile +fi +if ! [ -f ${PROFILE}/addedpacks ]; then +    echo "ERROR: no 'addedpacks' in profile '${PROFILE}'" +    exit 1 +fi + +# test if the script is started by root user. If not, exit +if [ $UID -ne 0 ]; then +    echo "Only root can run ${APP}"; exit 1 +fi + +echo "//" +echo "// **********************************************************" +echo "// This will delete EVERYTHING under" +echo "//" +echo "//        ${INSTLDIR}" +echo "//" + +if [ -z "${DONTASK}" ]; then +    echo "// I really mean it ... Are you sure you want to do this?" +    echo "// **********************************************************" +    # Await yes or no +    read -p "// [y/N]: " ans +    if [ -z "$( echo ${ans} | grep '^ *[yY]' )" ]; then exit 0; fi +fi + +for fd in $( ls -A ${INSTLDIR} ); do +    rm -rf ${INSTLDIR}/${fd} +#lookforme  +done +mkdir -p ${LARCHBUILD} + +############### Call 'inpacs' to do the installation + +if [ -f ${PROFILE}/basepacks ]; then +    INPACSO="${INPACSO} -b ${PROFILE}/basepacks" +fi + +if [ -f ${PROFILE}/baseveto ]; then +    INPACSO="${INPACSO} -x ${PROFILE}/baseveto" +fi + +if [ -f ${PROFILE}/pacman.conf ]; then +    cp ${PROFILE}/pacman.conf . +elif ! [ -f pacman.conf ]; then +    if [ -f /etc/pacman.conf ]; then +        cp /etc/pacman.conf . +    else +        echo "ERROR: Couldn't find pacman.conf" +        exit 1 +    fi +fi +INPACSO="${INPACSO} -k pacman.conf" +if [ x = y ] +then +# If necessary add the larch repository to pacman.conf +if ! grep '^[larch5]' pacman.conf &>/dev/null; then +    if [ -d larchrepo ]; then +        larch5path="file://$( readlink -f larchrepo )" +    else +        sysarch="$( uname -m )" +        if [ "${sysarch}" != "x86_64" ]; then +            sysarch="i686" +        fi +        larch5path="${larch5path}/${sysarch}" +    fi +    #sed "/\[testing\]/ i \ +	echo "[larch5] " >> pacman.conf +	echo "Server = ${larch5path}" >> pacman.conf +fi + +fi + +if ! which pacman &>/dev/null; then +    if ! [ -x ${startdir}/pacman ]; then +        echo "ERROR: Couldn't find pacman executable" +        exit 1 +    fi +    INPACSO="${INPACSO} -P ${startdir}/pacman" +fi +echo "checking for pre_process.sh" +if [ -f ${PROFILE}/pre-process.sh ] +then +	echo "Running pre-process script" +	cd ${PROFILE} +	./pre-process.sh +	cd - + +else +	echo "No pre_process" +fi + +inpacs -a ${PROFILE}/addedpacks ${INPACSO} ${INSTLDIR} +if [ $? -ne 0 ]; then exit 1; fi + +# Use build version of pacman.conf in live system, without [larch5] repository. +# This can be overwritten by a pacman.conf in the profile's overlay. + +rm -f ${INSTLDIR}/etc/pacman.conf +if [ -f ${PROFILE}/pacman.conf ]; then +    # This file should be used in preference to pacman.conf - it is created by +    # larch-setup on non-Arch systems before commenting out the 'Include' lines. +    cp ${PROFILE}/pacman.conf  ${INSTLDIR}/etc/pacman.conf +else +    sed '/^\[larch5\]/,/^ *$/ d' <pacman.conf >${INSTLDIR}/etc/pacman.conf +fi + +cachepacs -a ${PROFILE}/cache_packs  $INPACSO -d ${INSTLDIR} + + +# Generate glibc locales +if [ -f ${PROFILE}/locale.gen ]; then +    echo +    echo "********** Generating locales **********" +    echo +    cat ${PROFILE}/locale.gen ${INSTLDIR}/etc/locale.gen >${INSTLDIR}/etc/locale.gen_new +    mv -f ${INSTLDIR}/etc/locale.gen_new ${INSTLDIR}/etc/locale.gen +    chroot ${INSTLDIR} usr/sbin/locale-gen +fi + +# Generate ssh keys +ssh_init ${INSTLDIR} + +# Set up a symlink to the installation for 'larchify' +rm -f larchroot && ln -sf ${INSTLDIR} ${startdir}/larchroot +if [ $? -ne 0 ]; then +    echo "WARNING: Couldn't create 'larchroot' symlink" +fi + +echo "// ${APP} finished installation of Arch system" +echo "//" + +#run script to post-process the new installation +if [ -f ${PROFILE}/post-process.sh ] +then +	${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} +	echo ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} +fi + + +if [ -z "${NOLIVE}" ]; then +    # Get live CD build functions +    . ${LARCHDATA}/buildlive +    mklive +fi | 
