-
Notifications
You must be signed in to change notification settings - Fork 398
/
fo-installdeps
executable file
·258 lines (231 loc) · 10.1 KB
/
fo-installdeps
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/usr/bin/env bash
# FOSSology fo-installdeps script
# SPDX-FileCopyrightText: © 2008-2014 Hewlett-Packard Development Company, L.P.
# SPDX-License-Identifier: GPL-2.0-only
#
# This script helps you install build and runtime dependencies on a system.
# It is NOT indented to replace package dependencies, it's just a tool to
# make testing the "upstream" build and install process. If you determine
# this script isn't installing something you think it should, consult
# the packaging metadata for the system in question as that is the
# canonical location for such info, then fix it there first and also
# update this file and the INSTALL document.
show_help() {
cat <<EOF
Usage: fo-installdeps [options]
-r or --runtime : install runtime dependencies
-b or --buildtime : install buildtime dependencies
-e or --everything : install all dependencies (default)
-o or --offline : do not run composer installation
-y : Automatic yes to prompts
-h or --help : this help text
EOF
}
source "$(dirname ${BASH_SOURCE[0]})/utils.sh"
#
# Don't show the -y option. Should only be used for install testing, as using
# it without being careful can destroy your system.
#
YesOpt=''
#Default should be installation with internet connection
OFFLINE=''
EVERYTHING=''
RUNTIME=''
BUILDTIME=''
## Options parsing and setup
# parse options
OPTS=$(getopt -o rbeohy --long runtime,buildtime,everything,offline,help -n 'fo-installdeps' -- "$@")
if [[ $? -ne 0 ]]; then
OPTS="--help"
fi
eval set -- "$OPTS"
# if no options or just -y then do everything
if [[ $OPTS == ' --' || $OPTS == ' -y --' ]]; then
EVERYTHING=true
fi
while true; do
case "$1" in
-r|--runtime) RUNTIME=true; shift;;
-b|--buildtime) BUILDTIME=true; shift;;
-e|--everything) EVERYTHING=true; shift;;
-o|--offline) OFFLINE=true; shift;;
-y) YesOpt='-y'; shift;;
-h|--help) show_help; exit;;
--) shift; break;;
*) echo "ERROR: option $1 not recognised"; exit 1;;
esac
done
set -o errexit -o nounset -o pipefail
must_run_as_root
need_lsb_release
if [[ $EVERYTHING ]]; then
echo "*** Installing both runtime and buildtime dependencies ***"
RUNTIME=true
BUILDTIME=true
fi
# figure out what distro we're on
DISTRO=$(lsb_release --id --short)
CODENAME=$(lsb_release --codename --short)
########################################################################
echo "install core dependencies"
if [[ $BUILDTIME ]]; then
echo "*** Installing $DISTRO buildtime dependencies ***";
case "$DISTRO" in
Debian|Ubuntu)
echo "DB: Installing build essential....."
apt-get $YesOpt install \
libmxml-dev curl libxml2-dev libcunit1-dev libicu-dev \
build-essential libtext-template-perl subversion rpm librpm-dev \
libmagic-dev libglib2.0 libboost-regex-dev libzstd-dev \
libboost-program-options-dev libpq-dev composer patch devscripts \
libdistro-info-perl libcppunit-dev libomp-dev cmake ninja-build
case "$CODENAME" in
stretch)
apt-get $YesOpt install php-mbstring php7.0-cli php7.0-xml php7.0-zip php7.0-gd php7.0-pgsql php7.0-curl php7.0-uuid;;
buster)
apt-get $YesOpt install php-mbstring php7.3-cli php7.3-xml php7.3-zip php7.3-gd php7.3-pgsql php7.3-curl php7.3-uuid;;
bullseye)
apt-get $YesOpt install php7.4-mbstring php7.4-cli php7.4-xml php7.4-zip php7.4-gd php7.4-pgsql php7.4-curl php7.4-uuid;;
sid)
apt-get $YesOpt install php-mbstring php-cli php-xml php-zip php-gd php-pgsql php-curl php-uuid;;
focal)
apt-get $YesOpt install php-mbstring php-cli php-xml php-zip php-gd php-pgsql php-curl php-uuid;;
jammy)
apt-get $YesOpt install php-mbstring php-cli php-xml php-zip php-gd php-pgsql php-curl php-uuid;;
esac
if ! dpkg --get-selections | grep -q postgresql-server-dev; then ## if postgresql-server-dev is not installed
case "$CODENAME" in
stretch)
apt-get $YesOpt install postgresql-server-dev-9.6;;
buster)
apt-get $YesOpt install postgresql-server-dev-11;;
bullseye)
apt-get $YesOpt install postgresql-server-dev-13;;
sid)
apt-get $YesOpt install postgresql-server-dev-11;;
focal)
apt-get $YesOpt install postgresql-server-dev-12;;
jammy)
apt-get $YesOpt install postgresql-server-dev-14;;
*) echo "ERROR: Unknown or Unsupported $DISTRO $CODENAME release, please report to the mailing list"; exit 1;;
esac
fi
;;
Fedora)
yum $YesOpt groupinstall "Development Tools"
yum $YesOpt install \
perl-Text-Template subversion \
postgresql-devel file-devel \
libxml2 \
boost-devel php-mbstring libicu-devel libpq-devel patch \
libomp-devel cmake ninja-build
;;
RedHatEnterprise*|CentOS)
yum $YesOpt install \
postgresql-devel \
gcc make file libxml2 \
perl-Text-Template subversion \
boost-devel php-mbstring libicu-devel libpq-devel patch \
libomp-devel cmake ninja-build
;;
*) echo "ERROR: distro not recognised, please fix and send a patch"; exit 1;;
esac
fi
########################################################################
if [[ $RUNTIME ]]; then
echo "*** Installing $DISTRO runtime dependencies ***";
echo "*** For optional email notifications a Mail Transport Agent Must be ***";
echo "*** installed. Consult with your system administrator. Or try ***";
echo "*** apt-get install mail-transport-agent, pick one and install it***";
case "$DISTRO" in
Debian|Ubuntu)
echo "doing runtime"
apt-get $YesOpt install apache2
apt-get $YesOpt install php-pear \
libxml2 libzstd1 \
binutils \
cabextract cpio sleuthkit genisoimage \
poppler-utils upx-ucl \
unrar-free unzip p7zip-full p7zip wget \
subversion git \
dpkg-dev php-uuid
case "$CODENAME" in
stretch)
apt-get $YesOpt install postgresql-9.6 php7.0 php7.0-pgsql libapache2-mod-php7.0 php7.0-pgsql \
php7.0-cli php7.0-curl php7.0-xml php7.0-zip php7.0-mbstring php7.0-uuid php-gettext s-nail libboost-program-options1.62.0 \
libboost-regex1.62.0 libicu57;;
buster)
apt-get $YesOpt install postgresql-11 php7.3 php7.3-pgsql libapache2-mod-php7.3 php7.3-pgsql \
php7.3-cli php7.3-curl php7.3-xml php7.3-zip php7.3-mbstring php7.3-uuid php-gettext s-nail libboost-program-options1.67.0 \
libboost-regex1.67.0 libicu63;;
bullseye)
apt-get $YesOpt install postgresql-13 php7.4 php7.4-pgsql \
libapache2-mod-php7.4 php7.4-pgsql php7.4-cli php7.4-curl \
php7.4-xml php7.4-zip php7.4-mbstring php7.4-uuid php-php-gettext s-nail \
libboost-program-options1.74.0 libboost-regex1.74.0 libicu67;;
sid)
apt-get $YesOpt install postgresql php php-pgsql php-cli php-curl php-xml php-zip php-mbstring php-uuid php-gettext s-nail \
libboost-program-options1.74.0 libboost-regex1.74.0 libicu67;;
focal)
apt-get $YesOpt install postgresql php php-pgsql php-cli php-curl php-xml php-zip php-mbstring php-uuid s-nail \
libboost-program-options1.71.0 libboost-regex1.71.0 libicu66;;
jammy)
apt-get $YesOpt install postgresql-14 php8.1 php8.1-pgsql \
libapache2-mod-php8.1 php8.1-pgsql php8.1-cli php8.1-curl \
php8.1-xml php8.1-zip php8.1-mbstring php8.1-uuid php-php-gettext s-nail \
libboost-program-options1.74.0 libboost-regex1.74.0 libicu70;;
*) echo "ERROR: Unknown or Unsupported $DISTRO $CODENAME release, please report to the mailing list"; exit 1;;
esac
;;
Fedora)
yum $YesOpt install postgresql-server httpd chkconfig
yum $YesOpt install \
postgresql \
php php-pear php-pgsql php-process php-xml php-mbstring\
smtpdaemon \
libxml2 \
binutils mailx \
sleuthkit boost libicu
# enable, possible init, and start postgresql
/sbin/chkconfig postgresql on
if [ ! -f /var/lib/pgsql/data/PG_VERSION ]; then
/usr/bin/postgresql-setup --initdb
fi
/usr/bin/systemctl start postgresql
echo "NOTE: unrar is not available in Fedora release $CODENAME,"
echo " please install from upstream sources."
;;
RedHatEnterprise*|CentOS)
yum $YesOpt install postgresql-server httpd
yum $YesOpt install \
postgresql \
php php-pear php-pgsql php-process php-mbstring\
smtpdaemon \
file libxml2 \
binutils mailx boost libicu
echo "NOTE: cabextract, sleuthkit, upx, and unrar are not"
echo " available in RHEL please install from upstream sources."
;;
*) echo "ERROR: distro not recognised, please fix and send a patch"; exit 1;;
esac
if [[ $OFFLINE ]]; then
echo "WARNING: composer is not installed, and the installer does not install it due to the offline switch"
echo "Please run the equivalent of 'sudo ./utils/install_composer.sh'"
else
"$( dirname "$0" )/install_composer.sh"
fi
fi
########################################################################
options=''
if [[ $BUILDTIME ]]; then
options="$options -b"
fi
if [[ $RUNTIME ]]; then
options="$options -r"
fi
if [[ $YesOpt ]]; then
options="$options -y"
fi
mods_dir="$(dirname "$0")/../src/" ## get the directory where fo-installdeps resides
find "$mods_dir" -type f -name mod_deps -execdir bash -cv "{} $options" \;
########################################################################