-
Notifications
You must be signed in to change notification settings - Fork 5
/
makedeb.sh
executable file
·289 lines (260 loc) · 9.27 KB
/
makedeb.sh
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/bin/bash
#
# Constants
#
source /etc/os-release
VERSION="1.0.0~alpha18"
BUILD="1"
#
# Package requirements for build
#
if [ "x$(whoami)" != "xroot" ]; then
echo "Sorry, this currently needs to be run as root. Quitting."
echo
exit 1
fi
#
if [ "x${ID}" == "xdebian" ]||[ "x${ID}" == "xubuntu" ]; then
OS="${ID}${VERSION_ID}"
else
echo "Warning: This OS is not recognised. Attempting to continue"
echo
OS="unknown"
fi
RELEASE="${VERSION}~${OS}-${BUILD}"
echo "Release: ${RELEASE}"
#
apt install build-essential unzip libcap-dev libssl-dev
if [ ${?} -ne 0 ]; then
echo
echo "Sorry, could not verify required packages for build. Quitting."
echo
exit 1
fi
#
# Locate our script
#
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
SDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd $SDIR || exit 1
ODIR=$(pwd)
BDIR="/tmp/openakc_${RELEASE}_build.$$"
mkdir -p ${BDIR}
cp -dpR ${SDIR}/* ${BDIR}
cd $BDIR || exit 1
echo "Building OpenAKC Capability Tool"
cd tools/openakc-cap
gcc -fPIC -O2 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -g -c openakc-cap.c -o openakc-cap.o
gcc -O2 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -g -o openakc-cap openakc-cap.o -lcap
cp openakc-cap -p ${BDIR}/bin
cd ../..
echo "Unpacking Tools"
cd tools
unzip -q hpenc-3.0.zip
unzip -q libsodium-1.0.18-RELEASE.zip
cd ..
echo "Building Sodium Security Library"
cd tools/libsodium-1.0.18-RELEASE
./configure
make
cd ../..
echo "Building HPEnc stream encryption tool"
cd tools/hpenc-3.0/src
cp ../../libsodium-1.0.18-RELEASE/src/libsodium/include/sodium.h .
cp ../../libsodium-1.0.18-RELEASE/src/libsodium/.libs/libsodium.a .
cp -dpR ../../libsodium-1.0.18-RELEASE/src/libsodium/include/sodium .
patch -p0 < ../../../resources/hpenc30.src.Makefile.patch
cd ..
make
cd ../..
echo "Compiling Shell Scripts"
cd ${BDIR}/bin
#
cp ../tools/hpenc-3.0/src/hpenc ./openakc-hpenc
strip ./openakc-hpenc
strip ./openakc-cap
#
sed -i "s,^RELEASE=.*,RELEASE=\"${RELEASE}\",g" openakc
##shc -v -r -T -f openakc
cp openakc openakc.x
#
sed -i "s,^RELEASE=.*,RELEASE=\"${RELEASE}\",g" openakc-server
##shc -v -r -T -f openakc-server
cp openakc-server openakc-server.x
#
sed -i "s,^RELEASE=.*,RELEASE=\"${RELEASE}\",g" openakc-plugin
##shc -v -r -T -f openakc-plugin
cp openakc-plugin openakc-plugin.x
#
sed -i "s,^RELEASE=.*,RELEASE=\"${RELEASE}\",g" openakc-session
##shc -v -r -T -f openakc-session
cp openakc-session openakc-session.x
#
# Build Client Package
#
cd $BDIR || exit 1
PDIR="openakc_${RELEASE}_amd64"
#
mkdir -p "${PDIR}/DEBIAN"
mkdir -p "${PDIR}/etc/openakc"
mkdir -p "${PDIR}/var/lib/openakc"
mkdir -p "${PDIR}/usr/sbin"
mkdir -p "${PDIR}/usr/bin"
mkdir -p "${PDIR}/usr/share/doc/openakc"
mkdir -p "${PDIR}/etc/rsyslog.d"
#
cp resources/openakc.conf "${PDIR}/etc/openakc/"
cp resources/openakc.conf.readme "${PDIR}/etc/openakc/"
cp bin/openakc-cap "${PDIR}/usr/bin/openakc-cap"
cp bin/openakc-hpenc "${PDIR}/usr/bin/openakc-hpenc"
cp bin/openakc-session.x "${PDIR}/usr/bin/openakc-session"
cp resources/deb_prerm "${PDIR}/DEBIAN/prerm"
cp resources/deb_preinst "${PDIR}/DEBIAN/preinst"
sed -e "s,%RELEASE%,$RELEASE,g" resources/deb_postinst > "${PDIR}/DEBIAN/postinst"
cp resources/deb_postrm "${PDIR}/DEBIAN/postrm"
cp bin/openakc-plugin.x "${PDIR}/usr/sbin/openakc-plugin"
cp LICENSE "${PDIR}/usr/share/doc/openakc/"
cp LICENSE-hpenc "${PDIR}/usr/share/doc/openakc/"
cp LICENSE-libsodium "${PDIR}/usr/share/doc/openakc/"
cp QUICKSTART.txt "${PDIR}/usr/share/doc/openakc/"
#
chmod 755 "${PDIR}/var/lib/openakc"
chmod 755 "${PDIR}/etc/openakc"
chmod 644 "${PDIR}/etc/openakc/openakc.conf"
chmod 644 "${PDIR}/etc/openakc/openakc.conf.readme"
chmod 755 "${PDIR}/DEBIAN/postinst"
#
echo "Package: openakc" > "${PDIR}/DEBIAN/control"
echo "Version: ${VERSION}-${BUILD}" >> "${PDIR}/DEBIAN/control"
echo "Maintainer: A. James Lewis <[email protected]>" >> "${PDIR}/DEBIAN/control"
echo "Depends: openssh-server (>= 7.0), openssh-client (>= 7.0), bash (>= 3.2), openssl (>= 0.9.8), openakc-shared, coreutils, hostname, debianutils, e2fsprogs, libcap2" >> "${PDIR}/DEBIAN/control"
echo "Conflicts: openakc-server" >> "${PDIR}/DEBIAN/control"
echo "Homepage: http://www.fsck.co/uk/openakc/" >> "${PDIR}/DEBIAN/control"
echo "Architecture: amd64" >> "${PDIR}/DEBIAN/control"
echo "Description: OpenAKC Agent" >> "${PDIR}/DEBIAN/control"
#
dpkg-deb --build "${PDIR}"
rm -fr "${PDIR}"
#
# Build Tools Package
#
cd $BDIR || exit 1
PDIR="openakc-tools_${RELEASE}_amd64"
#
mkdir -p "${PDIR}/DEBIAN"
mkdir -p "${PDIR}/usr/bin"
mkdir -p "${PDIR}/usr/share/doc/openakc-tools"
mkdir -p "${PDIR}/etc/rsyslog.d"
#
cp bin/openakc "${PDIR}/usr/bin/openakc"
cp LICENSE "${PDIR}/usr/share/doc/openakc-tools/"
#
chmod 755 "${PDIR}/usr/bin/openakc"
#
echo "Package: openakc-tools" > "${PDIR}/DEBIAN/control"
echo "Version: ${VERSION}-${BUILD}" >> "${PDIR}/DEBIAN/control"
echo "Maintainer: A. James Lewis <[email protected]>" >> "${PDIR}/DEBIAN/control"
echo "Depends: bash (>= 3.2), openssl (>= 0.9.8), openakc-shared, coreutils, hostname, sudo, debianutils" >> "${PDIR}/DEBIAN/control"
echo "Homepage: http://www.fsck.co.uk/openakc/" >> "${PDIR}/DEBIAN/control"
echo "Architecture: amd64" >> "${PDIR}/DEBIAN/control"
echo "Description: OpenAKC API Tools" >> "${PDIR}/DEBIAN/control"
#
dpkg-deb --build "${PDIR}"
rm -fr "${PDIR}"
#
# Build Server Package
#
cd $BDIR || exit 1
PDIR="openakc-server_${RELEASE}_amd64"
#
mkdir -p "${PDIR}/DEBIAN"
#mkdir -p "${PDIR}/etc/openakc"
#mkdir -p "${PDIR}/var/lib/openakc"
mkdir -p "${PDIR}/usr/sbin"
mkdir -p "${PDIR}/usr/bin"
mkdir -p "${PDIR}/etc/sudoers.d"
mkdir -p "${PDIR}/etc/xinetd.d"
mkdir -p "${PDIR}/lib/systemd/system"
mkdir -p "${PDIR}/usr/share/doc/openakc-server"
#
cp bin/openakc-hpenc "${PDIR}/usr/bin/openakc-hpenc"
cp bin/openakc-server.x "${PDIR}/usr/sbin/openakc-server"
cp resources/deb_postinst-server "${PDIR}/DEBIAN/postinst"
cp resources/deb_postrm-server "${PDIR}/DEBIAN/postrm"
cp resources/deb_preinst-server "${PDIR}/DEBIAN/preinst"
cp resources/openakc-sudoers "${PDIR}/etc/sudoers.d/openakc"
cp resources/openakc-xinetd "${PDIR}/etc/xinetd.d/openakc"
cp resources/[email protected] "${PDIR}/lib/systemd/system/"
cp resources/openakc.socket "${PDIR}/lib/systemd/system/"
cp docs/OpenAKC_Admin_Guide.pdf "${PDIR}/usr/share/doc/openakc-server/"
cp LICENSE "${PDIR}/usr/share/doc/openakc-server/"
cp LICENSE-hpenc "${PDIR}/usr/share/doc/openakc-server/"
cp LICENSE-libsodium "${PDIR}/usr/share/doc/openakc-server/"
cp QUICKSTART.txt "${PDIR}/usr/share/doc/openakc-server/"
#
chmod 640 "${PDIR}/etc/sudoers.d/openakc"
chmod 640 "${PDIR}/etc/xinetd.d/openakc"
chmod 644 "${PDIR}/lib/systemd/system/[email protected]"
chmod 644 "${PDIR}/lib/systemd/system/openakc.socket"
#
echo "Package: openakc-server" > "${PDIR}/DEBIAN/control"
echo "Version: ${VERSION}-${BUILD}" >> "${PDIR}/DEBIAN/control"
echo "Maintainer: A. James Lewis <[email protected]>" >> "${PDIR}/DEBIAN/control"
echo "Depends: openssh-client (>= 7.0), bash (>= 3.2), openssl (>= 0.9.8), openakc-shared, coreutils, openakc-tools" >> "${PDIR}/DEBIAN/control"
echo "Conflicts: openakc" >> "${PDIR}/DEBIAN/control"
echo "Homepage: http://www.fsck.co/uk/openakc/" >> "${PDIR}/DEBIAN/control"
echo "Architecture: amd64" >> "${PDIR}/DEBIAN/control"
echo "Description: OpenAKC API Server" >> "${PDIR}/DEBIAN/control"
#
dpkg-deb --build "${PDIR}"
rm -fr "${PDIR}"
#
# Build Shared Package
#
cd $BDIR || exit 1
PDIR="openakc-shared_${RELEASE}_amd64"
#
mkdir -p "${PDIR}/DEBIAN"
mkdir -p "${PDIR}/var/lib/openakc/libexec"
mkdir -p "${PDIR}/usr/share/doc/openakc-shared"
mkdir -p "${PDIR}/etc/rsyslog.d"
#
cp bin/openakc-functions "${PDIR}/var/lib/openakc/libexec/functions-${RELEASE}"
cp resources/openakc-rsyslog "${PDIR}/etc/rsyslog.d/99-openakc.conf"
#cp resources/deb_preinst-shared "${PDIR}/DEBIAN/preinst"
sed -e "s,%RELEASE%,$RELEASE,g" resources/deb_preinst-shared > "${PDIR}/DEBIAN/preinst"
sed -e "s,%RELEASE%,$RELEASE,g" resources/deb_postinst-shared > "${PDIR}/DEBIAN/postinst"
sed -e "s,%RELEASE%,$RELEASE,g" resources/deb_prerm-shared > "${PDIR}/DEBIAN/prerm"
cp resources/deb_postrm-shared "${PDIR}/DEBIAN/postrm"
cp LICENSE "${PDIR}/usr/share/doc/openakc-shared/"
#
##chmod 755 "${PDIR}/usr/bin/openakc"
chmod 640 "${PDIR}/etc/rsyslog.d/99-openakc.conf"
chmod 644 "${PDIR}/var/lib/openakc/libexec/functions-${RELEASE}"
chmod 755 "${PDIR}/var/lib/openakc/libexec"
chmod 755 "${PDIR}/DEBIAN/preinst"
chmod 755 "${PDIR}/DEBIAN/postinst"
chmod 755 "${PDIR}/DEBIAN/prerm"
chmod 755 "${PDIR}/DEBIAN/postrm"
#
echo "Package: openakc-shared" > "${PDIR}/DEBIAN/control"
echo "Version: ${VERSION}-${BUILD}" >> "${PDIR}/DEBIAN/control"
echo "Maintainer: A. James Lewis <[email protected]>" >> "${PDIR}/DEBIAN/control"
echo "Depends: bash (>= 3.2), openssl (>= 0.9.8), coreutils, e2fsprogs" >> "${PDIR}/DEBIAN/control"
echo "Homepage: http://www.fsck.co.uk/openakc/" >> "${PDIR}/DEBIAN/control"
echo "Architecture: amd64" >> "${PDIR}/DEBIAN/control"
echo "Description: OpenAKC Shared Components" >> "${PDIR}/DEBIAN/control"
#
dpkg-deb --build "${PDIR}"
rm -fr "${PDIR}"
#
# Cleanup
#
cp *.deb "${ODIR}"
cd "${ODIR}" || exit 1
rm -fr "${BDIR}"