fix typo & improve path safety (space in path should now be allowed)

This commit is contained in:
OMGeeky
2024-06-16 17:17:07 +02:00
parent a00b8fbc66
commit ae3ca5d50a

View File

@@ -8,7 +8,7 @@ else
fi
#read the folder this script should be in (should be the packaging folder inside the ATCS source)
PACKAGING_DIR=$(dirname $(readlink -f "$0" || greadlink -f "$0" || stat -f "$0"))
PACKAGING_DIR=$(dirname "$(readlink -f "$0" || greadlink -f "$0" || stat -f "$0")")
ATCS_SOURCE_DIR=$(dirname "${PACKAGING_DIR}")
TEMP_DIR=${PACKAGING_DIR}/tmp
echo "Packaging dir: ${PACKAGING_DIR}"
@@ -19,63 +19,63 @@ MANIFEST_LOCATION=${PACKAGING_DIR}/Manifest.txt
echo ""
echo "Getting version"
VERSION=$(cat ${PACKAGING_DIR}/ATCS_latest)
VERSION=$(cat "${PACKAGING_DIR}"/ATCS_latest)
echo "Got version ${VERSION}"
echo "Removing tmp folder"
rm -rf ${PACKAGING_DIR}/tmp/
rm -rf "${PACKAGING_DIR}"/tmp/
echo "recreating tmp folder"
mkdir ${PACKAGING_DIR}/tmp/
mkdir "${PACKAGING_DIR}"/tmp/
#ATCS_SOURCE_DIR="${PACKAGING_DIR}/.."
echo ""
#copy manifest to temp folder for editing
cp ${MANIFEST_LOCATION} ${TEMP_DIR}
cp "${MANIFEST_LOCATION}" "${TEMP_DIR}"
MANIFEST_LOCATION=${TEMP_DIR}/Manifest.txt
#copy lib files to packaged folder?
echo 'copying lib files'
mkdir -p ${PACKAGING_DIR}/common/lib/
cp ${ATCS_SOURCE_DIR}/lib/* ${PACKAGING_DIR}/common/lib/
mkdir -p "${PACKAGING_DIR}"/common/lib/
cp "${ATCS_SOURCE_DIR}"/lib/* "${PACKAGING_DIR}"/common/lib/
cd $ATCS_SOURCE_DIR
cd "$ATCS_SOURCE_DIR" || exit
#set ClassPath variable to use in the building etc.
echo 'setting class path'
#linux needs a : as seperator while windows needs ;
#linux needs a : as separator while windows needs ;
if [ "$LINUX" = true ] ; then
CP="lib/*:src:hacked-libtiled:siphash-zackehh/src/main/java"
else
CP="lib/*;src;hacked-libtiled;siphash-zackehh/src/main/java"
fi
echo "ClassPath: "
echo ${CP}
echo "${CP}"
echo ""
#set build the classes
echo 'building java classes'
#javac -cp $CP *.java
javac -cp $CP ${ATCS_SOURCE_DIR}/src/com/gpl/rpg/atcontentstudio/*.java -d ${TEMP_DIR}
echo javac -cp $CP ${ATCS_SOURCE_DIR}/src/com/gpl/rpg/atcontentstudio/*.java -d ${TEMP_DIR}
javac -cp "$CP" "${ATCS_SOURCE_DIR}"/src/com/gpl/rpg/atcontentstudio/*.java -d "${TEMP_DIR}"
echo javac -cp "$CP" "${ATCS_SOURCE_DIR}"/src/com/gpl/rpg/atcontentstudio/*.java -d "${TEMP_DIR}"
echo ""
LIB_PATHS=$(find lib -name '*.jar' | paste -sd' ')
echo "LIB_PATHS: ${LIB_PATHS}"
# add all lib files to the class path in the temp Manifest
echo "Class-Path: . lib/* ${LIB_PATHS}" >>${MANIFEST_LOCATION}
echo "Class-Path: . lib/* ${LIB_PATHS}" >>"${MANIFEST_LOCATION}"
echo ""
echo "creating jar at location: ${JAR_LOCATION}"
# create the jar file
# the command with those parameters requires this format:
# jar vmfc <Manifest file> <Jar file (target location)> <all things to add to the jar file>
# jar mfc <Manifest file> <Jar file (target location)> <all things to add to the jar file>
# the things to add always use the whole relative path from the current dir,
# so when that is not wanted, the -C <location> thing will change to that dir
jar mfc ${MANIFEST_LOCATION} ${JAR_LOCATION} -C ${PACKAGING_DIR}/tmp/ com/gpl/rpg/atcontentstudio/ -C res . -C ${ATCS_SOURCE_DIR}/src .
jar mfc "${MANIFEST_LOCATION}" "${JAR_LOCATION}" -C "${PACKAGING_DIR}"/tmp/ com/gpl/rpg/atcontentstudio/ -C res . -C "${ATCS_SOURCE_DIR}"/src .
echo ''
echo "Done creating jar"
if [ "$LINUX" = true ] ; then
cd ${PACKAGING_DIR}
cd "${PACKAGING_DIR}" || exit
echo "Creating archive"
tar caf "ATCS_${VERSION}.tar.gz" "common"
echo "Created archive at ${PACKAGING_DIR}/ATCS_${VERSION}.tar.gz"