Debian Codegraph @

scripts/macos_luarocks

raw symbols SCIP
1 #!/bin/bash
2 : ' Copyright (c) 2016- Toby "tobylane"
3 Permission is hereby granted, free of charge, to any person obtaining a copy of
4 this software and associated documentation files (the "Software"), to deal in
5 the Software without restriction, including without limitation the rights to
6 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 of the Software, and to permit persons to whom the Software is furnished to do
8 so, subject to the following conditions:
9 The above copyright notice and this permission notice shall be included in all
10 copies or substantial portions of the Software.
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 SOFTWARE.'
18 ## Settings
19 # Lua version, if not the lua CorsixTH was built with. Use 5.1 for luajit
20 #lua_version="5.4"
21 # The luarocks executable if not in PATH
22 luarocks="luarocks"
23 # The luarocks folder, assuming all rocks are together
24 dir="$($luarocks show --rock-tree luafilesystem)"
25 # Always overwrite existing rocks if uncommented
26 #always_copy=true
27 # Always build new rocks if uncommented
28 #always_build=true
29
30 set -ae
31 if [ "$CTH_VERBOSE" ] || [ "$CI" ]; then
32 set -x
33 fi
34
35 # Find target app
36 if [ -d "$1" ]; then
37 cd "$1"
38 elif [ -d /Applications/CorsixTH.app ]; then
39 cd /Applications/
40 fi
41 if [ -d CorsixTH.app ]; then
42 cd CorsixTH.app/Contents/Resources/
43 else
44 echo "No CorsixTH.app found"
45 exit 1
46 fi
47
48 # Find lua version
49 if [ -n "$lua_version" ]; then
50 lua=$lua_version
51 elif otool -L ../MacOS/CorsixTH | grep -q 'lua'; then
52 lua="$(otool -L ../MacOS/CorsixTH | grep 'lua' | sed -rn "s/.*current.* ([0-9]\.[0-9]).*/\1/p")"
53 elif lua -v >/dev/null; then
54 lua="$(lua -v | cut -d" " -f2 | cut -d. -f1-2)"
55 fi
56 if [ -z "$lua" ]; then
57 lua=5.4
58 echo "No Lua library or executable found, using version 5.4."
59 fi
60
61 # Collect rocks
62 if [ -e lfs.so ] && [ -e lpeg.so ] && [ -z "$always_copy" ] && [ -z "$always_build" ]
63 then echo "Luarocks for $lua in place."
64 exit 0
65 elif [ -e "$dir/lib/lua/$lua/lfs.so" ] && [ -e "$dir/lib/lua/$lua/lpeg.so" ] &&
66 [ -d "$dir/share/lua/" ] && [ -z "$always_build" ]
67 then mkdir -p lib/lua/"$lua/" share/lua/"$lua/"
68 cp -RL "$dir/lib/lua" lib/
69 cp -RL "$dir/share/lua" share/
70 echo "Copied luarocks from global installation for $lua."
71 else
72 luarocks="$luarocks install --lua-version $lua --tree ."
73 $luarocks luafilesystem
74 $luarocks lpeg
75 echo "Installed local luarocks for $lua."
76 fi
77
78 # Move into place for CorsixTH
79 rsync -r "lib/lua/$lua/"lpeg.so "lib/lua/$lua/"lfs.so .
80 rsync -r "share/lua/$lua/"re.lua ./Lua/
81 rm -rf lib/ share/