Bug fixes

- dot files are now properly excluded when zipping
- add PROJECT_DIR variable
- add new deps exit in module_exit
- an optional error message can be passed to module_exit
- escaped characters will now be interpreted in error messages
- fix in compare_version
This commit is contained in:
Antonin Décimo
2015-06-24 15:58:43 +02:00
parent 1d6443044f
commit ba6537c7ae

View File

@@ -41,7 +41,7 @@ check_deps () {
LUA=true LUA=true
} }
if [[ $EXIT == true ]]; then if [[ $EXIT == true ]]; then
exit 1 exit_module "deps"
fi fi
} }
@@ -100,7 +100,7 @@ compare_version () {
else else
return 1 return 1
fi fi
if [[ $2 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then if [[ $3 =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
local v2_maj=${BASH_REMATCH[1]} local v2_maj=${BASH_REMATCH[1]}
local v2_min=${BASH_REMATCH[2]} local v2_min=${BASH_REMATCH[2]}
local v2_rev=${BASH_REMATCH[3]} local v2_rev=${BASH_REMATCH[3]}
@@ -238,7 +238,7 @@ read_options () {
while true; do while true; do
case "$1" in case "$1" in
-a|--${pre}author ) AUTHOR="$2"; shift 2 ;; -a|--${pre}author ) AUTHOR="$2"; shift 2 ;;
--clean ) rm -rf "$CACHE_DIR"; shift ;; --${pre}clean ) rm -rf "$CACHE_DIR"; shift ;;
-d|--${pre}description ) DESCRIPTION="$2"; shift 2 ;; -d|--${pre}description ) DESCRIPTION="$2"; shift 2 ;;
-e|--${pre}email ) EMAIL="$2"; shift 2 ;; -e|--${pre}email ) EMAIL="$2"; shift 2 ;;
-h|--${pre}help ) short_help; exit 0 ;; -h|--${pre}help ) short_help; exit 0 ;;
@@ -336,6 +336,7 @@ init_module () {
MODULE="$1" MODULE="$1"
CACHE_DIR="$CACHE_DIR/$2" CACHE_DIR="$CACHE_DIR/$2"
read_options "$3" read_options "$3"
LOVE_FILE="${TITLE}.love"
mkdir -p "$RELEASE_DIR" "$CACHE_DIR" mkdir -p "$RELEASE_DIR" "$CACHE_DIR"
echo "Generating $TITLE with LÖVE $LOVE_VERSION for ${MODULE}..." echo "Generating $TITLE with LÖVE $LOVE_VERSION for ${MODULE}..."
return 0 return 0
@@ -344,21 +345,28 @@ init_module () {
# Create the LÖVE file # Create the LÖVE file
## $1: Compression level 0-9 ## $1: Compression level 0-9
create_love_file () { create_love_file () {
LOVE_FILE="$RELEASE_DIR"/"$TITLE".love local dotfiles=()
zip -FS -$1 -r "$LOVE_FILE" \ for file in .*; do
-x "$0" "${RELEASE_DIR#$PWD/}/*" \ if [[ $file == '.' || $file == '..' ]]; then continue; fi
$(ls -Ap | grep "^\." | sed -e 's/^/\//g' -e 's/\/$/\/*/g') @ \ if [[ -d $file ]]; then file="$file/*"; fi
dotfiles+=( "$file" )
done
zip -FS -$1 -r "$RELEASE_DIR/$LOVE_FILE" \
-x "$0" "${RELEASE_DIR#$PWD/}/*" "${dotfiles[@]}" @ \
"${FILES[@]}" "${FILES[@]}"
} }
# Exit module # Exit module
## $1: optional error identifier ## $1: optional error identifier
## $2: optional error message, printed if $1=="undef" or unidentified error ## $2: optional error message
exit_module () { exit_module () {
if [[ -z $1 ]]; then if [[ -z $1 ]]; then
echo "Done !" echo "Done !"
exit 0 exit 0
fi fi
if [[ -n $2 ]]; then
>&2 echo -e "$2"
fi
case $1 in case $1 in
execute ) execute )
exit 2 ;; exit 2 ;;
@@ -370,10 +378,9 @@ exit_module () {
version ) version )
>&2 echo "LÖVE version string is invalid." >&2 echo "LÖVE version string is invalid."
exit 5 ;; exit 5 ;;
deps )
exit 6 ;;
undef|* ) undef|* )
if [[ -n $2 ]]; then
>&2 echo "$2"
fi
exit 1 ;; exit 1 ;;
esac esac
} }
@@ -395,6 +402,7 @@ EMBEDDED=false
DEFAULT_MODULE=true DEFAULT_MODULE=true
TITLE="$(basename $(pwd))" TITLE="$(basename $(pwd))"
PROJECT_DIR="$PWD"
RELEASE_DIR=releases RELEASE_DIR=releases
CACHE_DIR=~/.cache/love-release CACHE_DIR=~/.cache/love-release
FILES=() FILES=()