#!/bin/bash #Define build variables ACTION="" DISTRO="" FLAVOUR="" MIRROR="" EXTRA_MIRRORS="" EXTRA_MIRRORS_UNTRUSTED="" EXTRA_PPAS="" DEFAULTVERSION="19" VARIABLES_FILE="auto/settings" EXTRA_CONFIG="auto/additional_config/" # Define extra variables RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color # This include function addPPA # This include function cleanExtraSources # This include function addExtraMirror source /usr/share/isomaker/libs/IsoMakerUtils # Functions usage(){ echo "usage" echo -e "\t $(basename $0) build|configure DISTRO FLAVOUR EXTRAOPTIONS" echo -e "\t $(basename $0) clean" echo -e "" echo -e "\t * EXTRAOPTIONS:" echo -e "\t -a ARCH" echo -e "\t -m MIRROR" echo -e "\t -k KERNEL" echo -e "\t -p PPA[:Pining_Number]" echo -e "\t -e url" echo -e "\t -u url" echo -e "\t -s LINEOFSOURCESLIST " echo -e "\t -i | --interactive" echo -e "\t " } showResume(){ echo -e "\n\n" echo -e "\t${GREEN}********** Resume **********${NC}\n" echo -e " FLAVOUR : $FLAVOUR " echo -e " MIRROR : $MIRROR " echo -e " ARCH : $ARCH " echo -e " PPA : $EXTRA_PPAS " echo -e "\n\t${GREEN}**********************************${NC}" } showErrors(){ if [ $( cat binary.log | grep "^E:" | tee errores | wc -l ) -gt 0 ];then echo -e "\n\t${RED}******* Errors **********${NC}\n" cat errores | sed -e "s%^% %g" echo -e "\n\t${RED}*****************************${NC}\n" fi } setEnvironment(){ # Copy General auto scripts if [ ! -e auto ]; then if [ -e /usr/share/isomaker/types/$DISTRO/auto ]; then cp -r /usr/share/isomaker/types/$DISTRO/auto ./auto else cp -r /usr/share/isomaker/scripts ./auto fi fi # Copy Distro configuration if [ -e /usr/share/isomaker/types/$DISTRO/settings ]; then cp /usr/share/isomaker/types/$DISTRO/settings ./auto/ fi # Copy if exists custom uefi files if [ -e /usr/share/isomaker/types/$DISTRO/uefi ]; then cp -r /usr/share/isomaker/types/$DISTRO/uefi ./auto/ fi if [ -n "$MIRROR" ]; then echo "MIRROR=\"$MIRROR\"" >> $VARIABLES_FILE echo "MIRRORDEFAULT=\"$MIRROR\"" >> $VARIABLES_FILE fi if [ -n "$KERNEL" ]; then echo "KERNEL_PACKAGES=\"$KERNEL_PACKAGES\"" >> $VARIABLES_FILE fi if [ -n "$ARCH" ]; then echo "ARCH=\"${ARCH}\"" >> $VARIABLES_FILE fi if [ -n "$INTERACTIVE" ]; then echo "INTERACTIVE=true" >> $VARIABLES_FILE fi echo "DISTRO=\"${DISTRO}\"" >> $VARIABLES_FILE echo "FLAVOUR=\"${FLAVOUR}\"" >> $VARIABLES_FILE } ########## # # # MAIN # # # ########## # Parse arguments while [[ $# > 0 ]]; do case $1 in build|configure|chroot) ACTION=$1 DISTRO="$2" FLAVOUR="$3" shift ;; clean) ACTION="clean" ;; -a) ARCH="$2" shift ;; -k) KERNEL_PACKAGES="$2" shift ;; -m) MIRROR="$2" shift ;; -i|--interactive) INTERACTIVE="true" ;; -p) EXTRA_PPAS="${EXTRA_PPAS} $2" shift ;; -u) EXTRA_MIRRORS_UNTRUSTED="${EXTRA_MIRRORS_UNTRUSTED} $2" shift ;; -e) EXTRA_MIRRORS="${EXTRA_MIRRORS} $2" shift ;; -s) echo "$2" SOURCELISTINLINE="$2" shift ;; esac shift done case $ACTION in clean) lb clean rm -r * exit 0 ;; build|configure|chroot) #continue ;; *) usage exit 0 ;; esac # Build iso setEnvironment cleanExtraSources mkdir -p auto/additional_config rsync -ax --ignore-existing /usr/share/isomaker/types/$DISTRO/configuration/common/* auto/additional_config/ || true rsync -ax /usr/share/isomaker/types/$DISTRO/configuration/$FLAVOUR/* auto/additional_config || true mkdir -p auto/additional_config/preseed/ if [ -e /usr/share/isomaker/types/$DISTRO/preseed.list ]; then while read line; do if [ -e "$line" ]; then FILENAME=$(basename $line) rsync -ax --ignore-existing "$line" auto/additional_config/preseed/${FILENAME}.preseed.chroot fi done < /usr/share/isomaker/types/$DISTRO/preseed.list fi if [ -e /usr/share/isomaker/types/$DISTRO/configuration/$FLAVOUR/preseed.list ]; then while read line; do if [ -e "$line" ]; then FILENAME=$(basename $line) rsync -ax --ignore-existing "$line" auto/additional_config/preseed/${FILENAME}_${FLAVOUR}.preseed.chroot fi done < /usr/share/isomaker/types/$DISTRO/configuration/$FLAVOUR/preseed.list fi if [ "$ACTION" = "chroot" ]; then lb config --initramfs none else lb config fi # Append ppas if [ "${EXTRA_PPAS}" != "" ]; then addPPA ${EXTRA_PPAS} fi if [ "${EXTRA_MIRRORS}" != "" ]; then addExtraMirror ${EXTRA_MIRRORS} fi if [ "${EXTRA_MIRRORS_UNTRUSTED}" != "" ]; then addExtraMirrorUntrusted ${EXTRA_MIRRORS_UNTRUSTED} fi if [ "${SOURCELISTINLINE}" != "" ]; then addSourceListInline ${SOURCELISTINLINE} fi if [ "$ACTION" = "configure" ]; then exit 0 fi if [ "$ACTION" = "chroot" ]; then lb bootstrap lb chroot exit 0 fi lb build cerr=$? showResume showErrors if [ -e "binary.hybrid.iso" ]; then source auto/settings [[ ${ARCH} = "i386" ]] && ARCHLABEL="32bits" || ARCHLABEL="64bits" DATELABEL=`date +%Y%m%d` VERSIONLABEL=`cat config/version_label || echo $DEFAULTVERSION` mv binary.hybrid.iso ${DISTRIBUTION_NAME}-${FLAVOUR}_${ARCHLABEL}_${VERSIONLABEL}_${DATELABEL}.iso fi exit $cerr