Commit 33563c83 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci

build-update-package: Added code to ensure files integrity

Signed-off-by: default avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
Acked-by: default avatarDanilo Kiyoshi Simizu Yorinori <danilok@c3sl.ufpr.br>
parent e93f1f89
......@@ -19,7 +19,19 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# This function checks one file integrity
check_file_integrity(){
FILE="$*"
FILEREAL="$(echo ${FILE} | sed "s#^${MD5DIRESC}##g")"
test -f "${AGENTPACKAGEDIR}/${FILEREAL}" || return 1
(md5sum "${AGENTPACKAGEDIR}/${FILEREAL}" | cut -d' ' -f1 | \
diff - "${FILE}" &> /dev/null) || return 1
}
PREFIX="$(dirname $0)"
MD5DIR="${AGENTDIR}/${AGENTPACKAGEDIR}/.md5sum"
MD5DIRESC="$(echo ${MD5DIR} | sed "s/\./\\\./g")"
# Get the configuration
if ! source "${PREFIX}/buildpackage.conf" 2> /dev/null; then
......@@ -52,11 +64,27 @@ VERSION=$(cat ${VERSIONFILE})
# Set the output file name
OUTPUT="${UPDATEDIR}/SEED2-update-${VERSION}.run"
# Change to agent directory
cd "${AGENTDIR}"
# -----------------------------------------------------------------------------
# Check all MD5 files
printf "Checking SEED2-run files integrity... "
for FILE in $(find "${MD5DIR}" -type f); do
if ! check_file_integrity "${FILE}"; then
printf "ERROR: File(s) corrupted. Please, re-create integrity or %b"
"rebuild the agent files.\n"
exit 1
fi
done
printf "done.\n"
# -----------------------------------------------------------------------------
# Compress the agent files
printf "Compressing SEED2-run files... "
cd "${AGENTDIR}"
TARFILE=$(tempfile --prefix=SEED2-tar)
if ! tar -czf "${TARFILE}" SEED2-run; then
printf "ERROR: Failed to compress the agent files.\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment