diff --git a/build-update-package b/build-update-package index 4f770007a345c292ad09a83fbfc53dba463585e5..ce03ed61e23e25b3c292f5683f06b2d86e535f5e 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"