Skip to content

Commit

Permalink
Polish up WiiU deploy scripts
Browse files Browse the repository at this point in the history
== 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
  • Loading branch information
gblues committed Jan 11, 2018
1 parent e0eb625 commit 8701ce2
Show file tree
Hide file tree
Showing 5 changed files with 326 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ menu/driverspzarch.c
# Wii U
*.depend
*.rpx
*.last
wiiu/wut/elf2rpl/elf2rpl
/pkg/wiiu/retroarch
/pkg/wiiu/wiiu
/pkg/wiiu/rpx
/wiiu-devel.properties


# 3ds
/.lst
Expand Down
196 changes: 196 additions & 0 deletions dist-scripts/wiiu-new-cores.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
#!/bin/bash

source ../version.all
platform=wiiu
EXT=a
scriptDir=
pngDir=
infoDir=

original_pwd=$(pwd)

setScriptDir()
{
scriptDir=$(dirname $(readlink -f $1))
}

setInfoDir()
{
if [ -d ../../dist/info ]; then
infoDir=$(readlink -f ../../dist/info)
elif [ $(ls -1 *.info |wc -l) > 0 ]; then
infoDir=$(pwd)
fi

if [ -z "$infoDir" ]; then
echo "WARNING: Could not find your *.info files. meta.xml files will not be generated."
fi
}

setPngDir()
{
pwd
if [ -d ../media/assets/pkg/wiiu ]; then
pngDir=$(readlink -f ../media/assets/pkg/wiiu)
elif [ $(ls -1 *.png |wc -l) > 0 ]; then
pngDir=$(pwd)
fi

if [ -z "$pngDir" ]; then
echo "WARNING: Could not find your *.png files. icon.png files will not be generated."
fi
}

getCores()
{
if [ -d ../../dist/wiiu ]; then
ls -1 ../../dist/wiiu/*.a
elif [ $(ls -1 *.a |wc -l) > 0 ]; then
ls -1 *.a
fi
}

clean()
{
local here=$(pwd)

cd $scriptDir/..
make -f Makefile.wiiu clean || exit 1

for trash in libretro_wiiu.a libretro_wiiu.elf libretro_wiiu.rpx \
objs/wiiu pkg/wiiu/wiiu pkg/wiiu/retroarch pkg/wiiu/rpx
do
rm -rf $trash
done

cd $here
}

# $1 = core filename (e.g. ../../dist/wiiu/somecore_libretro_wiiu.a
# $2 = desired package type, e.g. rpx or elf
coreNameToPackageName()
{
local packageName=$(basename $1 |awk -F'\.a' '{print $1}' |sed 's/_wiiu//')
echo "$packageName"
}

lookup()
{
cat | grep "$1 = " | sed "s/$1 = \"//" | sed s/\"//
}

generateMetaXml()
{
local infoFile=$1
local xmlDir=$2
local outFile=$xmlDir/meta.xml

if [ ! -e $infoFile ]; then
return 1
fi

local display_name=$(cat $infoFile |lookup "display_name")
local corename=$(cat $infoFile |lookup "corename")
local authors=$(cat $infoFile |lookup "authors" |sed s/\|/\ -\ /g)
local systemname=$(cat $infoFile |lookup "systemname")
local license=$(cat $infoFile |lookup "license")
local build_date=$(date +%Y%m%d%H%M%S)
local build_hash=$(git rev-parse --short HEAD 2>/dev/null)

mkdir -p $xmlDir
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' > $outFile
echo '<app version="1">' >> $outFile
echo ' <name>'$corename'</name>' >> $outFile
echo ' <coder>'$authors'</coder>' >> $outFile
echo ' <version>'$RARCH_VERSION' r'$build_hash'</version>' >> $outFile
echo ' <release_date>'$build_date'</release_date>' >> $outFile
echo ' <short_description>RetroArch</short_description>' >> $outFile
echo -e ' <long_description>'$display_name'\n\nSystem: '$systemname'\nLicense: '$license'</long_description>' >> $outFile
echo ' <category>emu</category>' >> $outFile
echo ' <url>https://github.com/libretro</url>' >> $outFile
echo '</app>' >> $outFile
}

copyPng()
{
local pngFilename=$(echo $1 |sed 's/_libretro//').png
local destFilename=$2/icon.png

if [ -e $pngDir/$pngFilename ]; then
cp $pngDir/$pngFilename $destFilename
fi
}

buildCore()
{
local core=$1
local distDir=$(pwd)
local buildDir=$(dirname $(pwd))
local packageName=$(coreNameToPackageName $core)
local rpxResult=$packageName.rpx
local elfResult=$packageName.elf

cd $buildDir

if [ -f Makefile.wiiu ]; then
echo "--- building core: $packageName ---"
rm -f libretro_wiiu.a
cp $distDir/$core libretro_wiiu.a
make -f Makefile.wiiu \
PC_DEVELOPMENT_IP_ADDRESS=$PC_DEVELOPMENT_IP_ADDRESS \
PC_DEVELOPMENT_TCP_PORT=$PC_DEVELOPMENT_TCP_PORT \
-j3 || exit 1

if [ ! -z "$infoDir" ]; then
for i in 'pkg/wiiu/retroarch/cores' 'pkg/wiiu/rpx/retroarch/cores'; do
mkdir -p $i/info
cp $infoDir/$packageName.info $i/info
generateMetaXml $i/info/$packageName.info $i/../../wiiu/apps/$packageName
done
fi

if [ ! -z "$pngDir" ]; then
for i in 'pkg/wiiu/wiiu/apps' 'pkg/wiiu/rpx/wiiu/apps'; do
copyPng $packageName $i/$packageName
done
fi

for i in "pkg/wiiu/wiiu/apps/$packageName" 'pkg/wiiu/retroarch/cores'; do
mkdir -p $i
cp retroarch_wiiu.elf $i/$elfResult
done
for i in "pkg/wiiu/rpx/wiiu/apps/$packageName" 'pkg/wiiu/rpx/retroarch/cores'; do
mkdir -p $i
cp retroarch_wiiu.rpx $i/$rpxResult
done
else
echo "ERROR: Something went wrong. Makefile.wiiu not found."
exit 1
fi

cd $distDir
}

setScriptDir $0

clean

cd $scriptDir
if [ -e ../wiiu-devel.properties ]; then
. ../wiiu-devel.properties
fi

setInfoDir
setPngDir

cores=$(getCores)

if [ -z "$cores" ]; then
echo "ERROR: No cores found. Nothing to do."
exit 1
fi

for core in $cores; do
buildCore $core
done

104 changes: 104 additions & 0 deletions dist-scripts/wiiu-rpx-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/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
26 changes: 13 additions & 13 deletions version.all
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# /* this file is a polyglot: it's valid C, Makefile and shell */
# /* this reduces the number of files to update when changing the version */
# /* files to change to update version: */
# /* - this one, obviously */
# /* - version.dtd */
# /* - pkg/snap/snapcraft.yaml (including the github url) */
#if 0
RARCH_VERSION="1.7.0"
#endif
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "1.7.0"
#endif
# /* this file is a polyglot: it's valid C, Makefile and shell */
# /* this reduces the number of files to update when changing the version */
# /* files to change to update version: */
# /* - this one, obviously */
# /* - version.dtd */
# /* - pkg/snap/snapcraft.yaml (including the github url) */

#if 0
RARCH_VERSION="1.7.0"
#endif
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "1.7.0"
#endif
10 changes: 10 additions & 0 deletions wiiu-devel.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# To use this file:
# 1. Copy this file to wiiu-devel.properties
# 2. Fill in the variables below with your IP address and desired
# port number.
#

PC_DEVELOPMENT_IP_ADDRESS=
PC_DEVELOPMENT_TCP_PORT=4405
WIIU_IP_ADDRESS=

0 comments on commit 8701ce2

Please sign in to comment.