RetroArch/dist-scripts/wiiu-rpx-upload.sh
gblues 8701ce289a Polish up WiiU deploy scripts
== DETAILS
Some updates for the WiiU port:

1. Implement a way to set logging IP/port that doesn't risk getting committed.

   To do this, I've created `wiiu-devel.properties.template` and added the file
   `wiiu-devel.properties` to .gitignore. Developers can then:

   * Copy the template file to `wiiu-devel.properties`
   * Enter the relevant details (documented in the template file)

2. Convert `version.all` to unix line endings so modern versions of bash don't
   complain when it is included.

2. Rewrote the `wiiu-cores.sh` script into `wiiu-new-cores.sh`

   - Automatically detects when building retroarch inside the `libretro-super`
     hierarchy to collect the *.info files and *.a files
   - Automatically detects the *.png (fetched by running `fetch-submodules.sh`
     script)

3. Create a `wiiu-rpx-upload.sh` script to upload the output of `wiiu-cores.sh`

   - uses `wiiu-devel.properties` to get WiiU IP address
   - after upload, re-downloads and compares hashes to detect bad uploads
2018-01-10 22:51:00 -08:00

105 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
#
# This script will upload the packaged RetroArch cores to a WiiU running
# FTPiiU or FTPiiU Anywhere
#
# IMPORTANT: This script assumes the following structur
#
# WARNING: I experienced corrupt uploads when using Dimok's FTPiiU. You
# probably want to use FIX94's FTPiiU Anywhere.
#
# After uploading everything, the script will re-download the RPX files and
# compare their hash and print an error if the file was corrupted.
#
# The WiiU's IP address can be specified by either setting the WIIU_IP_ADDRESS
# environment variable, or by configuring the wiiu-devel.properties file
# (see the file wiiu-devel.properties.template for instructions).
#
# The path to the parent directory of your retroarch/ and wiiu/ folders, as
# visible in FTPiiU.
RETRO_ROOT=sd
here=$(pwd)
cd $(dirname $(readlink -f $0))
if [ -e ../wiiu-devel.properties ]; then
. ../wiiu-devel.properties
fi
if [ -z "$WIIU_IP_ADDRESS" ]; then
echo "WIIU_IP_ADDRESS not set. Set up ../wiiu-devel.properties or set the"
echo "environment variable."
cd $here
exit 1
fi
filesToUpload()
{
find . -type f \( -name "*.rpx" -o -name "*.xml" -o -name "*.png" -o -name "*.info" \)
}
cd ../pkg/wiiu/rpx
# First, delete any previous *.remote files from previous uploads.
find . -name '*.remote' | xargs rm -f {}
# Now generate the FTP command list
rm -f .ftpcommands
# Now create the directory structure
for dir in $(find . -type "d"); do
if [ "$dir" == "." ]; then
continue
fi
echo "mkdir $dir" >> .ftpcommands
done
# Delete and re-upload the files we just built
for cmd in rm put; do
filesToUpload | xargs -L 1 echo "$cmd" >> .ftpcommands
done
# Lastly, download the RPX files as *.rpx.remote files
for rpx in $(find . -name "*.rpx"); do
echo "get $rpx ${rpx}.remote" >> .ftpcommands
done
# The command list is done. Time to execute it.
ftp -n $WIIU_IP_ADDRESS <<END_SCRIPT
quote USER wiiu
quote PASS wiiu
passive
bin
cd $RETRO_ROOT
$(cat .ftpcommands)
END_SCRIPT
rm -f .ftpcommands
errors=0
# Now, we compare the hashes of the original file and the file we got back,
# and print an error if the hashes don't match.
for remote in $(find . -name "*.remote"); do
originalFile=$(echo $remote |sed 's/\.remote//')
originalHash=$(md5sum -b $originalFile |awk '{print $1}')
remoteHash=$(md5sum -b $remote |awk '{print $1}')
if [ "$originalHash" != "$remoteHash" ]; then
echo "ERROR: $remote was corrupted during upload."
errors=$((errors+1))
fi
done
cd $here
if [ $errors -ne 0 ]; then
echo "Upload failed. $errors files failed to upload correctly."
exit 1
fi
echo "RetroArch build uploaded and validated successfully."
exit 0