summaryrefslogtreecommitdiffstats
path: root/packaging/repoconfig/build-deb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/repoconfig/build-deb.sh')
-rwxr-xr-xpackaging/repoconfig/build-deb.sh55
1 files changed, 26 insertions, 29 deletions
diff --git a/packaging/repoconfig/build-deb.sh b/packaging/repoconfig/build-deb.sh
index 97f929a68..188d849cf 100755
--- a/packaging/repoconfig/build-deb.sh
+++ b/packaging/repoconfig/build-deb.sh
@@ -1,49 +1,46 @@
#!/bin/sh
-# Extract distro info from /etc/os-release
-DISTVERS="$(awk -F'"' '/VERSION_ID=/ {print $2}' /etc/os-release)"
-DISTNAME="$(awk -F'=' '/^ID=/ {print $2}' /etc/os-release)"
+set -e
+
+SRC_DIR="$(CDPATH='' cd -- "$(dirname -- "${0}")" && pwd -P)"
+BUILD_DIR=/build
+DISTRO="$(awk -F'=' '/^ID=/ {print $2}' /etc/os-release)"
+DISTRO_VERSION="$(awk -F'"' '/VERSION_ID=/ {print $2}' /etc/os-release)"
# Needed because dpkg is stupid and tries to configure things interactively if it sees a terminal.
export DEBIAN_FRONTEND=noninteractive
-# Pull in our dependencies
-apt update || exit 1
-apt upgrade -y || exit 1
-apt install -y build-essential debhelper curl gnupg || exit 1
+echo "::group::Installing Build Dependencies"
+apt update
+apt upgrade -y
+apt install -y --no-install-recommends ca-certificates cmake ninja-build curl gnupg
+echo "::endgroup::"
+
+echo "::group::Building Packages"
+cmake -S "${SRC_DIR}" -B "${BUILD_DIR}" -G Ninja
+cmake --build "${BUILD_DIR}"
-# Run the builds in an isolated source directory.
-# This removes the need for cleanup, and ensures anything the build does
-# doesn't muck with the user's sources.
-cp -a /netdata/packaging/repoconfig /usr/src || exit 1
-cd /usr/src/repoconfig || exit 1
+cd "${BUILD_DIR}"
+cpack -G DEB
+echo "::endgroup::"
-# pre/post options are after 1.18.8, is simpler to just check help for their existence than parsing version
-if dpkg-buildpackage --help | grep "\-\-post\-clean" 2> /dev/null > /dev/null; then
- dpkg-buildpackage --post-clean --pre-clean -b -us -uc || exit 1
-else
- dpkg-buildpackage -b -us -uc || exit 1
-fi
+[ -d "${SRC_DIR}/artifacts" ] || mkdir -p "${SRC_DIR}/artifacts"
# Embed distro info in package name.
-# This is required to make the repo actually standards compliant wthout packageclouds hacks.
-distid="${DISTNAME}${DISTVERS}"
-for pkg in /usr/src/*.deb; do
- pkgname="$(basename "${pkg}" .deb)"
+# This is required to make the repo actually standards compliant wthout packagecloud's hacks.
+distid="${DISTRO}${DISTRO_VERSION}"
+for pkg in "${BUILD_DIR}"/packages/*.deb; do
+ extension="${pkg##*.}"
+ pkgname="$(basename "${pkg}" "${extension}")"
name="$(echo "${pkgname}" | cut -f 1 -d '_')"
version="$(echo "${pkgname}" | cut -f 2 -d '_')"
arch="$(echo "${pkgname}" | cut -f 3 -d '_')"
- newname="$(dirname "${pkg}")/${name}_${version}+${distid}_${arch}.deb"
+ newname="${SRC_DIR}/artifacts/${name}_${version}+${distid}_${arch}${extension}"
mv "${pkg}" "${newname}"
done
-# Copy the built packages to /netdata/artifacts (which may be bind-mounted)
-# Also ensure /netdata/artifacts exists and create it if it doesn't
-[ -d /netdata/artifacts ] || mkdir -p /netdata/artifacts
-cp -a /usr/src/*.deb /netdata/artifacts/ || exit 1
-
# Correct ownership of the artifacts.
# Without this, the artifacts directory and it's contents end up owned
# by root instead of the local user on Linux boxes
-chown -R --reference=/netdata /netdata/artifacts
+chown -R --reference="${SRC_DIR}" "${SRC_DIR}/artifacts"