Skip to content
Snippets Groups Projects
Commit 3b43eff8 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci
Browse files

build-update-package: Improved and added some comments, messages and the code

parent 8dd171b6
No related branches found
No related tags found
No related merge requests found
...@@ -19,35 +19,28 @@ ...@@ -19,35 +19,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA. # USA.
PREFIX="$(dirname $0)" PREFIX="$(dirname $0)"
# Get the configuration # Get the configuration
if ! source "${PREFIX}/buildpackage.conf" 2> /dev/null; then 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 exit 1
fi fi
# Customizable variables, please refer to # Customizable variables. Please refer to buildpackage.conf to change these
# buildpackage.conf to change these values # values
: ${AGENTDIR:="agent-files"} : ${AGENTDIR:="agent-files"}
: ${AGENTPACKAGEDIR:="SEED2-run"} : ${AGENTPACKAGEDIR:="SEED2-run"}
: ${UPDATEDIR:="update-files"} : ${UPDATEDIR:="update-files"}
BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-update" BOOTSTRAP="${PREFIX}/bootstraps/bootstrap-update"
VERSIONFILE="${AGENTDIR}/${AGENTPACKAGEDIR}/client/conf/version" VERSIONFILE="${AGENTDIR}/${AGENTPACKAGEDIR}/client/conf/version"
printf "====================\n" printf "====================\n"
printf "$0 v0.1\n" printf "$0 v0.1\n\n"
printf "\n"
printf "*** Make sure ${AGENTDIR}/${AGENTPACKAGEDIR}\n" printf "*** Make sure ${AGENTDIR}/${AGENTPACKAGEDIR}\n"
printf "contains the latest package generated by build-agent-files ***\n" printf "contains the latest package generated by build-agent-files ***\n"
printf "====================\n" printf "====================\n\nStarting to build the package...\n\n"
printf "\n"
printf "Starting build the package...\n\n"
# Check the readability of version file and get the version # Check the readability of version file and get the version
if ! test -r "${VERSIONFILE}"; then if ! test -r "${VERSIONFILE}"; then
...@@ -56,7 +49,13 @@ if ! test -r "${VERSIONFILE}"; then ...@@ -56,7 +49,13 @@ if ! test -r "${VERSIONFILE}"; then
fi fi
VERSION=$(cat ${VERSIONFILE}) VERSION=$(cat ${VERSIONFILE})
# Set the output file name
OUTPUT="${UPDATEDIR}/SEED2-update-${VERSION}.run"
# -----------------------------------------------------------------------------
# Compress the agent files
printf "Compressing SEED2-run files... " printf "Compressing SEED2-run files... "
cd "${AGENTDIR}" cd "${AGENTDIR}"
TARFILE=$(tempfile --prefix=SEED2-tar) TARFILE=$(tempfile --prefix=SEED2-tar)
if ! tar -czf "${TARFILE}" SEED2-run; then if ! tar -czf "${TARFILE}" SEED2-run; then
...@@ -64,14 +63,23 @@ if ! tar -czf "${TARFILE}" SEED2-run; then ...@@ -64,14 +63,23 @@ if ! tar -czf "${TARFILE}" SEED2-run; then
exit 2 exit 2
fi fi
cd - &> /dev/null 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}') MD5_CHECK=$(md5sum ${TARFILE} | awk '{print $1}')
printf " done\n\n"
OUTPUT="${UPDATEDIR}/SEED2-update-${VERSION}.run" printf "done.\n"
# End of MD5 calculation
# -----------------------------------------------------------------------------
# Generate the update package
printf "Creating update .run package... " printf "Creating update .run package... "
mkdir -p "${UPDATEDIR}" mkdir -p "${UPDATEDIR}"
LINENUM=$(( $(wc -l "${BOOTSTRAP}" | cut -d' ' -f1) + 1 )) LINENUM=$(( $(wc -l "${BOOTSTRAP}" | cut -d' ' -f1) + 1 ))
...@@ -81,8 +89,11 @@ sed "s/BOOTSTRAP_LINES=/BOOTSTRAP_LINES=${LINENUM}/g; \ ...@@ -81,8 +89,11 @@ sed "s/BOOTSTRAP_LINES=/BOOTSTRAP_LINES=${LINENUM}/g; \
"${BOOTSTRAP}" > "${OUTPUT}" "${BOOTSTRAP}" > "${OUTPUT}"
cat "${TARFILE}" >> "${OUTPUT}" cat "${TARFILE}" >> "${OUTPUT}"
printf "done\n"
printf "done.\n"
# End of update package generation
# Remove the tar file
rm -f "${TARFILE}" rm -f "${TARFILE}"
printf "All done.\n" printf "\nAll done.\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment