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 @@
# 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})
# 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 "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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment