From ec672e1566b8a9e94781dcdfe5e05f776fa348e0 Mon Sep 17 00:00:00 2001 From: "Mike Kostersitz (Oilcan Productions)" Date: Fri, 26 Apr 2024 16:05:17 -0700 Subject: [PATCH] Updated deploy-ftp with retry flow --- build/deploy-ftp.sh | 96 ++++++++++++++++++++++++++------------------- tools/sims | 2 +- tools/tv11 | 2 +- tools/tv11.old | 1 + 4 files changed, 59 insertions(+), 42 deletions(-) create mode 160000 tools/tv11.old diff --git a/build/deploy-ftp.sh b/build/deploy-ftp.sh index 7d30ae3c..82ed067a 100644 --- a/build/deploy-ftp.sh +++ b/build/deploy-ftp.sh @@ -1,12 +1,12 @@ #!/bin/sh -set -e - HOST="hactrn.kostersitz.com" USER="if0_35726802@hactrn.kostersitz.com" DIR="/images" TESTDIR="test" NETRC="$HOME/.netrc" +RETRY_LIMIT=5 +retry_count=0 if test -z "$FTP_SECRET"; then echo 'ERROR: No password in $FTP_SECRET.' @@ -18,11 +18,12 @@ echo "login $USER" >> "$NETRC" echo "password $FTP_SECRET" >> "$NETRC" chmod 600 "$NETRC" -(cd out; tar czf $EMULATOR.tgz $EMULATOR) +upload_file(){ + (cd out; tar czf $EMULATOR.tgz $EMULATOR) -echo "Deploying as $USER at $HOST" + echo "Deploying as $USER at $HOST" -ftp "$HOST" <&1)" - exit 1 + echo "Testing archive $EMULATOR.tgz" + if tar -xzf "$EMULATOR.tgz"; then + echo "Unpacking successful!" + else + echo "Error unpacking $EMULATOR.tgz: $(tar -xzf "$EMULATOR.tgz" 2>&1)" + cd .. + rm -rf "$TESTDIR" + return 1 + fi fi -fi -echo "Testing archive integrity" -# Define the paths to the folders -BUILDDIR="../$EMULATOR" -DLDIR="./$EMULATOR" + echo "Testing archive integrity" + BUILDDIR="../$EMULATOR" + DLDIR="./$EMULATOR" -# Generate MD5 hashes for files in FOLDER1 (with relative filenames) -find "$BUILDDIR" -type f -exec md5sum {} + | sed "s|$BUILDDIR/||" > "$BUILDDIR_hashes.txt" + find "$BUILDDIR" -type f -exec md5sum {} + | sed "s|$BUILDDIR/||" > "$BUILDDIR_hashes.txt" + find "$DLDIR" -type f -exec md5sum {} + | sed "s|$DLDIR/||" > "$DLDIR_hashes.txt" -# Generate MD5 hashes for files in FOLDER2 (with relative filenames) -find "$DLDIR" -type f -exec md5sum {} + | sed "s|$DLDIR/||" > "$DLDIR_hashes.txt" + if cmp -s "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"; then + echo "The contents of $BUILDDIR and $DLDIR are binary identical." + cd .. + rm -rf "$TESTDIR" + return 0 + else + echo "Differences found between $BUILDDIR and $DLDIR:" + diff -u "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt" + cd .. + rm -rf "$TESTDIR" + return 1 + fi +} -# Compare the hash files -if cmp -s "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"; then - echo "The contents of $BUILDDIR and $DLDIR are binary identical." -else - echo "Differences found between $BUILDDIR and $DLDIR:" - diff -u "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt" -fi -# Clean up temporary files -cd .. -rm -r "$TESTDIR" +while [ $retry_count -lt $RETRY_LIMIT ]; do + upload_file + if test_archive_integrity; then + echo "File integrity verified successfully." + exit 0 + else + echo "File integrity verification failed, retrying... ($((retry_count+1))/$RETRY_LIMIT)" + retry_count=$((retry_count+1)) + fi +done -exit 0 +echo "Reached maximum retry limit, exiting with failure." +exit 1 diff --git a/tools/sims b/tools/sims index 20fa16ec..48186c90 160000 --- a/tools/sims +++ b/tools/sims @@ -1 +1 @@ -Subproject commit 20fa16ec1ce720eeaa8d8e52eeaee7f0d498df94 +Subproject commit 48186c90c49b3711090720fb38f3f88010ef576b diff --git a/tools/tv11 b/tools/tv11 index cb5e5615..e45a3307 160000 --- a/tools/tv11 +++ b/tools/tv11 @@ -1 +1 @@ -Subproject commit cb5e561508237612e22b5b430bf966f40929adb3 +Subproject commit e45a330754fe4e34c4907d7fc9aa00304113880e diff --git a/tools/tv11.old b/tools/tv11.old new file mode 160000 index 00000000..e45a3307 --- /dev/null +++ b/tools/tv11.old @@ -0,0 +1 @@ +Subproject commit e45a330754fe4e34c4907d7fc9aa00304113880e