From 3b43eff83974f8f0f563bf3c0bd3d3baa42d48d7 Mon Sep 17 00:00:00 2001 From: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Date: Tue, 26 Apr 2011 17:21:35 -0300 Subject: [PATCH] build-update-package: Improved and added some comments, messages and the code Signed-off-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Acked-by: Danilo Kiyoshi Simizu Yorinori <danilok@c3sl.ufpr.br> Acked-by: Tiago Rodrigo Kepe <trk08@c3sl.ufpr.br> --- build-update-package | 51 +++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/build-update-package b/build-update-package index 4f77000..ce03ed6 100755 --- a/build-update-package +++ b/build-update-package @@ -19,35 +19,28 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. - PREFIX="$(dirname $0)" # Get the configuration if ! source "${PREFIX}/buildpackage.conf" 2> /dev/null; then - echo "error: failed to load buildpackage.conf" + printf "ERROR: 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 : ${AGENTDIR:="agent-files"} : ${AGENTPACKAGEDIR:="SEED2-run"} : ${UPDATEDIR:="update-files"} - BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-update" VERSIONFILE="${AGENTDIR}/${AGENTPACKAGEDIR}/client/conf/version" printf "====================\n" -printf "$0 v0.1\n" -printf "\n" +printf "$0 v0.1\n\n" printf "*** Make sure ${AGENTDIR}/${AGENTPACKAGEDIR}\n" printf "contains the latest package generated by build-agent-files ***\n" -printf "====================\n" -printf "\n" - - -printf "Starting build the package...\n\n" +printf "====================\n\nStarting to build the package...\n\n" # Check the readability of version file and get the version if ! test -r "${VERSIONFILE}"; then @@ -56,7 +49,13 @@ if ! test -r "${VERSIONFILE}"; then fi VERSION=$(cat ${VERSIONFILE}) -printf "Compressing SEED2-run files..." +# Set the output file name +OUTPUT="${UPDATEDIR}/SEED2-update-${VERSION}.run" + +# ----------------------------------------------------------------------------- +# Compress the agent files +printf "Compressing SEED2-run files... " + cd "${AGENTDIR}" TARFILE=$(tempfile --prefix=SEED2-tar) if ! tar -czf "${TARFILE}" SEED2-run; then @@ -64,14 +63,23 @@ if ! tar -czf "${TARFILE}" SEED2-run; then exit 2 fi cd - &> /dev/null -printf " done\n" -printf "Calculating MD5SUM..." +printf "done.\n" +# End of agent compression + +# ----------------------------------------------------------------------------- +# Calculate the MD5 +printf "Calculating MD5... " + MD5_CHECK=$(md5sum ${TARFILE} | awk '{print $1}') -printf " done\n\n" -OUTPUT="${UPDATEDIR}/SEED2-update-${VERSION}.run" -printf "Creating update .run package..." +printf "done.\n" +# End of MD5 calculation + +# ----------------------------------------------------------------------------- +# Generate the update package +printf "Creating update .run package... " + mkdir -p "${UPDATEDIR}" LINENUM=$(( $(wc -l "${BOOTSTRAP}" | cut -d' ' -f1) + 1 )) @@ -81,8 +89,11 @@ sed "s/BOOTSTRAP_LINES=/BOOTSTRAP_LINES=${LINENUM}/g; \ "${BOOTSTRAP}" > "${OUTPUT}" cat "${TARFILE}" >> "${OUTPUT}" -printf "done\n" +printf "done.\n" +# End of update package generation + +# Remove the tar file rm -f "${TARFILE}" -printf "All done.\n" +printf "\nAll done.\n" -- GitLab