-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathbuilder.sh
executable file
·70 lines (55 loc) · 1.91 KB
/
builder.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
#!/bin/bash
# Wazuh indexer builder
# Copyright (C) 2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
set -e
# Script parameters to build the package
target="wazuh-indexer"
architecture=$1
revision=$2
future=$3
reference=$4
directory_base="/usr/share/wazuh-indexer"
if [ -z "${revision}" ]; then
revision="1"
fi
if [ "${future}" = "yes" ];then
version="99.99.0"
else
if [ "${reference}" ];then
version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${reference}/VERSION | cat)
else
version=$(cat /root/VERSION)
fi
fi
# Build directories
build_dir=/build
pkg_name="${target}-${version}"
pkg_path="${build_dir}/${target}"
source_dir="${pkg_path}/${pkg_name}"
mkdir -p ${source_dir}/debian
# Including spec file
if [ "${reference}" ];then
curl -sL https://github.com/wazuh/wazuh-packages/tarball/${reference} | tar zx
cp -r ./wazuh*/stack/indexer/deb/debian/* ${source_dir}/debian/
cp -r ./wazuh*/* /root/
else
cp -r /root/stack/indexer/deb/debian/* ${source_dir}/debian/
fi
# Generating directory structure to build the .deb package
cd ${build_dir}/${target} && tar -czf ${pkg_name}.orig.tar.gz "${pkg_name}"
# Configure the package with the different parameters
sed -i "s:VERSION:${version}:g" ${source_dir}/debian/changelog
sed -i "s:RELEASE:${revision}:g" ${source_dir}/debian/changelog
# Installing build dependencies
cd ${source_dir}
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y"
# Build package
debuild --no-lintian -eINSTALLATION_DIR="${directory_base}" -eVERSION="${version}" -eREVISION="${revision}" -b -uc -us
deb_file="${target}_${version}-${revision}_${architecture}.deb"
cd ${pkg_path} && sha512sum ${deb_file} > /tmp/${deb_file}.sha512
mv ${pkg_path}/${deb_file} /tmp/