-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·67 lines (60 loc) · 2.15 KB
/
package.sh
File metadata and controls
executable file
·67 lines (60 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Package the .paclet archive for distribution.
# On WSL, copies to Windows temp dir to avoid Java file locking issues.
set -e
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_ROOT"
find_wolframscript() {
if command -v wolframscript &>/dev/null; then echo "wolframscript"; return; fi
local latest=""
for dir in "/mnt/c/Program Files/Wolfram Research/Wolfram"/* \
"/mnt/c/Program Files/Wolfram Research/Mathematica"/*; do
[ -f "$dir/wolframscript.exe" ] && latest="$dir/wolframscript.exe"
done
[ -n "$latest" ] && echo "$latest" && return
for app in "/Applications/Mathematica.app" "/Applications/Wolfram.app"; do
[ -f "$app/Contents/MacOS/wolframscript" ] && echo "$app/Contents/MacOS/wolframscript" && return
done
echo ""
}
WS="$(find_wolframscript)"
if [ -z "$WS" ]; then echo "Error: wolframscript not found."; exit 1; fi
echo "Using: $WS"
STAGE=$(mktemp -d)
trap "rm -rf $STAGE" EXIT
cp PacletInfo.wl "$STAGE/"
cp -r Kernel "$STAGE/"
mkdir -p "$STAGE/LibraryResources"
for dir in LibraryResources/*/; do
if ls "$dir"sweep* &>/dev/null 2>&1; then
cp -r "$dir" "$STAGE/LibraryResources/"
fi
done
mkdir -p paclet_archive
if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ]; then
WIN_STAGE="/mnt/c/Temp/nl_paclet_build_$$"
WIN_OUT="/mnt/c/Temp/nl_paclet_output_$$"
rm -rf "$WIN_STAGE" "$WIN_OUT"
cp -r "$STAGE" "$WIN_STAGE"
mkdir -p "$WIN_OUT"
"$WS" -code "
Needs[\"PacletTools\`\"];
result = PacletTools\`PacletBuild[\"C:\\\\Temp\\\\nl_paclet_build_$$\", \"C:\\\\Temp\\\\nl_paclet_output_$$\"];
If[FailureQ[result], Print[\"FAILED: \", result]; Exit[1],
Print[\"Success: \", result]; Exit[0]]
"
cp "$WIN_OUT"/*.paclet paclet_archive/
rm -rf "$WIN_STAGE" "$WIN_OUT"
else
OUT=$(mktemp -d)
"$WS" -code "
Needs[\"PacletTools\`\"];
result = PacletTools\`PacletBuild[\"$STAGE\", \"$OUT\"];
If[FailureQ[result], Print[\"FAILED: \", result]; Exit[1],
Print[\"Success: \", result]; Exit[0]]
"
cp "$OUT"/*.paclet paclet_archive/
rm -rf "$OUT"
fi
echo ""
ls -lh paclet_archive/*.paclet