-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvmfs-install
executable file
·186 lines (158 loc) · 4.17 KB
/
cvmfs-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
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
#!/usr/bin/env bash
#
# Copyright 2013 Victor Penso
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
_version=0.1
# Filename of this script
_script=$(basename $0)
# Help text for this script
function _help() {
echo "Usage:
Install CVMFS locally and/or build Debian packages.
$_script [-bdhp] VERSION
Options:
-b,--build-only
Do not install the binaries.
-d, --debug
Print debug messages
-h, --help
Show this test.
-p,--build-package
Build Debian packages."
}
# enable line numbers for debug output
if [ "$_DEBUG" = "true" ] ; then
export PS4='(${BASH_SOURCE}:${LINENO}):${FUNCNAME[0]}-[${SHLVL},${BASH_SUBSHELL},$?] '
fi
function _debug() {
if [ "$_DEBUG" = "true" ]; then
echo 1>&2 "DEBUG: $@"
fi
}
function _error() {
echo 1>&2 "ERROR: $@"
}
# Parse the command line options
ARGS=$(getopt -o hdbp -l "help;debug;build-only;build-package" -- "$@")
eval set -- "$ARGS"
while true; do
case "$1" in
-b|--build-only)
BUILD_ONLY=true
shift
;;
-p|--build-package)
BUILD_PACKAGE=true
shift
;;
-d|--debug)
_DEBUG=true
shift
;;
-h|--help)
_help
exit 0
;;
--) shift; break ;;
*) break ;;
esac
done
# Does the caller provided a version?
version=$1 ; shift
if [ -f $version ] ; then
_error "No version defined!"
_help
exit 1
fi
# list of dependency packages
packages="build-essential
autotools-dev
debhelper
devscripts
attr
curl
cmake
libcurl3
libcurl4-openssl-dev
chkconfig
sqlite3
libsqlite3-dev
autofs5
fuse-utils
libfuse-dev
libattr1-dev
linux-headers-$(uname -r)"
# install all dependencies
export DEBIAN_FRONTEND=noninteractive
for package in $packages ; do
apt-get -qqy install $package 1>/dev/null 2>/dev/null
if [[ $? != 0 ]] ; then
_error "Couldn't install package $package"
exit 1
fi
_debug "Package $package installed."
done
echo "All build dependencies available."
# developers source code URL
source_uri=https://ecsft.cern.ch/dist/cvmfs/cvmfs-$version/cvmfs_$version.tar.gz
# target build directory
build_directory=/usr/local/src
mkdir -p $build_directory 2>/dev/null
# source code archive
source_file=$build_directory/cvmfs_$version.orig.tar.gz
# get the source code
if [ ! -f $source_file ] ; then
_debug "Download CVMFS $version to $build_directory"
curl --insecure --silent --show-error --output $source_file $source_uri
fi
if [ ! -d $build_directory/cvmfs-$version ] ; then
_debug "Extract source archive to $build_directory"
tar --extract --gzip --file $source_file --directory $build_directory
fi
cd $build_directory/cvmfs-$version
echo "Working directory $PWD"
_debug "Execute Cmake to configure the build process"
cmake . > configure.log 2>&1
if [[ $? != 0 ]] ; then
_error "Configure failed! Check $PWD/configure.log"
exit 1
fi
echo "Configure finished."
# build the source code
_debug "Run make to build the binary code."
make > build.log 2>&1
if [[ $? != 0 ]] ; then
_error "Build failed! Check $PWD/build.log"
exit 1
fi
echo "Build finished."
if [ "$BUILD_PACKAGE" = "true" ] ; then
_debug "Build Debian package."
debuild -us -uc > build-package.log 2>&1
if [[ $? != 0 ]] ; then
_error "Package build failed! Check $PWD/build-package.log"
exit 1
fi
echo "Packages should be available in $build_directory"
exit 0
fi
if [ ! "$BUILD_ONLY" = "true" ] ; then
# deploy the software
make install > $PWD/install.log
echo "Installation finished."
fi
cd - 1>/dev/null
exit 0