-
Notifications
You must be signed in to change notification settings - Fork 10
/
build
executable file
·124 lines (106 loc) · 3.12 KB
/
build
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#! /bin/bash
function error_exit
{
echo "$1" 1>&2
exit 1
}
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Build script for Latex.bbpackage"
echo
echo "Usage: $0"
exit
fi
# go to directory containing this script
cd $( dirname "${BASH_SOURCE[0]}" )
cd AppleScriptSources || error_exit "Error: Unable to find AppleScriptSources directory"
# Check for tex location
# ----------------------
echo -n "Locating tex binaries...."
if bin=$( which pdflatex ); then
bin=${bin%pdflatex}
echo $bin
else
bin="/usr/texbin/"
echo "Not found"
echo "Warning: pdflatex directory not found; assuming $bin"
echo "The typsetting script may not work"
echo
fi
if [ $bin != "/usr/texbin/" ]; then
echo -n "Editing AppleScript to use custom tex path..."
sed -i '' 's!^property texbin.*$!property texbin : "'"${bin}"'"!g' "Resources/typeset-lib.applescript"
echo "Done"
fi
# Check for chktex location
# ----------------------
echo -n "Locating chktex script..."
if bin=$( which chktex ); then
bin=${bin%chktex}
echo $bin
else
bin="/usr/texbin/"
echo "Not found"
echo "Warning: chktex directory not found; assuming $bin"
echo "You can install chktex using homebrew"
echo " $ brew install chktex"
echo "or macports"
echo " $ sudo port install texlive-bin-extra"
echo "Only the \"Check Latex Semantics\" script depends on chktex"
echo
fi
if [ $bin != "/usr/texbin/" ]; then
echo -n "Editing AppleScript to use custom chktex path..."
sed -i '' 's!^property chktexbin.*$!property chktexbin : "'"${bin}"'"!g' "Scripts/Tools/Check Latex Semantics.applescript"
echo "Done"
fi
# Check for git location
# ----------------------
if bin=$( which git ); then
bin=${bin%git}
else
bin="/usr/local/bin/"
fi
if [ $bin != "/usr/local/bin/" ]; then
sed -i '' 's!^property gitbin.*$!property gitbin : "'"${bin}"'"!g' "Resources/typeset-lib.applescript"
fi
# Compile AppleScript sources
# ---------------------------
# create directories if necessary
find . -type d | while read directory
do
[ -d "../Contents/$directory" ] || mkdir "../Contents/$directory"
done
echo -n "Compiling AppleScripts"
find . -name "*.applescript" | while read file
do
if osacompile -o "../Contents/${file%applescript}scpt" "$file"; then
echo -n "."
else
echo "Error: unable to compile $file"
fi
done
echo "Done"
# return to parent directory
cd ..
# Set stationery bit on stationery
# --------------------------------
cd Contents/Stationery
echo -n "Setting stationery bits"
for f in *
do
# if the file has no xattr's, then add some
# this is necessary for the applescript to work
xattr "$f" | grep -q 'com\.apple\.FinderInfo' \
|| xattr -wx com.apple.FinderInfo \
"54 45 58 54 00 00 00 00 08 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" "$f"
# use applescript
if osascript -e "tell application \"Finder\" to set stationery of (POSIX file \"$f\" as alias) to true" > /dev/null 2>&1; then
echo -n "."
else
echo "Error: unable to set stationery bit on $f"
fi
done
echo "Done"
# return to parent directory
cd ../..