#!/bin/bash set +h umask 022 zprint() { echo -e "${zzwhite} *** $* *** ${zzreset}"; } zmsg() { echo -e "${zzred} *** $* *** ${zzreset}"; } stars() { echo -e "${zzpurple} $(printf '%.0s*' {1..100}) ${zzreset}"; } print_formatted_duration() { duration=$1 hour=$((duration / 3600)) mins=$(( (duration % 3600) / 60 )) sec=$((duration % 60)) zprint $(printf "%02d Hours, %02d Minutes and %02d Seconds \n" ${hour} ${mins} ${sec}) } zbuild_check() { local file="$1" if [[ -f ${ZBUILD}/${file} ]]; then return 0 else stars zprint "Error: Missing $file ... Exiting" return 1 fi } zbuild_wait() { local wait=${1:-5} zmsg "Waiting $wait seconds or Press [SPACE] to continue..." read -t $wait -n 1 key if [[ $key == " " ]]; then zmsg "Skipped wait." else zmsg "Continuing..." fi } zbuild_exec() { local file="$1" case "$file" in *.zbc) ${ZBUILD}/zbuild "${ZBUILD}/$file" || { echo "Error: $file - Exiting: $?"; return 1; } ;; *.sh) "${ZBUILD}/$file" || { echo "Error: $file - Exiting: $?"; return 1; } ;; *) zmsg "Invalid File Found in Stream" return 666 ;; esac } # # Start of Package Builder # ZBefore=`date +%s` zzreset="\033[0m" zzwhite="\033[1;37m" zzred="\033[1;31m" zzpurple="\033[1;35m" export ZSRC=/sources export ZBUILD=/zbuild if [[ -z $1 ]]; then zmsg "Source script required to run" exit 1 else source "$1" fi if [[ ${#stage_build[@]} -eq 0 ]]; then zmsg "Requires stage_build list of packages" exit 1 fi for script in ${stage_build[@]}; do stars zprint "Executing ${script}" zbuild_check "${script}" || break zbuild_wait 5 zbuild_exec "${script}" stars done ZAfter=`date +%s` let duration=ZAfter-ZBefore print_formatted_duration $duration