Skip to content

Commit

Permalink
Added selector to use base in Debian builder, also removed lintian ch…
Browse files Browse the repository at this point in the history
…eck and added environment variables
  • Loading branch information
okynos committed Feb 9, 2022
1 parent 21954f1 commit 050e45b
Show file tree
Hide file tree
Showing 3 changed files with 981 additions and 963 deletions.
22 changes: 18 additions & 4 deletions stack/indexer/deb/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BUILD_DOCKER="yes"
DEB_AMD64_BUILDER="deb_indexer_builder_amd64"
DEB_BUILDER_DOCKERFILE="${CURRENT_PATH}/docker"
FUTURE="no"
BASE="s3"

trap ctrl_c INT

Expand Down Expand Up @@ -46,15 +47,19 @@ build_deb() {


# Build the Debian package with a Docker container
VOLUMES="-v ${OUTDIR}/:/tmp:Z"
if [ "${REFERENCE}" ];then
docker run -t --rm -v ${OUTDIR}/:/tmp:Z \
docker run -t --rm ${VOLUMES} \
${CONTAINER_NAME} ${ARCHITECTURE} ${REVISION} \
${FUTURE} ${REFERENCE} || return 1
${FUTURE} ${BASE} ${REFERENCE} || return 1
else
docker run -t --rm -v ${OUTDIR}/:/tmp:Z \
if [ "${BASE}" = "local" ];then
VOLUMES="${VOLUMES} -v ${CURRENT_PATH}/../base/output:/root/output:Z"
fi
docker run -t --rm ${VOLUMES} \
-v ${CURRENT_PATH}/../../..:/root:Z \
${CONTAINER_NAME} ${ARCHITECTURE} \
${REVISION} ${FUTURE} || return 1
${REVISION} ${FUTURE} ${BASE} || return 1
fi

echo "Package $(ls -Art ${OUTDIR} | tail -n 1) added to ${OUTDIR}."
Expand Down Expand Up @@ -88,6 +93,7 @@ help() {
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package x.30.0 Used for development purposes."
echo " --base <s3/local> [Optional] Base file location, use local or s3, default: s3"
echo " -h, --help Show this help."
echo
exit $1
Expand Down Expand Up @@ -133,6 +139,14 @@ main() {
FUTURE="yes"
shift 1
;;
"--base")
if [ -n "$2" ]; then
BASE="$2"
shift 2
else
help 1
fi
;;
"-s"|"--store")
if [ -n "$2" ]; then
OUTDIR="$2"
Expand Down
9 changes: 5 additions & 4 deletions stack/indexer/deb/builder.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Wazuh package builder
# Wazuh indexer builder
# Copyright (C) 2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
Expand All @@ -9,12 +9,14 @@
# Foundation.

set -ex

# Script parameters to build the package
target="wazuh-indexer"
architecture=$1
release=$2
future=$3
spec_reference=$4
base_location=$4
spec_reference=$5
directory_base="/usr/share/wazuh-indexer"

if [ -z "${release}" ]; then
Expand Down Expand Up @@ -54,14 +56,13 @@ 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" ${sources_dir}/debian/changelog
sed -i "s:RELEASE:${release}:g" ${sources_dir}/debian/changelog
sed -i "s:export INSTALLATION_DIR=.*:export INSTALLATION_DIR=${directory_base}:g" ${sources_dir}/debian/rules

# Installing build dependencies
cd ${sources_dir}
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y"

# Build package
debuild -b -uc -us
debuild --no-lintian -eINSTALLATION_DIR="${directory_base}" -eBASE="${base_location}" -eBASE_VERSION="${version}" -b -uc -us

deb_file="${target}_${version}-${release}_${architecture}.deb"

Expand Down
Loading

0 comments on commit 050e45b

Please sign in to comment.