-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
executable file
·119 lines (119 loc) · 4.64 KB
/
install
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
#!/bin/bash
# installs CCGlab externals, to go with git ccglab repo.
# also sets PATH and lisp execs so that ccglab is available from anywhere
# brew does not allow sudo anymore-- $SUDO controls that
# cem bozsahin 2015-2021
# check to see if there is already a ccglab
if [ "$CCGLAB_HOME" ]; then
echo "You have a CCGlab installed at: $CCGLAB_HOME."
echo "There is no need to reinstall. Just do 'git pull' at $CCGLAB_HOME for the latest."
exit -1
fi
LOG="=======================================================\nCCGlab install and set up, `date`\n=======================================================" # installers can be very verbose, accumulate all deeds to report at end
LOGFILE='/tmp/ccglab-install.log'
LOG+="\n-CCGlab command-line resources for install and use:"
LOG+="\n wget=`command -v wget`"
LOG+="\n git=`command -v git`"
LOG+="\n awk=`command -v awk`"
LOG+="\n sed=`command -v sed`"
if [ ! `command -v wget` ] || [ ! `command -v awk` ] || [ ! `command -v git` ] || [ ! `command -v sed` ]; then
LOG+="\n-Your system is missing some install and CCGlab command-line basics."
LOG+="\n-Check the top of this log file to find out which one is missing"
LOG+="\n-Install the missing one in your system before CCGlab install and use"
LOG+="\n-CCGlab install: ABORTED"
else
echo "PLEASE NOTE:"
echo " IN CASE THE INSTALLER ASKS FOR superuser PASSWORD,"
echo " It will be ONLY for installing sbcl and rlwrap THRU safe installers"
echo " "
SUDO=sudo
ccglabdir=`pwd`
lalrdir=~
# dont wget if its already here but not set
if [ -f "$lalrdir/lalrparser.lisp" ] && [ ! "$LALR_HOME" ]; then
LALR_HOME=$lalrdir
LOG+="\n-LALR parser: no download; local one set for CCGlab"
fi
# check to see if lalr has been set and installed before
if [ ! "$LALR_HOME" ]; then
wget -v --no-check-certificate --backups=3 http://web.science.mq.edu.au/~mjohnson/code/lalrparser.lisp
LOG+="\n-LALR parser downloaded and installed at $lalrdir"
mv lalrparser.lisp $lalrdir # -o option of wget is unpredictable
else
lalrdir=$LALR_HOME
LOG+="\n-LALR parser taken from $LALR_HOME"
fi
#check if SBCL and rlwrap need installing-- SBCL is the standard CCGlab lisp
#there is a pecking order of packagers, in case you have more than one
packager=
install=install
if [ `command -v dnf` ]; then
packager=dnf
fi
if [ `command -v yum` ]; then
packager=yum
# open library space of yum
$SUDO yum $install yum-utils
$SUDO yum-config-manager --enable \*
fi
if [ `command -v apt-get` ]; then
packager=apt-get
# open library space of apt-get and refresh
$SUDO add-apt-repository universe
$SUDO apt-get update
fi
if [ `command -v pacman` ]; then
packager=pacman
install='-S'
fi
if [ `command -v brew` ]; then
packager=brew
SUDO=
fi
if [ "$packager" ]; then
LOG+="\n-You have an installer ($packager) for standard packages"
else
LOG+="\n-apt-get, dnf, pacman, yum or brew not found. I leave Common Lisp and rlwrap handling to you."
LOG+="\n-The README.md in the git repo shows how you can set them manually."
fi
if [ ! `command -v sbcl` ]; then
if [ "$packager" ]; then
$SUDO $packager $install sbcl
LOG+="\n-sbcl is downloaded and installed"
fi
else
LOG+="\n-Local sbcl is set for CCGlab"
fi
locallisp=`command -v sbcl`
if [ `command -v rlwrap` ]; then
LOG+="\n-Local rlwrap is set for CCGlab"
else
if [ "$packager" ]; then
LOG+="\n-rlwrap is downloaded and installed"
$SUDO $packager $install rlwrap
fi
fi
printf '%s\n' '# stuff added by CCGlab installer' >> ~/.bashrc
if [ `command -v rlwrap` ]; then
printf '%s\n' 'export RLWRAP=rlwrap' >> ~/.bashrc
else
printf '%s\n' 'export RLWRAP=' >> ~/.bashrc
LOG+='\n-Change the RLWRAP variable in ~/.bashrc if you have rlwrap somewhere'
fi
printf '%s\n%s\n%s\n%s\n' "export CCGLAB_HOME=$ccglabdir" "export CCGLAB_LISP=$locallisp" "export LALR_HOME=$lalrdir" "export PATH=:.:\$CCGLAB_HOME/bin:\$PATH" >> ~/.bashrc
printf '%s\n' '# end of stuff added by CCGlab installer' >> ~/.bashrc
printf '%s\n' '# stuff added by CCGlab installer' >> ~/.bash_profile
printf '%s\n' 'if [ -f ~/.bashrc ]; then source ~/.bashrc; fi' >> ~/.bash_profile
LOG+='\n-Your .bashrc and .bash_profile have been updated for CCGlab'
LOG+='\n-Just do "git pull" in ccglab home for updates from now on.'
LOG+="\n-I wouldnt do updates in standard files of $ccglabdir."
LOG+="\n-They will be overridden by next git pull"
LOG+="\n-CCGlab manual has some pointers for grammar and model development workflows"
LOG+="\n\n-To run, first open a fresh terminal, or logout and login. Then do"
LOG+="\n ccglab"
LOG+="\n\n-CCGlab install: COMPLETED"
fi
LOG+="\n-This log is saved in file $LOGFILE"
LOG+="\n`date`\n======================================================="
echo -e $LOG > $LOGFILE
echo -e $LOG