3 # Usage: gen-patch-zip [out-file]
5 # Generates an encrypted patch ZIP for all releases. If out-file is
6 # specified, the encrypted patch ZIP is output to that file. Otherwise, the
7 # patch ZIP is output to ./patch.zip.
12 # include convenience functions and constants
15 # the path containing the game data to be used for the patch
16 PATCH_DIR
="$ASSETS_DIR/patch-data"
18 # the patch file containing our data, using ./patch.zip by default.
19 # if we have an argument, zip and encrypt into that file instead.
20 PATCH_FILE
=${1:-patch.zip}
22 # does in-place encryption (well, using a temp file)
23 function encrypt-patch
{
24 TMP_FILE
="/tmp/oitg-patch-enc-tmp"
27 echo "you didn't give me anything to encrypt!"
31 # leave this visible in case it throws an error
32 $ITG2_UTIL_PATH -p
"$1" "$TMP_FILE"
37 # Require that the encryption file actually exists
38 has_file
"$ITG2_UTIL_PATH" "$ITG2_UTIL_FILE must be built in $ITG2_UTIL_DIR first."
40 # delete the patch file if it exists, or zip will try to update it
43 # we need this so we can put patch.zip in the CWD
46 # mild hack: wipe that CWD if we're using an absolute path
47 if [ ${PATCH_FILE:0:1} == "/" ]; then CWD
=""; fi
50 echo "Zipping files into $PATCH_FILE..."
51 zip -rq
"$CWD/$PATCH_FILE" .
/*/
54 echo "Encrypting patch data..."
55 encrypt-patch
"$PATCH_FILE"
57 echo "Patch successfully created: $PATCH_FILE"