-
Notifications
You must be signed in to change notification settings - Fork 34
/
install-compiler.sh.template
146 lines (116 loc) · 3.24 KB
/
install-compiler.sh.template
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
#######################################################
#
# makeself embedded installer for the compiler package
#
#######################################################
INSTALL_ROOT=install-root
# XXX make this templated
TARGET_ROOT=/opt/roadsend/pcc
UNINSTALLER=$TARGET_ROOT/bin/roadsend-pcc-uninstall.sh
###
### require root
### ============
me=`id -u`
if [ "$me" -ne 0 ]
then
echo "You must be root to run installer"
exit 1
fi
###
### start the uninstaller script
### ============================
mkdir -p $TARGET_ROOT/bin
cat <<EOF > $UNINSTALLER
#!/bin/sh
#
# This is an automatically generated uninstaller script for the
# Roadsend PHP package
## require root
me=\`id -u\`
if [ "\$me" -ne 0 ]
then
echo "You must be root to run uninstaller"
exit 1
fi
echo "Uninstalling Roadsend PHP Binaries..."
EOF
###
### install files
### =============
echo "Roadsend PHP"
echo "http://code.roadsend.com/"
echo
echo "Installing Compiler binaries... "
echo "installation root directory is $TARGET_ROOT"
## backup /etc/pcc.conf if it's there
if [ -f "/etc/pcc.conf" ]; then
cp -f /etc/pcc.conf /etc/.pcc.conf.installer.backup
fi
# save a copy of pcc.conf
echo "cp /etc/pcc.conf /etc/pcc.conf.backup" >> $UNINSTALLER
cd $INSTALL_ROOT &&
for dir in `find . -type d`; do mkdir -p /$dir; done &&
for file in `find . -not -type d`; do
cp -Pp $file /$file;
echo "rm -f /$file" >> $UNINSTALLER
done
## check if we need to restore /etc/pcc.conf
if [ -f "/etc/.pcc.conf.installer.backup" ]; then
mv -f /etc/.pcc.conf.installer.backup /etc/pcc.conf
fi
###
### symlink bin files?
###
agreed=
while [ x$agreed = x ]; do
echo
echo -n "Do you want to symlink the Roadsend PHP binaries to the system path? [y/n/?]: "
read reply leftover
case $reply in
y* | Y*)
agreed=y;;
n* | N*)
agreed=n;;
?)
echo "Your system will need to know where to find the Roadsend PHP binaries.";
echo "If you plan to manually add $TARGET_ROOT/bin to your system's PATH";
echo "then you should say N here.";
echo "";
echo "If in doubt, say Y";;
esac
done
if test "$agreed" = y; then
echo "making binary symlinks to /usr/bin ..."
## /usr/bin links
bin_dir=$TARGET_ROOT/bin
old_dir=`pwd`
cd $bin_dir
for bin in pcc* bigloo
do
binname=`basename $bin`
ln -fs $bin_dir/$binname /usr/bin/$binname
echo "rm -f /usr/bin/$binname" >> $UNINSTALLER
done
cd $old_dir
else
echo "Please add $TARGET_ROOT/bin to your system PATH"
fi
echo "rm -f $UNINSTALLER" >> $UNINSTALLER
chmod 755 $UNINSTALLER
echo "The configuration file is located in /etc/pcc.conf"
echo "You can uninstall this package by running $UNINSTALLER"
# check for a bad (home ...) setting
grep 'home' /etc/pcc.conf |grep -q /opt
if [ -z $? ]; then
cat <<EOF
WARNING: Roadsend PHP has been installed in
/opt/roadsend/pcc, but your configuration file is from an older
version of the compiler that was previously installed elsewhere.
Please update the home directive in /etc/pcc.conf to:
(home "/opt/roadsend/pcc"),
Thank you.
EOF
fi
echo "Done."
[ -d "$TARGET_ROOT/libs" ] || echo "NOTE: You will also need to install the pcc-runtime package before using the compiler!"