Skip to content
Commits on Source (1)
  • Patryk Obara's avatar
    Simplify launcher script · 4dec08f2
    Patryk Obara authored
    Also, place all files in a newly created subdirectory to avoid a number
    of issues related to case sensitivity.
    
    Launcher script is prefferred over symlinks packaged in the tarball,
    because the game supports multiple languages and some files might be
    named differently in depots for different languages; it has also
    added benefit of supporting demo version of the game.
    4dec08f2
#!/bin/bash
relpathresult=""
relpath() {
# both $1 and $2 are absolute paths beginning with /
# $1 must be a canonical path; that is none of its directory
# components may be ".", ".." or a symbolic link
#
# returns relative path to $2/$target from $1/$source
source=$1
target=$2
common_part=$source
result=
while [ "${target#"$common_part"}" = "$target" ]; do
# no match, means that candidate common part is not correct
# go up one level (reduce common part)
common_part=$(dirname "$common_part")
# and record that we went back, with correct / handling
if [ -z "$result" ]; then
result=..
else
result=../$result
fi
done
if [ "$common_part" = / ]; then
# special case for root (no common path)
result=$result/
fi
# since we now have identified the common part,
# compute the non-common part
forward_part=${target#"$common_part"}
# and now stick all parts together
if [ -n "$result" ] && [ -n "$forward_part" ]; then
result=$result$forward_part
elif [ -n "$forward_part" ]; then
# extra slash removal
result=${forward_part#?}
fi
relpathresult="$result"
lowercase () {
echo "$@" | tr '[:upper:]' '[:lower:]'
}
processfile() {
fname=$1
convertedfilename=$(echo "$fname" | tr '[:upper:]' '[:lower:]')
pathexistscheck=$(readlink -e "$convertedfilename")
dirname=$(dirname "$convertedfilename")
if [ ! -d "$dirname" ]
then
mkdir -p "$dirname"
fi
relpath "$dirname" "$fname"
relativepathtorealfile="$relpathresult"
if [ -z "$pathexistscheck" ]
then
echo "$fname -> $convertedfilename"
ln -s "$relativepathtorealfile" "$convertedfilename"
fi
create_relative_symlink () {
local -r target=$1
local -r symlink="share/arx/data/$(lowercase "$target")"
mkdir -p "$(dirname "$symlink")"
ln -rsf "$target" "$symlink"
}
find . -maxdepth 1 -type f -name "[[:upper:]]*" | while read fname; do
processfile "$fname"
done
# http://wiki.arx-libertatis.org/Required_data_files_and_checksums
find ./Graph -type f | while read fname; do
processfile "$fname"
find {misc,Graph} -type f | while read -r file_name ; do
create_relative_symlink "$file_name"
done
find ./misc -type f | while read fname; do
processfile "$fname"
for pak in *.pak ; do
create_relative_symlink "$pak"
done
./arx-bin --data-dir=.
./arx-bin --data-dir=share/arx/data "$@"