diff --git a/build-agent-files b/build-agent-files index 56b1a566391da0d5933351fbbd60380f38640fc4..54b3db16969e9c83b2a71c195a47c0e75da9231d 100755 --- a/build-agent-files +++ b/build-agent-files @@ -24,12 +24,12 @@ PREFIX="$(dirname $0)" # Get the configuration if ! source "${PREFIX}/buildpackage.conf" 2> /dev/null; then - echo "error: failed to load buildpackage.conf" + printf "ERROR (1): Failed to load buildpackage.conf.\n" exit 1 fi -# Customizable variables, please refer to -# buildpackage.conf to change these values +# Customizable variables. Please refer to buildpackage.conf to change these +# values : ${GITBASEDIR:="../"} : ${GITUSER:="git"} : ${GITSERVER:="git.c3sl.ufpr.br"} @@ -38,34 +38,29 @@ fi : ${AGENTPACKAGEDIR:="SEED2-run"} -printf "====================\n" -printf "$0 v0.1\n" -printf "\n" +printf "====================\n$0 v0.1\n\n" printf "**** Make sure that ${WEBSERVICE} webservice are up and running!!!\n" -printf "\n" -printf "NOTE: This will take a while.\n" +printf "\nNOTE: This will take a while.\n" printf " Make sure the git update process below will run ok.\n" -printf "====================\n" -printf "\n" +printf "====================\n\n" # Check if wget have been build if ! test -f "${PREFIX}/wget-"*"/src/wget"; then - printf "PLEASE USE build-wget BEFORE RUNNNING THIS SCRIPT!!\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n" - exit 1 + printf "ERROR (2): Please run build-wget before running this script. %b" \ + "Aborting...\n" + exit 2 fi # Sanity check, we do not want dynamic linked binaries on the package ldd "${PREFIX}/wget-"*"/src/wget" &> /dev/null if ! test $? -eq 1; then - printf "THE wget BINARY HAVE NOT BEEN COMPILED WITH STATIC LIBRARY!!\n" - printf "PLEASE, BUILD wget USIGN build-wget!!\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n" - exit 1 + printf "ERROR (3): The wget binary wasn't compiled with static library.%b" \ + "\nPlease, build wget using build-wget. Aborting...\n" + exit 3 fi -# Make sure all repositories are ok +# Ensure all repositories are ok printf "Updating git repositories...\n" for repo in "${GITBASEDIR}/client:client" "${GITBASEDIR}/coleta:coleta"; do REPOPATH="$(echo $repo |cut -d: -f1)" @@ -75,72 +70,67 @@ for repo in "${GITBASEDIR}/client:client" "${GITBASEDIR}/coleta:coleta"; do # Check the environment if ! cd "${REPOPATH}" 2> /dev/null; then if ! cd "${GITBASEDIR}" 2> /dev/null; then - printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n" - printf "MAKE SURE THAT GITBASEDIR EXISTS AND HAVE ACCESS TO IT.\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n" - exit 1 + printf "ERROR (4): Something went wrong.\nMake sure that %b%b" \ + "GITBASEDIR exists and the script has access to it. " \ + "Aborting...\n" + exit 4 else printf "git clone ${REPONAME}...\n" if git clone ${GITUSER}@${GITSERVER}:seed2/${REPONAME}.git; then cd - &> /dev/null cd "${REPOPATH}" else - printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n" - printf "PROBLEMS EXECUTING GIT CLONE...\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n" - exit 1 + printf "ERROR (5): Something went wrong.\nProblems %b" \ + "executing git clone(1). Aborting...\n" + exit 5 fi fi fi if ! git pull; then - printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n" - printf "PROBLEMS EXECUTING GIT PULL...\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n" - exit 1 + printf "ERROR (6): Something went wrong.\n Problems executing %b" \ + "git pull(1). Aborting...\n" + exit 6 fi cd - &> /dev/null done printf "\n\n" -# Compile agent and collect -printf "Starting compilation proccess...\n\n" -printf "Starting compiling client..\n\n" +# Compile the collect agent and the client +printf "Starting compilation process...\n\n" +printf "Starting client compilation...\n\n" sleep 1 cd "${GITBASEDIR}/client" if make && make install; then - printf "\n\n" - printf "Client compilation is finished.\n" - printf "EVERYTHING WAS FINE\n\n" + printf "\n\nClient compilation is finished.\n%b" \ + "Everything was fine.\n\n" else printf "\n\n" - printf "Client compilation is finished.\n" - printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n" - exit 1 + printf "ERROR (7): Client compilation is finished.\n%b" \ + "Something went wrong. Aborting...\n\n" + exit 7 fi cd - -printf "Starting compiling collect-parser...\n\n" +printf "Starting collect-parser compilation...\n\n" sleep 1 cd "${GITBASEDIR}/coleta" if make && make install; then printf "\n\n" - printf "Collect-parser compilation is finished.\n" - printf "EVERYTHING WAS FINE\n\n" + printf "Collect-parser compilation is finished.\n%b" \ + "Everything was fine.\n\n" else printf "\n\n" - printf "Collect-parser compilation is finished.\n" - printf "SOMETHING WENT WRONG !!!!!!!!!!!!!!!!!!!!!!!!\n" - printf "ABORTING !!!!!!!!!!!!!!!!!!!!!!!!\n\n" - exit 1 + printf "ERROR (8): Collect-parser compilation is finished.\n%b" \ + "Something went wrong. Aborting...\n\n" + exit 8 fi cd - # Build the package itself -printf "Starting build the package...\n" +printf "Starting to build the package...\n" OUTDIR="${AGENTDIR}/${AGENTPACKAGEDIR}/" rm -Rf "${OUTDIR}" @@ -164,11 +154,11 @@ tests version EOF -printf "Copying collect files..." +printf "Copying collect files... " rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \ "${GITBASEDIR}/coleta/"* "${OUTDIR}" rm -Rf "${OUTDIR}/lib/libxml2"* -printf " done\n" +printf "done.\n" cat > ${EXCLUDEFILE} << EOF src @@ -184,20 +174,20 @@ TODO tests EOF -printf "Copying client files..." +printf "Copying client files... " rsync -aHx --delete --exclude-from=${EXCLUDEFILE} \ "${GITBASEDIR}/client/"* "${OUTDIR}/client/" -printf " done\n\n" +printf "done.\n" BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-install" -printf "Copying bootstrap..." +printf "Copying bootstrap... " cp -a "${BOOTSTRAP}" "${AGENTDIR}"/ -printf " done\n\n" +printf "done.\n" -printf "Copying wget binary..." +printf "Copying wget binary... " cp -a "${PREFIX}/wget-"*"/src/wget" "${OUTDIR}/bin/" -printf " done\n\n" +printf "done.\n" rm -f "${EXCLUDEFILE}" -printf "All done.\n" +printf "\nAll done.\n\n"