mirror of
https://github.com/TangentFoxy/love-release.git
synced 2025-07-28 11:02:20 +00:00
Changes in build/install, config, modules, cli
This commit is contained in:
46
Makefile
Normal file
46
Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
BUILD_DIR=build
|
||||
|
||||
# Installation directories
|
||||
BINARY_DIR=/usr/bin
|
||||
INSTALL_DIR=/usr/share/love-release
|
||||
MANPAGE_DIR=/usr/share/man/man1
|
||||
COMPLETION_DIR=/usr/share/bash-completion/completions
|
||||
|
||||
|
||||
SED_INSTALL_DIR=$(shell echo "$(INSTALL_DIR)" | sed -e 's/[\/&]/\\&/g')
|
||||
|
||||
love-release: clean
|
||||
mkdir -p $(BUILD_DIR)
|
||||
sed -e 's/INSTALL=false/INSTALL=true/' -e 's/SCRIPTS_DIR="scripts"/SCRIPTS_DIR="$(SED_INSTALL_DIR)\/scripts"/' love-release.sh > '$(BUILD_DIR)/love-release'
|
||||
cp love-release.1 '$(BUILD_DIR)/love-release.1'
|
||||
gzip '$(BUILD_DIR)/love-release.1'
|
||||
|
||||
install:
|
||||
install -m 0755 '$(BUILD_DIR)/love-release' '$(BINARY_DIR)'
|
||||
install -m 0755 -d '$(INSTALL_DIR)' '$(INSTALL_DIR)/scripts' '$(COMPLETION_DIR)'
|
||||
install -m 0755 scripts/* '$(INSTALL_DIR)/scripts'
|
||||
install -m 0644 -t '$(INSTALL_DIR)' README.md conf.lua
|
||||
install -m 0644 completion.sh '$(COMPLETION_DIR)/love-release'
|
||||
install -m 0644 '$(BUILD_DIR)/love-release.1.gz' '$(MANPAGE_DIR)'
|
||||
|
||||
embedded: clean
|
||||
mkdir -p '$(BUILD_DIR)'
|
||||
sed 's/EMBEDDED=false/EMBEDDED=true/' love-release.sh > '$(BUILD_DIR)/love-release.sh'
|
||||
for file in scripts/*; do \
|
||||
module="$$(basename -s '.sh' "$$file")"; \
|
||||
content='if [[ $$(execute_module "'"$$module"'") == true ]]; then'$$'\n'"$$(cat $$file)"$$'\n''fi'$$'\n\n'; \
|
||||
echo "$$content" >> "$(BUILD_DIR)/tmp"; \
|
||||
done
|
||||
sed -i.bak -e '/include_scripts_here$$/r $(BUILD_DIR)/tmp' '$(BUILD_DIR)/love-release.sh';
|
||||
chmod 0775 '$(BUILD_DIR)/love-release.sh'
|
||||
rm -rf '$(BUILD_DIR)/love-release.sh.bak' '$(BUILD_DIR)/tmp'
|
||||
|
||||
remove:
|
||||
rm -rf '$(BINARY_DIR)/love-release'
|
||||
rm -rf '$(INSTALL_DIR)'
|
||||
rm -rf '$(MANPAGE_DIR)/love-release.1.gz'
|
||||
rm -rf '$(COMPLETION_DIR)/love-release' '/etc/bash_completion.d/love-release'
|
||||
|
||||
clean:
|
||||
rm -rf '$(BUILD_DIR)'
|
||||
|
31
README.md
31
README.md
@@ -2,13 +2,21 @@
|
||||
`love-release.sh` -- Bash script to generate Love 2D game releases
|
||||
|
||||
### INSTALLATION
|
||||
git clone https://github.com/MisterDA/love-release.git
|
||||
cd love-release
|
||||
First clone the repository, then you have two choices:
|
||||
- you can build the script and install it on your system, and benefit of command-line completion, man page and extensibility,
|
||||
- or make an embedded version with every thing you need in one file
|
||||
Alternatively, you could also change the installation directories by editing the Makefile.
|
||||
|
||||
# Install system-wide
|
||||
sudo ./install.sh
|
||||
# Install in user space
|
||||
./install.sh
|
||||
```shell
|
||||
# Install on your system (assumes root rights)
|
||||
make
|
||||
make install
|
||||
|
||||
# All-in-one
|
||||
make embedded
|
||||
```
|
||||
|
||||
To remove love-release, if you haven't changed the default installation directories, run `make remove`.
|
||||
|
||||
### SYNOPSIS
|
||||
`love-release.sh [-adlmw] [-n project_name] [-r release_dir] [-v love_version] [FILES...]`
|
||||
@@ -21,10 +29,10 @@ The script fully supports Windows, MacOS either on x86 or x64,
|
||||
Debian and Android packages.
|
||||
It needs an Internet connection to download Love files,
|
||||
and relies on `curl`, `zip` and `unzip` commands.
|
||||
To set the default Love version to use,
|
||||
you can edit the very beginning of the script.
|
||||
If `lua` and a `conf.lua` file are found,
|
||||
it will automatically detect which version your project uses.
|
||||
|
||||
### CONFIGURATION
|
||||
You can install `lua` and add a `conf.lua` to your project to get automatic releases.
|
||||
See the `conf.lua` file included to see how configuration works.
|
||||
|
||||
### OPTIONS
|
||||
`-h` Print a short help
|
||||
@@ -134,9 +142,6 @@ with eventual underscores (i.e. [a-zA-Z0-9\_]), otherwise you'll get errors.
|
||||
#### OTHERS
|
||||
`--clean` Clean the cache located in `~/.cache/love-release`.
|
||||
One can replace the Love files there.
|
||||
`--config` Pass a configuration file as argument.
|
||||
It describes which build you want to make, with what options.
|
||||
See `config.ini`.
|
||||
|
||||
#### MODULES
|
||||
The script is modular.
|
||||
|
33
conf.lua
Normal file
33
conf.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
function love.conf(t)
|
||||
t.identity = nil -- The name of the save directory (string)
|
||||
-- love-release requires [a-z0-9_] characters. Cannot begin with a number.
|
||||
t.version = "0.9.2" -- The LÖVE version this game was made for (string)
|
||||
t.game_version = nil -- The version of your game (string)
|
||||
t.icon = nil -- The path to the executable icons (string)
|
||||
t.console = false -- Attach a console (boolean, Windows only)
|
||||
|
||||
t.title = "Untitled" -- The name of the game (string)
|
||||
t.author = "Unnamed" -- The name of the author (string)
|
||||
t.email = nil -- The email of the author (string)
|
||||
t.url = nil -- The website of the game (string)
|
||||
t.description = nil -- The description of the game (string)
|
||||
|
||||
-- OS to release your game on. Use a table if you want to overwrite the options, or just the OS name.
|
||||
-- Available OS are "love", "windows", "osx", "debian" and "android".
|
||||
-- A LÖVE file is created if none is specified.
|
||||
t.os = {
|
||||
"love",
|
||||
windows = {
|
||||
x86 = true,
|
||||
x64 = true,
|
||||
installer = false,
|
||||
appid = nil,
|
||||
},
|
||||
"osx",
|
||||
"debian",
|
||||
"android",
|
||||
}
|
||||
|
||||
-- t.window.*
|
||||
-- t.modules.*
|
||||
end
|
89
config.ini
89
config.ini
@@ -1,89 +0,0 @@
|
||||
; love-release config file
|
||||
|
||||
; Default values will be used if the option is left blank.
|
||||
; To prevent a build from being executed, comment its section name and options.
|
||||
|
||||
[global]
|
||||
; Directory where the zip archives will be stored
|
||||
release_dir="releases"
|
||||
|
||||
; Love version to use
|
||||
love_version="0.9.1"
|
||||
|
||||
; Project's name
|
||||
project_name=""
|
||||
|
||||
; Homepage
|
||||
homepage=""
|
||||
|
||||
; Description
|
||||
description=""
|
||||
|
||||
|
||||
[windows]
|
||||
; Path to an .ico file to use
|
||||
icon=""
|
||||
|
||||
; Create an installer rather than a zip
|
||||
installer="false"
|
||||
|
||||
; Package name
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
package_name=""
|
||||
|
||||
; Version of the package
|
||||
package_version=""
|
||||
|
||||
; Maintainer name (full name)
|
||||
maintainer_name=""
|
||||
|
||||
; App id. Typically a GUID
|
||||
appid=""
|
||||
|
||||
|
||||
[macosx]
|
||||
; Set the maintainer's name. Provide it for CFBundleIdentifier.
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
maintainer_name=""
|
||||
|
||||
; Path to an .icns file to use
|
||||
icon=""
|
||||
|
||||
|
||||
[debian]
|
||||
; Version of the package
|
||||
package_version=""
|
||||
|
||||
; Maintainer name (full name)
|
||||
maintainer_name=""
|
||||
|
||||
; Maintainer_email
|
||||
maintainer_email=""
|
||||
|
||||
; Package name
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
package_name=""
|
||||
|
||||
; Icon directory
|
||||
; Icons must contain YYxYY in their filename to be recognized,
|
||||
; where YY is the resolution of the icon.
|
||||
; SVG files are recognized if suffixed with .svg
|
||||
icon=""
|
||||
|
||||
|
||||
[android]
|
||||
; Android game activity
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
activity=""
|
||||
|
||||
; Package version
|
||||
package_version=""
|
||||
|
||||
; Maintainer name
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
maintainer_name=""
|
||||
|
||||
; Package name
|
||||
; No spaces and no special characters except underscore. Better be lowercase.
|
||||
package_name=""
|
||||
|
69
install.sh
69
install.sh
@@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ $UID -eq 0 ]; then
|
||||
read -n 1 -p "Do you wish to install love-release system-wide ? [Y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]*|"" ) echo;;
|
||||
* ) echo -e "\nInstallation aborted."; exit;;
|
||||
esac
|
||||
|
||||
echo "Installing..."
|
||||
BINARY_DIR=/usr/bin
|
||||
INSTALL_DIR=/usr/share/love-release
|
||||
MANPAGE_DIR=/usr/share/man/man1
|
||||
COMPLETION_DIR=$(pkg-config --variable=completionsdir bash-completion)
|
||||
else
|
||||
read -n 1 -p "Do you wish to install love-release in your user directory ? [Y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]*|"" ) echo;;
|
||||
* ) echo -e "\nInstallation aborted."; exit;;
|
||||
esac
|
||||
|
||||
echo "Installing..."
|
||||
BINARY_DIR="$HOME"/bin
|
||||
INSTALL_DIR="$HOME"/.local/share/love-release
|
||||
MANPAGE_DIR="$HOME"/.local/share/man/man1
|
||||
COMPLETION_DIR="$HOME"/.bash_completion
|
||||
|
||||
echo "Add these lines to your shell rc file:"
|
||||
echo " export PATH=\"$BINARY_DIR:\$PATH\""
|
||||
echo " export MANPATH=\"$MANPAGE_DIR:\""
|
||||
fi
|
||||
|
||||
|
||||
SED_ARG=$(echo "$INSTALL_DIR" | sed -e 's/[\/&]/\\&/g')
|
||||
mkdir -p "$BINARY_DIR"
|
||||
sed -e "s/INSTALL_DIR=/INSTALL_DIR=$SED_ARG/g" love-release.sh > "$BINARY_DIR"/love-release
|
||||
chmod +x "$BINARY_DIR"/love-release
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cp ./README.md "$INSTALL_DIR"
|
||||
cp ./config.ini "$INSTALL_DIR"
|
||||
cp -r ./scripts "$INSTALL_DIR"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"/include
|
||||
_PWD=$PWD
|
||||
if [ -d "$INSTALL_DIR"/include/getopt ]; then
|
||||
cd "$INSTALL_DIR"/include/getopt
|
||||
git pull
|
||||
cd "$_PWD"
|
||||
else
|
||||
git clone https://gist.github.com/MisterDA/7284755 "$INSTALL_DIR"/include/getopt
|
||||
fi
|
||||
if [ -d "$INSTALL_DIR"/include/bash_ini_parser ]; then
|
||||
cd "$INSTALL_DIR"/include/bash_ini_parser
|
||||
git pull
|
||||
cd "$_PWD"
|
||||
else
|
||||
git clone https://github.com/rudimeier/bash_ini_parser "$INSTALL_DIR"/include/bash_ini_parser
|
||||
fi
|
||||
|
||||
mkdir -p "$MANPAGE_DIR"
|
||||
sed -e "s/scripts/$SED_ARG\/scripts/g" -e "s/config.ini/$SED_ARG\/config.ini/g" love-release.1 > "$MANPAGE_DIR"/love-release.1
|
||||
gzip -9 -f "$MANPAGE_DIR"/love-release.1
|
||||
|
||||
mkdir -p "$COMPLETION_DIR"
|
||||
cp ./completion.sh "$COMPLETION_DIR"/love-release
|
||||
|
||||
echo "Done !"
|
||||
|
@@ -13,10 +13,9 @@ The script fully supports Windows, MacOS either on x86 or x64,
|
||||
Debian and Android packages.
|
||||
It needs an Internet connection to download Love files,
|
||||
and relies on \fBcurl\fR, \fBzip\fR and \fBunzip\fR commands.
|
||||
To set the default Love version to use,
|
||||
you can edit the very beginning of the script.
|
||||
If \fBlua\fR and a \fIconf.lua\fR file are found,
|
||||
it will automatically detect which version your project uses.
|
||||
.SH CONFIGURATION
|
||||
You can install \fIlua\fR and add a \fIconf.lua\fR to your project to get automatic releases.
|
||||
See the \fIconf.lua\fR file included to see how configuration works.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-h
|
||||
@@ -178,11 +177,6 @@ Update the love-android-sdl2.git repository used in the cache.
|
||||
.B \-\-clean
|
||||
Clean the cache located in \fI~/.cache/love-release\fR.
|
||||
One can replace the Love files there.
|
||||
.TP
|
||||
.B \-\-config \fIfile\fR
|
||||
Pass a configuration file as argument.
|
||||
It describes which build you want to make, with what options.
|
||||
See \fIconfig.ini\fR.
|
||||
.SH MODULES
|
||||
The script is modular.
|
||||
Each different platform is handled by a subscript stored in \fIscripts\fR.
|
||||
|
555
love-release.sh
555
love-release.sh
@@ -1,74 +1,146 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
# Edit this if you want to use another Love version by default
|
||||
LOVE_VERSION=0.9.1
|
||||
|
||||
|
||||
# Platform-specific scripts registration
|
||||
|
||||
## To register your platforms scripts, you have to choose a command name that will trigger your script.
|
||||
## It must be followed by:
|
||||
## - a semicolon ";" if it doesn't require an argument
|
||||
## - a dot "." if it has an optional argument
|
||||
## - a colon ":" if it requires an argument
|
||||
|
||||
## Love file
|
||||
SCRIPT_ARGS="l;"
|
||||
|
||||
## Windows
|
||||
SCRIPT_ARGS="w. win-icon: win-package-version: win-maintainer-name: win-package-name: win-appid: win-installer; $SCRIPT_ARGS"
|
||||
|
||||
## Debian
|
||||
SCRIPT_ARGS="d; deb-icon: deb-package-version: deb-maintainer-name: maintainer-email: deb-package-name: $SCRIPT_ARGS"
|
||||
|
||||
## Android
|
||||
SCRIPT_ARGS="a; apk-icon: apk-activity: apk-package-version: apk-maintainer-name: apk-package-name: update-android; $SCRIPT_ARGS"
|
||||
|
||||
## Mac OS X
|
||||
SCRIPT_ARGS="m; osx-icon: osx-maintainer-name: $SCRIPT_ARGS"
|
||||
|
||||
|
||||
## List the options that require a file/directory that should be excluded by zip.
|
||||
EXCLUDE_OPTIONS=("win-icon" "osx-icon" "deb-icon" "apk-icon")
|
||||
EXCLUDE_CONFIG=("INI__windows__icon" "INI__macosx__icon" "INI__debian__icon" "INI__android__icon")
|
||||
|
||||
|
||||
## Add a short summary of your platform script here
|
||||
## SHORT_HELP=" -a Create an executable for a
|
||||
## --osname Create an executable for osname"
|
||||
SHORT_HELP=" -l Create a plain Love file
|
||||
-a Create an Android package
|
||||
-d Create a Debian package
|
||||
-m Create a Mac OS X application
|
||||
-w, Create a Windows application
|
||||
-w32 Create a Windows x86 application
|
||||
-w64 Create a Windows x64 application"
|
||||
|
||||
## Don't forget to source the corresponding file at the bottom of the script !
|
||||
# LÖVE version
|
||||
LOVE_DEF_VERSION=0.9.2
|
||||
|
||||
|
||||
|
||||
# Test if requirements are installed
|
||||
command -v curl >/dev/null 2>&1 || { echo "curl is not installed. Aborting." >&2; exit 1; }
|
||||
command -v zip >/dev/null 2>&1 || { echo "zip is not installed. Aborting." >&2; exit 1; }
|
||||
command -v unzip >/dev/null 2>&1 || { echo "unzip is not installed. Aborting." >&2; exit 1; }
|
||||
FOUND_LUA=true
|
||||
command -v lua >/dev/null 2>&1 || { FOUND_LUA=false; }
|
||||
# Helper functions
|
||||
|
||||
|
||||
# Tests on float numbers
|
||||
float_test () {
|
||||
a=$(echo | awk 'END { exit ( !( '"$1"')); }' && echo "true")
|
||||
if [ "$a" != "true" ]; then
|
||||
a=false
|
||||
# Dependencies check
|
||||
check_deps ()
|
||||
{
|
||||
command -v curl > /dev/null 2>&1 || {
|
||||
echo "curl is not installed. Aborting."
|
||||
local EXIT=true
|
||||
}
|
||||
command -v zip > /dev/null 2>&1 || {
|
||||
echo "zip is not installed. Aborting."
|
||||
local EXIT=true
|
||||
}
|
||||
command -v unzip > /dev/null 2>&1 || {
|
||||
echo "unzip is not installed. Aborting."
|
||||
local EXIT=true
|
||||
}
|
||||
command -v lua > /dev/null 2>&1 || {
|
||||
echo "lua is not installed. Install it to ease your releases."
|
||||
} && {
|
||||
LUA=true
|
||||
}
|
||||
if [[ $EXIT == true ]]; then
|
||||
exit 1
|
||||
fi
|
||||
echo $a
|
||||
}
|
||||
|
||||
# Reset script variables
|
||||
reset_vars () {
|
||||
TITLE="$(basename $(pwd))"
|
||||
RELEASE_DIR=releases
|
||||
CACHE_DIR=~/.cache/love-release
|
||||
}
|
||||
|
||||
# Get user confirmation, simple Yes/No question
|
||||
## $1: message, usually just a question
|
||||
## $2: default choice, 0 - no; 1 - yes, default - yes
|
||||
## return: true - yes
|
||||
get_user_confirmation () {
|
||||
if [[ $2 == "0" ]]; then
|
||||
read -n 1 -p "$1 [y/N]: " yn
|
||||
local default=false
|
||||
else
|
||||
read -n 1 -p "$1 [Y/n]: " yn
|
||||
local default=true
|
||||
fi
|
||||
case $yn in
|
||||
[Yy]* )
|
||||
echo "true"; echo >> "$(tty)";;
|
||||
[Nn]* )
|
||||
echo "false"; echo >> "$(tty)";;
|
||||
"" )
|
||||
echo "$default";;
|
||||
* )
|
||||
echo "$default"; echo >> "$(tty)";;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Generate LÖVE version variables
|
||||
## $1: LÖVE version string
|
||||
gen_version () {
|
||||
if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||
LOVE_VERSION=$1
|
||||
LOVE_VERSION_MAJOR=${BASH_REMATCH[1]}
|
||||
LOVE_VERSION_MINOR=${BASH_REMATCH[2]}
|
||||
LOVE_VERSION_REVISION=${BASH_REMATCH[3]}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Compare two LÖVE versions
|
||||
## $1: First LÖVE version
|
||||
## $2: comparison operator
|
||||
## "ge", "le", "gt" "lt"
|
||||
## ">=", "<=", ">", "<"
|
||||
## $3: Second LÖVE version
|
||||
## return: "true" or "false"
|
||||
compare_version () {
|
||||
if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||
local v1_maj=${BASH_REMATCH[1]}
|
||||
local v1_min=${BASH_REMATCH[2]}
|
||||
local v1_rev=${BASH_REMATCH[3]}
|
||||
else
|
||||
echo "false"
|
||||
return
|
||||
fi
|
||||
if [[ $2 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||
local v2_maj=${BASH_REMATCH[1]}
|
||||
local v2_min=${BASH_REMATCH[2]}
|
||||
local v2_rev=${BASH_REMATCH[3]}
|
||||
else
|
||||
echo "false"
|
||||
return
|
||||
fi
|
||||
|
||||
case $2 in
|
||||
ge|\>= )
|
||||
if (( $v1_maj >= $v2_maj && $v1_min >= $v2_min && $v1_rev >= $v2_rev )); then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
;;
|
||||
le|\<= )
|
||||
if (( $v1_maj <= $v2_maj && $v1_min <= $v2_min && $v1_rev <= $v2_rev )); then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
;;
|
||||
gt|\> )
|
||||
if (( $v1_maj > $v2_maj || ( $v1_max == $v2_max && $v1_min > $v2_min ) ||
|
||||
( $v1_max == $v2_max && $v1_min == $v2_min && $v1_rev > $v2_rev ) )); then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
;;
|
||||
lt|\< )
|
||||
if (( $v1_maj > $v2_maj || ( $v1_max == $v2_max && $v1_min > $v2_min ) ||
|
||||
( $v1_max == $v2_max && $v1_min == $v2_min && $v1_rev > $v2_rev ) )); then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Escape directory name for zip
|
||||
## $1: directory path
|
||||
## return: escaped directory path
|
||||
dir_escape () {
|
||||
dir="$1"
|
||||
local dir="$1"
|
||||
if [ -d "$dir" ]; then
|
||||
if [ "${dir::1}" != "/" ]; then
|
||||
dir="/$dir"
|
||||
@@ -84,212 +156,131 @@ dir_escape () {
|
||||
echo "$dir"
|
||||
}
|
||||
|
||||
# Get user confirmation, simple Yes/No question
|
||||
# $1: message, usually just a question
|
||||
# $2: default choice, 0 - no; 1 - yes, default - yes
|
||||
# return: true - yes, false - no
|
||||
get_user_confirmation () {
|
||||
if [ "$2" = "0" ]; then
|
||||
read -n 1 -p "$1 [y/N]: " yn
|
||||
default=false
|
||||
|
||||
# Read configuration
|
||||
## $1: system name
|
||||
read_config () {
|
||||
if [[ $LUA == true ]] && [[ -f "conf.lua" ]]; then
|
||||
local var=$(lua - <<EOF
|
||||
f = loadfile("conf.lua")
|
||||
t, love = {window = {}, modules = {}, screen = {}}, {}
|
||||
f()
|
||||
love.conf(t)
|
||||
|
||||
-- "love", "windows", "osx", "debian" or "android"
|
||||
os = "$OS"
|
||||
|
||||
fields = {
|
||||
"identity", "version", "game_version", "icon", "exclude",
|
||||
"title", "author", "email", "url", "description", }
|
||||
|
||||
for _, f in ipairs(fields) do
|
||||
t[f] = t[f] or ""
|
||||
end
|
||||
|
||||
for i in ipairs(t.os) do
|
||||
t.os[os] = {}
|
||||
end
|
||||
|
||||
if not t.os or #t.os == 0 then t.os.love = {} end
|
||||
|
||||
if t.os[os] then
|
||||
print(os:upper()..'=true')
|
||||
for _, f in ipairs(fields) do
|
||||
t.os[os][f] = t.os[os][f] or t[f]
|
||||
if type(t.os[os][f]) == "table" then
|
||||
str = f:upper()..'=('
|
||||
for _, v in ipairs(t.os[os][f]) do
|
||||
str = str..' "'..v..'"'
|
||||
end
|
||||
str = str..' )'
|
||||
print(str)
|
||||
else
|
||||
read -n 1 -p "$1 [Y/n]: " yn
|
||||
default=true
|
||||
print(f:upper()..'="'..t.os[os][f]..'"')
|
||||
end
|
||||
end
|
||||
else
|
||||
print(os:upper()..'=false')
|
||||
end
|
||||
|
||||
if os == "windows" then
|
||||
t.os.windows.x86 = t.os.windows.x86 or true
|
||||
t.os.windows.x64 = t.os.windows.x64 or true
|
||||
t.os.windows.installer = t.os.windows.installer or false
|
||||
t.os.windows.appid = t.os.windows.appid or ""
|
||||
print("X86="..tostring(t.os.windows.x86))
|
||||
print("X64="..tostring(t.os.windows.x64))
|
||||
print("INSTALLER="..tostring(t.os.windows.installer))
|
||||
print("APPID="..t.os.windows.appid)
|
||||
end
|
||||
EOF
|
||||
)
|
||||
eval "$var"
|
||||
if [[ $(compare_version "$LOVE_VERSION" ">" "$VERSION") == true ]]; then
|
||||
if [[ $(get_user_confirmation "LÖVE $LOVE_VERSION is out ! Your project uses LÖVE $VERSION. Continue ?") == false ]]; then
|
||||
exit
|
||||
fi
|
||||
gen_version $VERSION
|
||||
unset VERSION
|
||||
fi
|
||||
fi
|
||||
case $yn in
|
||||
[Yy]* )
|
||||
echo "true"; echo >> "$(tty)";;
|
||||
[Nn]* )
|
||||
echo "false"; echo >> "$(tty)";;
|
||||
"" )
|
||||
echo "$default";;
|
||||
* )
|
||||
echo "$default"; echo >> "$(tty)";;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Love version detection
|
||||
if [ "$FOUND_LUA" = true ] && [ -f "conf.lua" ]; then
|
||||
LOVE_VERSION_AUTO=$(lua -e 'f = loadfile("conf.lua"); t, love = {window = {}, modules = {}}, {}; f(); love.conf(t); t.version = t.version or ""; print(t.version)')
|
||||
else
|
||||
LOVE_VERSION_AUTO=$(grep -Eo -m 1 't.version = "[0-9]+.[0-9]+.[0-9]+"' conf.lua 2> /dev/null | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
|
||||
fi
|
||||
if [ -n "$LOVE_VERSION_AUTO" ]; then
|
||||
LOVE_VERSION=$LOVE_VERSION_AUTO
|
||||
fi
|
||||
LOVE_VERSION_MAJOR=$(echo "$LOVE_VERSION" | grep -Eo '^[0-9]+\.?[0-9]*')
|
||||
LOVE_GT_080=$(float_test "$LOVE_VERSION_MAJOR >= 0.8")
|
||||
LOVE_GT_090=$(float_test "$LOVE_VERSION_MAJOR >= 0.9")
|
||||
|
||||
|
||||
# Global variables
|
||||
ARGS=( "$@" )
|
||||
SCRIPT_ARGS="$SCRIPT_ARGS h; n: r: v: x: config: homepage: description: clean help"
|
||||
SCRIPT_ARGS=$(printf '%s\n' $SCRIPT_ARGS | sort -u)
|
||||
CONFIG=false
|
||||
CONFIG_FILE=config.ini
|
||||
|
||||
PROJECT_FILES=
|
||||
MAIN_EXCLUDE_FILES=
|
||||
|
||||
PROJECT_NAME="${PWD##/*/}"
|
||||
PROJECT_DIR="$PWD"
|
||||
|
||||
RELEASE_DIR="$PWD"/releases
|
||||
MAIN_CACHE_DIR=~/.cache/love-release
|
||||
INSTALL_DIR=
|
||||
PLATFORMS_DIR="$INSTALL_DIR"/scripts
|
||||
INCLUDE_DIR="$INSTALL_DIR"/include
|
||||
|
||||
if [ -n "$SHORT_HELP" ] && [ "${SHORT_HELP:$((${#SHORT_HELP}-1)):1}" != $'\n' ]; then
|
||||
SHORT_HELP="$SHORT_HELP
|
||||
"
|
||||
fi
|
||||
SHORT_HELP="Usage: love-release.sh [options...] [files...]
|
||||
Options:
|
||||
-h, --help Prints short or long help
|
||||
-n Set the projects name
|
||||
-r Set the release directory
|
||||
-v Set the Love version
|
||||
$SHORT_HELP"
|
||||
|
||||
|
||||
# Read config
|
||||
missing_operands=true
|
||||
source "$INCLUDE_DIR"/getopt/getopt.sh
|
||||
while getoptex "$SCRIPT_ARGS" "$@"
|
||||
do
|
||||
if [ "$OPTOPT" = "config" ]; then
|
||||
source "$INCLUDE_DIR"/bash_ini_parser/read_ini.sh
|
||||
missing_operands=false
|
||||
CONFIG_FILE=$OPTARG
|
||||
read_ini "$CONFIG_FILE" || exit 1
|
||||
CONFIG=true
|
||||
SED_ARG=$(echo "$PLATFORMS_DIR" | sed -e 's/[\/&]/\\&/g')
|
||||
PLATFORM_SCRIPTS=$(echo "${INI__ALL_SECTIONS}" | sed -r -e 's/[ ]*global[ ]*//g' -e "s/\<[^ ]+\>/$SED_ARG\/&.sh/g")
|
||||
IFS=" " read -a PLATFORM_SCRIPTS <<< "$PLATFORM_SCRIPTS"
|
||||
if [ -n "${INI__global__release_dir}" ]; then
|
||||
RELEASE_DIR=${INI__global__release_dir}
|
||||
fi
|
||||
if [ -n "${INI__global__love_version}" ]; then
|
||||
LOVE_VERSION=${INI__global__love_version}
|
||||
LOVE_VERSION_MAJOR=$(echo "$LOVE_VERSION" | grep -Eo '^[0-9]+\.?[0-9]*')
|
||||
LOVE_GT_080=$(float_test "$LOVE_VERSION_MAJOR >= 0.8")
|
||||
LOVE_GT_090=$(float_test "$LOVE_VERSION_MAJOR >= 0.9")
|
||||
fi
|
||||
if [ -n "${INI__global__project_name}" ]; then
|
||||
PROJECT_NAME=${INI__global__project_name}
|
||||
fi
|
||||
if [ -n "${INI__global__homepage}" ]; then
|
||||
PROJECT_HOMEPAGE=${INI__global__homepage}
|
||||
fi
|
||||
if [ -n "${INI__global__description}" ]; then
|
||||
PROJECT_DESCRIPTION=${INI__global__description}
|
||||
fi
|
||||
for option in "${EXCLUDE_CONFIG[@]}"
|
||||
do
|
||||
MAIN_EXCLUDE_FILES=$(dir_escape "${!option}") $MAIN_EXCLUDE_FILES
|
||||
done
|
||||
fi
|
||||
done
|
||||
unset OPTIND
|
||||
unset OPTOFS
|
||||
|
||||
|
||||
# Parsing options
|
||||
while getoptex "$SCRIPT_ARGS" "$@"
|
||||
do
|
||||
if [ "$OPTOPT" = "h" ]; then
|
||||
echo "$SHORT_HELP"
|
||||
exit
|
||||
elif [ "$OPTOPT" = "help" ]; then
|
||||
man love-release
|
||||
exit
|
||||
elif [ "$OPTOPT" = "n" ]; then
|
||||
PROJECT_NAME=$OPTARG
|
||||
elif [ "$OPTOPT" = "r" ]; then
|
||||
RELEASE_DIR=$OPTARG
|
||||
elif [ "$OPTOPT" = "v" ]; then
|
||||
LOVE_VERSION=$OPTARG
|
||||
LOVE_VERSION_MAJOR=$(echo "$LOVE_VERSION" | grep -Eo '^[0-9]+\.?[0-9]*')
|
||||
LOVE_GT_080=$(float_test "$LOVE_VERSION_MAJOR >= 0.8")
|
||||
LOVE_GT_090=$(float_test "$LOVE_VERSION_MAJOR >= 0.9")
|
||||
elif [ "$OPTOPT" = "x" ]; then
|
||||
MAIN_EXCLUDE_FILES="$(dir_escape "$OPTARG") $MAIN_EXCLUDE_FILES"
|
||||
elif [ "$OPTOPT" = "homepage" ]; then
|
||||
PROJECT_HOMEPAGE=$OPTARG
|
||||
elif [ "$OPTOPT" = "description" ]; then
|
||||
PROJECT_DESCRIPTION=$OPTARG
|
||||
elif [ "$OPTOPT" = "clean" ]; then
|
||||
missing_operands=false
|
||||
rm -rf "$MAIN_CACHE_DIR"
|
||||
fi
|
||||
for option in "${EXCLUDE_OPTIONS[@]}"
|
||||
do
|
||||
if [ "$OPTOPT" = "$option" ]; then
|
||||
MAIN_EXCLUDE_FILES=$(dir_escape "$OPTARG") $MAIN_EXCLUDE_FILES
|
||||
fi
|
||||
done
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
for file in "$@"
|
||||
do
|
||||
PROJECT_FILES="$PROJECT_FILES $file"
|
||||
done
|
||||
|
||||
set -- "${ARGS[@]}"
|
||||
unset OPTIND
|
||||
unset OPTOFS
|
||||
dump_var () {
|
||||
echo "LOVE_VERSION=$LOVE_VERSION"
|
||||
echo "LOVE_DEF_VERSION=$LOVE_DEF_VERSION"
|
||||
echo "LOVE_WEB_VERSION=$LOVE_WEB_VERSION"
|
||||
echo
|
||||
echo "IDENTITY=$IDENTITY"
|
||||
echo "GAME_VERSION=$GAME_VERSION"
|
||||
echo "ICON=$ICON"
|
||||
echo
|
||||
echo "TITLE=$TITLE"
|
||||
echo "AUTHOR=$AUTHOR"
|
||||
echo "EMAIL=$EMAIL"
|
||||
echo "URL=$URL"
|
||||
echo "DESCRIPTION=$DESCRIPTION"
|
||||
}
|
||||
|
||||
|
||||
# Modules functions
|
||||
## $1: Module name
|
||||
init_module ()
|
||||
## return: true if module should be executed
|
||||
execute_module ()
|
||||
{
|
||||
GLOBAL_OPTIND=$OPTIND
|
||||
GLOBAL_OPTOFS=$OPTOFS
|
||||
unset OPTIND
|
||||
unset OPTOFS
|
||||
EXCLUDE_FILES=$MAIN_EXCLUDE_FILES
|
||||
if [ -z "$MAIN_RELEASE_DIR" ]; then
|
||||
MAIN_RELEASE_DIR=$(cd "$(dirname "$RELEASE_DIR")" && pwd)/$(basename "$RELEASE_DIR")
|
||||
RELEASE_DIR="$MAIN_RELEASE_DIR"/$LOVE_VERSION
|
||||
fi
|
||||
missing_operands=false
|
||||
CACHE_DIR="$MAIN_CACHE_DIR"/$LOVE_VERSION
|
||||
mkdir -p "$RELEASE_DIR" "$CACHE_DIR"
|
||||
rm -rf "$RELEASE_DIR"/"$PROJECT_NAME".love 2> /dev/null
|
||||
echo "Generating $PROJECT_NAME with Love $LOVE_VERSION for $1..."
|
||||
local module="$1"
|
||||
read_config "$module"
|
||||
module=${module^^}
|
||||
echo "${!module}"
|
||||
}
|
||||
|
||||
# Init module
|
||||
init_module ()
|
||||
{
|
||||
reset_vars
|
||||
mkdir -p "$RELEASE_DIR"
|
||||
mkdir -p "$CACHE_DIR"/"$LOVE_VERSION"
|
||||
echo "Generating $TITLE with Love $LOVE_VERSION for ${MODULE}..."
|
||||
}
|
||||
|
||||
# Create the LÖVE file
|
||||
## $1: Compression level 0-9
|
||||
create_love_file ()
|
||||
{
|
||||
cd "$PROJECT_DIR"
|
||||
rm -rf "$RELEASE_DIR"/"$PROJECT_NAME".love 2> /dev/null
|
||||
if [ -z "$PROJECT_FILES" ]; then
|
||||
zip --filesync -$1 -r "$RELEASE_DIR"/"$PROJECT_NAME".love \
|
||||
-x "$0" "${MAIN_RELEASE_DIR#$PWD/}/*" "$CONFIG_FILE" $MAIN_EXCLUDE_FILES $EXCLUDE_FILES \
|
||||
LOVE_FILE="$RELEASE_DIR"/"$TITLE".love
|
||||
zip -FS -$1 -r "$LOVE_FILE" \
|
||||
-x "$0" "${RELEASE_DIR#$PWD/}/*" \
|
||||
$(ls -Ap | grep "^\." | sed -e 's/^/\//g' -e 's/\/$/\/*/g') @ \
|
||||
.
|
||||
else
|
||||
zip --filesync -$1 -r "$RELEASE_DIR"/"$PROJECT_NAME".love \
|
||||
-x "$0" "${MAIN_RELEASE_DIR#$PWD/}/*" "$CONFIG_FILE" $MAIN_EXCLUDE_FILES $EXCLUDE_FILES \
|
||||
$(ls -Ap | grep "^\." | sed -e 's/^/\//g' -e 's/\/$/\/*/g') @ \
|
||||
$PROJECT_FILES
|
||||
fi
|
||||
cd "$RELEASE_DIR"
|
||||
LOVE_FILE="$PROJECT_NAME".love
|
||||
}
|
||||
|
||||
## $1: exit code. 0 - success, other - failure
|
||||
# Exit module
|
||||
## $1: exit code.
|
||||
## 0 - success, other - failure
|
||||
## $2: error message
|
||||
exit_module ()
|
||||
{
|
||||
if [ -z "$1" ] || [ "$1" = "0" ]; then
|
||||
OPTIND=$GLOBAL_OPTIND
|
||||
OPTOFS=$GLOBAL_OPTOFS
|
||||
if [[ -z $1 || "$1" == "0" ]]; then
|
||||
echo "Done !"
|
||||
else
|
||||
echo -e "$2"
|
||||
@@ -297,58 +288,34 @@ exit_module ()
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$CONFIG" = true ]; then
|
||||
for script in "${PLATFORM_SCRIPTS[@]}"
|
||||
do
|
||||
source "$script"
|
||||
done
|
||||
exit
|
||||
|
||||
|
||||
# Main
|
||||
|
||||
check_deps
|
||||
|
||||
# Get latest LÖVE version number
|
||||
gen_version $LOVE_DEF_VERSION
|
||||
LOVE_WEB_VERSION=$(curl -s https://love2d.org/releases.xml | grep -m 2 "<title>" | tail -n 1 | grep -Eo "[0-9]+.[0-9]+.[0-9]+")
|
||||
gen_version $LOVE_WEB_VERSION
|
||||
|
||||
INSTALLED=false
|
||||
EMBEDDED=false
|
||||
|
||||
if [[ $INSTALLED == false && $EMBEDDED == false ]]; then
|
||||
>&2 echo "love-release has not been installed, and is not embedded into one script. Consider doing one of the two."
|
||||
INSTALLED=true
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Platform-specific scripts registration
|
||||
## To register your platforms scripts, test for the option you've specified
|
||||
## at the beginning of the script and source the corresponding file.
|
||||
## $OPTOPT holds the option and $OPTARG holds the eventual argument passed to it.
|
||||
|
||||
## while getoptex "a; osname:" "$@"
|
||||
while getoptex "$SCRIPT_ARGS" "$@"
|
||||
do
|
||||
:
|
||||
## if [ "$OPTOPT" = "a" ]; then
|
||||
## source "$PLATFORMS_DIR/a-system.sh"
|
||||
## elif [ "$OPTOPT" = "osname" ]; then
|
||||
## OSNAME=$OPTARG
|
||||
## source "$PLATFORMS_DIR/os.sh"
|
||||
## fi
|
||||
if [ "$OPTOPT" = "l" ]; then
|
||||
source "$PLATFORMS_DIR"/love.sh
|
||||
elif [ "$OPTOPT" = "a" ]; then
|
||||
source "$PLATFORMS_DIR"/android.sh
|
||||
elif [ "$OPTOPT" = "d" ]; then
|
||||
source "$PLATFORMS_DIR"/debian.sh
|
||||
elif [ "$OPTOPT" = "m" ]; then
|
||||
source "$PLATFORMS_DIR"/macosx.sh
|
||||
elif [ "$OPTOPT" = "w" ]; then
|
||||
if [ "$OPTARG" = "32" ]; then
|
||||
RELEASE_WIN_32=true
|
||||
elif [ "$OPTARG" = "64" ]; then
|
||||
RELEASE_WIN_64=true
|
||||
else
|
||||
RELEASE_WIN_32=true
|
||||
RELEASE_WIN_64=true
|
||||
fi
|
||||
source "$PLATFORMS_DIR"/windows.sh
|
||||
if [[ $EMBEDDED == true ]]; then
|
||||
: # include_scripts_here
|
||||
elif [[ $INSTALLED == true ]]; then
|
||||
SCRIPTS_DIR="scripts"
|
||||
for file in "$SCRIPTS_DIR"/*.sh; do
|
||||
MODULE="$(basename -s '.sh' "$file")"
|
||||
if [[ $(execute_module "$1") == true ]]; then
|
||||
source "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Missing operands
|
||||
if [ "$missing_operands" = true ]; then
|
||||
>&2 echo "./love-release.sh: missing operands.
|
||||
love-release.sh [-adlmw] [-n project_name] [-r release_dir] [-v love_version] [FILES...]
|
||||
Try 'love-release.sh --help' for more information."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user