|
| 1 | +#!/bin/sh |
| 2 | +echo "***************************************************************" |
| 3 | +echo "*" |
| 4 | +echo "* OpenTTD \"Bulgarian Town Names\"" |
| 5 | +echo "* Copyright (c) 2017 Rusi Dimitrov" |
| 6 | +echo "* This program comes with ABSOLUTELY NO WARRANTY." |
| 7 | +echo "* This is free software, and you are welcome to redistribute it" |
| 8 | +echo "* under certain conditions of GPL v3 license." |
| 9 | +echo "*" |
| 10 | +echo "***************************************************************" |
| 11 | + |
| 12 | +# Set variables |
| 13 | +NMLC=$(which nmlc) |
| 14 | +TAR=$(which tar) |
| 15 | +SRC="$PWD/src" |
| 16 | +cp $SRC/custom_tags-base.txt $SRC/custom_tags.txt |
| 17 | +VERSION=$(grep VERSION "${SRC}/custom_tags.txt" | cut -d':' -f2) |
| 18 | +NAME="bg_names" |
| 19 | +BUILD="Bulgarian_Town_Names-${VERSION}" |
| 20 | +RELEASE="$PWD/build/${BUILD}" |
| 21 | + |
| 22 | +# Preliminary checks |
| 23 | +if [ -z ${NMLC} ]; then |
| 24 | + echo "ERROR: NML not found!" |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if [ -z ${VERSION} ]; then |
| 29 | + echo "ERROR: Failed to get version!" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +# Create folder |
| 34 | +echo "\n *** Creating folder: /build/${BUILD}\n" |
| 35 | +mkdir -p "${RELEASE}" |
| 36 | + |
| 37 | +# Building |
| 38 | +echo "\n *** Building from the source, please wait...\n" |
| 39 | +${NMLC} --grf="${RELEASE}/${NAME}.grf" \ |
| 40 | + --custom-tags="${SRC}/custom_tags.txt" \ |
| 41 | + --lang-dir="${SRC}/lang" \ |
| 42 | + "${SRC}/${NAME}.nml" \ |
| 43 | + --verbosity=4 |
| 44 | + |
| 45 | +# If failed, then clean up and exit |
| 46 | +if [ $? -eq 1 ]; then |
| 47 | + echo "\n*********************** Building failed ***********************\n" |
| 48 | + rm -R "${RELEASE}" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | + |
| 52 | +# Copy files |
| 53 | +cp $PWD/docs/*.txt ${RELEASE} |
| 54 | +cp $PWD/LICENSE ${RELEASE}/license.txt |
| 55 | + |
| 56 | +# Create TAR |
| 57 | +echo "\n *** Creating archive: ${RELEASE}.tar\n" |
| 58 | +cd "$PWD/build/" |
| 59 | +${TAR} -cf "${RELEASE}.tar" "${BUILD}" |
| 60 | + |
| 61 | +# Clean up files and dirs |
| 62 | +cd - > /dev/null |
| 63 | +rm -R "${RELEASE}" "$PWD/.nmlcache" "$SRC/custom_tags.txt" |
| 64 | + |
| 65 | +# Finish |
| 66 | +echo "\n********************** Building finished **********************\n" |
| 67 | +echo "To install copy the NewGRF archive to the OpenTTD NewGRF directory:" |
| 68 | +echo " \$ cp ${RELEASE}.tar ~/.openttd/newgrf/\n" |
| 69 | +exit 0 |
0 commit comments