#!/bin/sh -e sinfo() { echo ${BASH:+-e} "\033[1;37;43m$@\033[0m" } # Must have root directory as an argument # "fresh" parameter can be given in subsequent invocation # (erasing ${LIVECD}/src will do the same) if [ -z "$1" -o \( -n "$2" -a "$2" != fresh \) ]; then echo "$0 [fresh]" exit 1 fi if [ `id -u` != 0 -o `id -g` != 0 ]; then echo "Must be root" exit 1 fi # Variables SRC=`dirname $0` LIVECD=$1 # If "fresh" parameter is passed, rewrites ${LIVECD}/src sinfo "Downloading and extracting stage3 and portage snapshots" ${SRC}/mkroot ${LIVECD} $2 # If "fresh" parameter is passed, rebuilds system from scratch sinfo "Installing packages and configuring system" ${SRC}/enter ${LIVECD} -c "./setup $2" # Reverse emerge rewriting /etc files during full build # Destructive operations are done on ${LIVECD}/copy sinfo "Restoring configuration and copying the live tree" ${SRC}/enter ${LIVECD} -c "./mkimage copy" # Cleans up ${LIVECD}/copy from inside sinfo "Uninstalling development packages" ${SRC}/enter ${LIVECD} copy -c ./setup-copy # Cleans up ${LIVECD}/copy from outside # Builds "liberte" dir in ${LIVECD}/dist to deploy sinfo "Mastering deployment directory" ${SRC}/enter ${LIVECD} -c ./mkimage # OK to copy "liberte" dir and run setup.sh sinfo "Done: ZIP archive in ${LIVECD}/dist"