2019-01-27 08:27:57 +02:00
#!/bin/bash
#Copy the repo, clean it, and write the version for the release
cd ~/build || exit
echo "Changing dir to :"
pwd
echo "Copying RedMew folder to work on"
cp -rf Refactorio/RedMew working_copy
echo "Removing git files"
rm -rf working_copy/.??*
echo "Writing the version file"
2019-02-03 19:18:42 +02:00
echo " global.redmew_version=' $DATE_FORMATTED - $COMMIT_SHA ' " > working_copy/resources/version.lua
2019-01-27 08:27:57 +02:00
echo "Contents of the version file:"
cat working_copy/resources/version.lua
2019-02-01 18:03:02 +02:00
echo "Copying map_selection.lua.sample to map_selection.lua"
cp working_copy/map_selection.lua.sample working_copy/map_selection.lua
2019-01-27 08:27:57 +02:00
#Create zips for each of the major maps/scenarios
function process_map ( ) {
2019-02-01 03:36:08 +02:00
#Show us which file is being worked on
2019-01-27 21:40:07 +02:00
echo " ----- $1 ----- "
2019-02-01 03:36:08 +02:00
#Rename the directory per map
2019-01-27 08:27:57 +02:00
mv " $3 " " $1 "
2019-02-01 18:03:02 +02:00
# Overwrite the first line of map_selection.lua
sed -i " 1s/.*/return require 'map_gen.maps. $2 '/ " " $1 /map_selection.lua "
echo "First line of map_selection:"
#Display the first line of map_selection.lua for verification
head -1 " $1 /map_selection.lua "
2019-02-01 03:36:08 +02:00
if [ " $4 " != true ] ; then #Base RedMew can't be deflated
echo "Remove binary files (images)"
#Remove the binary files that don't compress well
2019-02-01 03:47:26 +02:00
rm " $1 " /redmew_git_banner.png -f
rm " $1 " /map_gen/data/.source_images -rf
rm " $1 " /map_gen/data/.map_previews -rf
2019-02-01 03:36:08 +02:00
fi
2019-01-27 08:27:57 +02:00
echo "Creating zip..."
2019-02-01 03:36:08 +02:00
#Create the actual zip file with recursion, quiet, and max compression
2019-01-27 21:40:07 +02:00
zip -r9q " $1 .zip " " $1 "
2019-01-27 08:27:57 +02:00
echo "Stats on the zip:"
2019-01-27 21:40:07 +02:00
ls -al " $1 .zip "
cp " $1 .zip " " $HOME /build/Refactorio/RedMew/ $1 .zip "
2019-01-27 08:27:57 +02:00
PREVIOUS_NAME = $1
export PREVIOUS_NAME
return 0
}
#Each map after the default redmew release repeats the pattern of $1=The regular name of the map (proper casing), $2=The name of the map file (lower case), $3 "$PREVIOUS_NAME"
process_map "RedMew" "default" "working_copy" true
2019-02-01 03:36:08 +02:00
process_map "Diggy" "diggy" " $PREVIOUS_NAME "
process_map "Crashsite" "crash_site" " $PREVIOUS_NAME "
process_map "Tetris" "tetris" " $PREVIOUS_NAME "
2019-02-01 18:03:02 +02:00
process_map "Beach" "beach" " $PREVIOUS_NAME "
process_map "Danger_Ores" "danger_ores" " $PREVIOUS_NAME "
process_map "Grid_Islands_Rotated" "grid_islands_rotated" " $PREVIOUS_NAME "
process_map "Toxic_Danger_Ore_Jungle" "toxic_danger_ore_jungle" " $PREVIOUS_NAME "
process_map "Hub_Spiral" "hub_spiral" " $PREVIOUS_NAME "
process_map "Bacon_Islands" "bacon_islands" " $PREVIOUS_NAME "
process_map "Triangle_of_Death" "triangle_of_death" " $PREVIOUS_NAME "