From 8701ce289a316023d4b09b1406e5b758802d176d Mon Sep 17 00:00:00 2001 From: gblues Date: Wed, 10 Jan 2018 22:30:14 -0800 Subject: [PATCH] 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 --- .gitignore | 3 + dist-scripts/wiiu-new-cores.sh | 196 ++++++++++++++++++++++++++++++++ dist-scripts/wiiu-rpx-upload.sh | 104 +++++++++++++++++ version.all | 26 ++--- wiiu-devel.properties.template | 10 ++ 5 files changed, 326 insertions(+), 13 deletions(-) create mode 100755 dist-scripts/wiiu-new-cores.sh create mode 100755 dist-scripts/wiiu-rpx-upload.sh create mode 100644 wiiu-devel.properties.template diff --git a/.gitignore b/.gitignore index 3427518389de..60c69dd61566 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/dist-scripts/wiiu-new-cores.sh b/dist-scripts/wiiu-new-cores.sh new file mode 100755 index 000000000000..1e8a53c4635f --- /dev/null +++ b/dist-scripts/wiiu-new-cores.sh @@ -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 '' > $outFile + echo '' >> $outFile + echo ' '$corename'' >> $outFile + echo ' '$authors'' >> $outFile + echo ' '$RARCH_VERSION' r'$build_hash'' >> $outFile + echo ' '$build_date'' >> $outFile + echo ' RetroArch' >> $outFile + echo -e ' '$display_name'\n\nSystem: '$systemname'\nLicense: '$license'' >> $outFile + echo ' emu' >> $outFile + echo ' https://github.com/libretro' >> $outFile + echo '' >> $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 + diff --git a/dist-scripts/wiiu-rpx-upload.sh b/dist-scripts/wiiu-rpx-upload.sh new file mode 100755 index 000000000000..aacaabb797b8 --- /dev/null +++ b/dist-scripts/wiiu-rpx-upload.sh @@ -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 <