From 5217023dcdfc77db03d6da1253bc06fb4bb6f1ce Mon Sep 17 00:00:00 2001
From: "Austin S. Hemmelgarn" <austin@netdata.cloud>
Date: Tue, 18 Jun 2024 08:43:02 -0400
Subject: [PATCH] Move to using CPack for repository configuration packages.
 (#17930)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Move to using CPack for repository configuration packages.

This simplifies testing of changes to the configuration itself, as well
as making package builds marginally faster.

* Fix CMake handling for old RPM distros.

* Fix openSUSE detection.

* Fix file installation.

* Override code ownership for packaging/repoconfig/CMakeLists.txt

This way changes won’t bother people who aren’t actually responsible for
it.

* Update CI skip logic to work correctly with new repoconfig setup.

* Add improved status messages.
---
 .github/CODEOWNERS                            |   1 +
 .github/scripts/package-upload.sh             |   3 +-
 .github/workflows/build-macos.yml             |   1 +
 .github/workflows/build.yml                   |   1 +
 .github/workflows/checks.yml                  |   1 +
 .github/workflows/docker.yml                  |   1 +
 .github/workflows/go-tests.yml                |   1 +
 .github/workflows/packaging.yml               |   1 +
 packaging/repoconfig/CMakeLists.txt           | 260 ++++++++++++++++++
 packaging/repoconfig/Makefile                 |  35 ---
 packaging/repoconfig/build-deb.sh             |  55 ++--
 packaging/repoconfig/build-rpm.sh             |  44 ++-
 .../{debian/changelog => deb.changelog}       |  18 +-
 packaging/repoconfig/debian/compat            |   1 -
 packaging/repoconfig/debian/control           |  19 --
 packaging/repoconfig/debian/copyright         |  10 -
 packaging/repoconfig/debian/rules             |  21 --
 packaging/repoconfig/debian/source/format     |   1 -
 packaging/repoconfig/netdata-edge.repo.al     |  21 --
 packaging/repoconfig/netdata-edge.repo.al2023 |  21 --
 packaging/repoconfig/netdata-edge.repo.centos |  21 --
 packaging/repoconfig/netdata-edge.repo.fedora |  21 --
 packaging/repoconfig/netdata-edge.repo.ol     |  21 --
 packaging/repoconfig/netdata-edge.repo.suse   |  19 --
 packaging/repoconfig/netdata-repo.spec        | 126 ---------
 packaging/repoconfig/netdata.list.in          |   4 +-
 packaging/repoconfig/netdata.repo.al2023      |  21 --
 packaging/repoconfig/netdata.repo.centos      |  21 --
 .../{netdata.repo.al => netdata.repo.dnf}     |   4 +-
 packaging/repoconfig/netdata.repo.fedora      |  21 --
 packaging/repoconfig/netdata.repo.ol          |  21 --
 .../{netdata.repo.suse => netdata.repo.zypp}  |   4 +-
 packaging/repoconfig/rpm.changelog            |  12 +
 33 files changed, 357 insertions(+), 475 deletions(-)
 create mode 100644 packaging/repoconfig/CMakeLists.txt
 delete mode 100644 packaging/repoconfig/Makefile
 rename packaging/repoconfig/{debian/changelog => deb.changelog} (59%)
 delete mode 100644 packaging/repoconfig/debian/compat
 delete mode 100644 packaging/repoconfig/debian/control
 delete mode 100644 packaging/repoconfig/debian/copyright
 delete mode 100755 packaging/repoconfig/debian/rules
 delete mode 100644 packaging/repoconfig/debian/source/format
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.al
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.al2023
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.centos
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.fedora
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.ol
 delete mode 100644 packaging/repoconfig/netdata-edge.repo.suse
 delete mode 100644 packaging/repoconfig/netdata-repo.spec
 delete mode 100644 packaging/repoconfig/netdata.repo.al2023
 delete mode 100644 packaging/repoconfig/netdata.repo.centos
 rename packaging/repoconfig/{netdata.repo.al => netdata.repo.dnf} (68%)
 delete mode 100644 packaging/repoconfig/netdata.repo.fedora
 delete mode 100644 packaging/repoconfig/netdata.repo.ol
 rename packaging/repoconfig/{netdata.repo.suse => netdata.repo.zypp} (63%)
 create mode 100644 packaging/repoconfig/rpm.changelog

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index a05230df63..95116696f0 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -47,6 +47,7 @@ CMakeLists.txt @netdata/agent-sre @vkalintiris
 netdata.spec.in @netdata/agent-sre
 netdata-installer.sh @netdata/agent-sre
 packaging/version @netdatabot @netdata/agent-sre
+packaging/repoconfig/CMakelists.txt @netdata/agent-sre
 
 LICENSE.md @netdata/agent-sre @vkalintiris
 CHANGELOG.md @netdatabot @netdata/agent-sre
diff --git a/.github/scripts/package-upload.sh b/.github/scripts/package-upload.sh
index b4e432852a..9305ffa671 100755
--- a/.github/scripts/package-upload.sh
+++ b/.github/scripts/package-upload.sh
@@ -9,11 +9,12 @@ distro="${2}"
 arch="${3}"
 format="${4}"
 repo="${5}"
+pkg_src="${6:-./artifacts}"
 
 staging="${TMPDIR:-/tmp}/package-staging"
 prefix="/home/netdatabot/incoming/${repo}/"
 
-packages="$(find artifacts -name "*.${format}")"
+packages="$(find "${pkg_src}" -name "*.${format}")"
 
 mkdir -p "${staging}"
 
diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml
index 24c13150f3..d3bfa6d776 100644
--- a/.github/workflows/build-macos.yml
+++ b/.github/workflows/build-macos.yml
@@ -52,6 +52,7 @@ jobs:
           files_ignore: |
             netdata.spec.in
             **/*.md
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         env:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3c00192c29..cd48a63bc2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -75,6 +75,7 @@ jobs:
             packaging/*.checksums
           files_ignore: |
             **/*.md
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         env:
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 7c9486114b..2ddcd822be 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -59,6 +59,7 @@ jobs:
             packaging/*.checksums
           files_ignore: |
             **/*.md
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         env:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 6674b92ce5..0d22aee989 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -82,6 +82,7 @@ jobs:
             packaging/*.checksums
           files_ignore: |
             **/*.md
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         if: github.event_name != 'workflow_dispatch'
diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml
index ed8b881449..93596454b5 100644
--- a/.github/workflows/go-tests.yml
+++ b/.github/workflows/go-tests.yml
@@ -36,6 +36,7 @@ jobs:
           files_ignore: |
             **/*.md
             src/go/**/metadata.yaml
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         env:
diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml
index dcf6ee8c44..ebfba8072b 100644
--- a/.github/workflows/packaging.yml
+++ b/.github/workflows/packaging.yml
@@ -68,6 +68,7 @@ jobs:
             src/web/server/h2o/libh2o/
           files_ignore: |
             **/*.md
+            packaging/repoconfig/
       - name: List all changed files in pattern
         continue-on-error: true
         env:
diff --git a/packaging/repoconfig/CMakeLists.txt b/packaging/repoconfig/CMakeLists.txt
new file mode 100644
index 0000000000..65813460a0
--- /dev/null
+++ b/packaging/repoconfig/CMakeLists.txt
@@ -0,0 +1,260 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+cmake_minimum_required(VERSION 3.13.0...3.28)
+
+list(APPEND RHEL_DISTROS centos centos-stream rocky almalinux cloudlinux)
+list(APPEND SUSE_DISTROS opensuse-leap opensuse-tumbleweed)
+list(APPEND RPM_DISTROS rhel opensuse ol amzn fedora)
+list(APPEND DEB_DISTROS debian ubuntu)
+
+set(DEB_GPG_KEY_SOURCE "https://repo.netdata.cloud/netdatabot.gpg.key")
+
+set(PACKAGE_VERSION 3)
+set(PACKAGE_RELEASE 1)
+
+set(CPACK_THREADS 0)
+set(CPACK_STRIP_FILES NO)
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "netdata")
+set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
+set(CPACK_PACKAGING_INSTALL_PREFIX "/")
+set(CPACK_PACKAGE_VENDOR "Netdata Inc.")
+set(CPACK_COMPONENT_NETDATA-REPO_PACKAGE_DESCRIPTION "Configuration for the official Netdata Stable package repository.")
+set(CPACK_COMPONENT_NETDATA-REPO-EDGE_PACKAGE_DESCRIPTION "Configuration for the official Netdata Edge package repository.")
+
+project(netdata-repoconfig VERSION "${PACKAGE_VERSION}.${PACKAGE_RELEASE}"
+        DESCRIPTION "Repository configuration for Netdata’s official native packages."
+        HOMEPAGE_URL "https://www.netdata.cloud/"
+        LANGUAGES NONE)
+
+function(extract_release_item _variable _item)
+  if(DEFINED "${_variable}")
+    return()
+  endif()
+
+  if(DEFINED OS_RELEASE_FILE)
+  else()
+    message(CHECK_START "Searching for os-release file")
+    find_file(OS_RELEASE_FILE os-release PATHS /etc /lib /usr/lib NO_DEFAULT_PATH)
+    if(${OS_RELEASE_FILE} STREQUAL "OS_RELEASE_FILE-NOTFOUND")
+      message(CHECK_FAIL "failed")
+      message(FATAL_ERROR "Could not find os-release file")
+    endif()
+
+    message(CHECK_PASS "${OS_RELEASE_FILE}")
+  endif()
+
+  message(CHECK_START "Extracting ${_item} from ${OS_RELEASE_FILE}")
+  execute_process(COMMAND sh -c ". ${OS_RELEASE_FILE} && printf %s $${_item}"
+                  RESULT_VARIABLE _result
+                  OUTPUT_VARIABLE _output)
+
+  if(NOT ${_result} EQUAL 0)
+    message(CHECK_FAIL "failed to parse ${OS_RELEASE_FILE}")
+    return()
+  elseif(${_output} STREQUAL "")
+    message(CHECK_FAIL "variable ${_item} not defined in ${OS_RELEASE_FILE}")
+    return()
+  endif()
+
+  message(CHECK_PASS ${_output})
+  set(${_variable} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(require_command _variable _cmd)
+  if(DEFINED ${_variable})
+    return()
+  endif()
+
+  message(CHECK_START "Looking for ${_cmd}")
+
+  find_program(_result_${_cmd} ${_cmd})
+
+  if(${_result_${_cmd}} STREQUAL "_result_${_cmd}-NOTFOUND")
+    message(CHECK_FAIL "failed")
+    message(FATAL_ERROR "Unable to find required command: ${_cmd}")
+  endif()
+
+  message(CHECK_PASS "${_result_${_cmd}}")
+  set(${_variable} ${_result_${_cmd}} PARENT_SCOPE)
+endfunction()
+
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+  extract_release_item("DISTRO" ID)
+
+  if(NOT DEFINED DISTRO)
+    message(FATAL_ERROR "Failed to auto-detect distro ID")
+  endif()
+
+  extract_release_item(DISTRO_VERSION VERSION_ID)
+
+  if(NOT DEFINED DISTRO_VERSION)
+    message(FATAL_ERROR "Failed to auto-detect distro version ID.")
+  endif()
+else()
+  message(FATAL_ERROR "Repository configuration packages can only be built on Linux")
+endif()
+
+if(${DISTRO} IN_LIST RHEL_DISTROS)
+  set(DISTRO "rhel")
+elseif(${DISTRO} STREQUAL "opensuse-leap")
+  set(DISTRO "opensuse")
+elseif(${DISTRO} STREQUAL "opensuse-tumbleweed")
+  set(DISTRO "opensuse")
+  set(DISTRO_VERSION "tumbleweed")
+endif()
+
+if(${DISTRO} IN_LIST DEB_DISTROS)
+  extract_release_item(SUITE VERSION_CODENAME)
+
+  if(NOT DEFINED SUITE)
+    message(FATAL_ERROR "Failed to determine version codename")
+  endif()
+
+  require_command(DPKG dpkg)
+  require_command(CURL curl)
+  require_command(GPG gpg)
+
+  set(DIST_NAME ${DISTRO})
+  message(STATUS "Generating stable repository configuration for ${DISTRO} ${SUITE}")
+  set(VARIANT stable)
+  configure_file(netdata.list.in netdata.list @ONLY)
+  message(STATUS "Generating edge repository configuration for ${DISTRO} ${SUITE}")
+  set(VARIANT edge)
+  configure_file(netdata.list.in netdata-edge.list @ONLY)
+  message(STATUS "Preparing changelogs")
+  set(PKG_NAME netdata-repo)
+  file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/netdata-repo)
+  configure_file(deb.changelog netdata-repo/changelog @ONLY)
+  set(PKG_NAME netdata-repo-edge)
+  file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/netdata-repo-edge)
+  configure_file(deb.changelog netdata-repo-edge/changelog @ONLY)
+
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.list
+          DESTINATION etc/apt/sources.list.d
+          COMPONENT netdata-repo)
+  install(FILES ${CMAKE_BINARY_DIR}/netdata-edge.list
+          DESTINATION etc/apt/sources.list.d
+          COMPONENT netdata-repo-edge)
+
+  add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/netdatabot.gpg.key
+                     COMMENT "Fetch GPG key from ${DEB_GPG_KEY_SOURCE}"
+                     COMMAND ${CURL} -f -L -o ${CMAKE_BINARY_DIR}/netdatabot.gpg.key ${DEB_GPG_KEY_SOURCE})
+
+  add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/netdata.gpg
+                     COMMENT "Dearmor ${CMAKE_BINARY_DIR}/netdatabot.gpg.key"
+                     DEPENDS ${CMAKE_BINARY_DIR}/netdatabot.gpg.key
+                     COMMAND ${GPG} --dearmor --output ${CMAKE_BINARY_DIR}/netdata.gpg ${CMAKE_BINARY_DIR}/netdatabot.gpg.key)
+  add_custom_target(dearmor_gpg_key
+                    ALL
+                    COMMENT "Dearmor ${CMAKE_BINARY_DIR}/netdatabot.gpg.key"
+                    DEPENDS ${CMAKE_BINARY_DIR}/netdata.gpg)
+
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg
+          DESTINATION etc/apt/trusted.gpg.d
+          RENAME netdata-archive-keyring.gpg
+          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
+          COMPONENT netdata-repo)
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg
+          DESTINATION etc/apt/trusted.gpg.d
+          RENAME netdata-repoconfig-archive-keyring.gpg
+          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
+          COMPONENT netdata-repo)
+
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg
+          DESTINATION etc/apt/trusted.gpg.d
+          RENAME netdata-edge-archive-keyring.gpg
+          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
+          COMPONENT netdata-repo-edge)
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.gpg
+          DESTINATION etc/apt/trusted.gpg.d
+          RENAME netdata-repoconfig-archive-keyring.gpg
+          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
+          COMPONENT netdata-repo-edge)
+
+  set(CPACK_DEB_COMPONENT_INSTALL YES)
+  set(CPACK_DEBIAN_DEBUGINFO_PACKAGE NO)
+  set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS NO)
+  set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS YES)
+  set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+  set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Netdata Builder <bot@netdata.cloud>")
+  set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
+  set(CPACK_DEBIAN_PACKAGE_DEPENDS "debian-keyring, gnupg")
+  set(CPACK_DEBIAN_PACKAGE_SECTION "net")
+  set(CPACK_DEBIAN_PACKAGE_VERSION "${PACKAGE_VERSION}")
+  set(CPACK_DEBIAN_PACKAGE_RELEASE "${PACKAGE_RELEASE}")
+  set(CPACK_DEBIAN_NETDATA-REPO_PACKAGE_NAME "netdata-repo")
+  set(CPACK_DEBIAN_NETDATA-REPO-EDGE_PACKAGE_NAME "netdata-repo-edge")
+  set(CPACK_DEBIAN_NETDATA-REPO_PACKAGE_CONFLICTS "netdata-repo-edge")
+  set(CPACK_DEBIAN_NETDATA-REPO-EDGE_PACKAGE_CONFLICTS "netdata-repo")
+  set(CPACK_DEBIAN_NETDATA-REPO_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/netdata-repo/changelog")
+  set(CPACK_DEBIAN_NETDATA-REPO-EDGE_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/netdata-repo-edge/changelog")
+elseif(${DISTRO} IN_LIST RPM_DISTROS)
+  require_command(RPM rpm)
+
+  if(${RPM} STREQUAL "RPM-NOTFOUND")
+    message(FATAL_ERROR "Unable to find rpm, which is required for RPM package builds.")
+  endif()
+
+  set(REPO_CFG_PATH "yum.repos.d")
+  set(REPO_ID "dnf")
+  set(DIST_NAME "${DISTRO}")
+  set(DIST_VERSION "$releasever")
+
+  if(${DISTRO} STREQUAL "amzn")
+    set(DIST_NAME "amazonlinux")
+    if(${DISTRO_VERSION} VERSION_EQUAL 2)
+      # Nothing to do in this case, defaults work here.
+    elseif(${DISTRO_VERSION} VERSION_EQUAL 2023)
+      set(DIST_VERSION "2023")
+    else()
+      message(FATAL_ERROR "Unsupported version of Amazon Linux: ${DISTRO_VERSION}")
+    endif()
+  elseif(${DISTRO} STREQUAL "opensuse")
+    set(REPO_CFG_PATH "zypp/repos.d")
+    set(REPO_ID "zypp")
+    set(DIST_NAME "opensuse")
+  elseif(${DISTRO} STREQUAL "rhel")
+    set(DIST_NAME "el")
+
+    if(${DISTRO_VERSION} VERSION_LESS_EQUAL 8)
+      set(CPACK_RPM_PACKAGE_REQUIRES "yum-plugin-priorities, epel-release")
+    else()
+      set(CPACK_RPM_PACKAGE_REQUIRES "epel-release")
+    endif()
+  endif()
+
+  message(STATUS "Generating stable repository configuration for ${DISTRO} ${DISTRO_VERSION}")
+  set(VARIANT stable)
+  configure_file(netdata.repo.${REPO_ID} netdata.repo @ONLY)
+  message(STATUS "Generating edge repository configuration for ${DISTRO} ${DISTRO_VERSION}")
+  set(VARIANT edge)
+  configure_file(netdata.repo.${REPO_ID} netdata-edge.repo @ONLY)
+
+  install(FILES ${CMAKE_BINARY_DIR}/netdata.repo
+          COMPONENT netdata-repo
+          DESTINATION etc/${REPO_CFG_PATH})
+  install(FILES ${CMAKE_BINARY_DIR}/netdata-edge.repo
+          COMPONENT netdata-repo-edge
+          DESTINATION etc/${REPO_CFG_PATH})
+
+  set(CPACK_RPM_COMPONENT_INSTALL ON)
+  set(CPACK_RPM_PACAKGE_AUTOREQPROV OFF)
+  set(CPACK_RPM_DEBUGINFO_PACKAGE OFF)
+  set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
+  set(CPACK_RPM_PACKAGE_GROUP "System Environment/Base")
+  set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "")
+  set(CPACK_RPM_PACKAGE_ARCHITECTURE "noarch")
+  set(CPACK_RPM_PACKAGE_VERSION "${PACKAGE_VERSION}")
+  set(CPACK_RPM_PACKAGE_RELEASE "${PACKAGE_RELEASE}")
+  set(CPACK_RPM_PACKAGE_CHANGELOG "${CMAKE_SOURCE_DIR}/rpm.changelog")
+  set(CPACK_RPM_NETDATA-REPO_FILE_NAME "netdata-repo-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.rpm")
+  set(CPACK_RPM_NETDATA-REPO_PACKAGE_NAME "netdata-repo")
+  set(CPACK_RPM_NETDATA-REPO_PACAKGE_CONFLICTS "netdata-repo-edge")
+  set(CPACK_RPM_NETDATA-REPO-EDGE_FILE_NAME "netdata-repo-edge-${PACKAGE_VERSION}-${PACKAGE_RELEASE}.rpm")
+  set(CPACK_RPM_NETDATA-REPO-EDGE_PACKAGE_NAME "netdata-repo-edge")
+  set(CPACK_RPM_NETDATA-REPO-EDGE_PACKAGE_CONFLICTS "netdata-repo")
+else()
+  message(FATAL_ERROR "Unsupported distribution ${DISTRO} ${DISTRO_VERSION}")
+endif()
+
+include(CPack)
diff --git a/packaging/repoconfig/Makefile b/packaging/repoconfig/Makefile
deleted file mode 100644
index 18b9887fe6..0000000000
--- a/packaging/repoconfig/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-FILES = netdata.list netdata-edge.list netdata-archive-keyring.gpg netdata-edge-archive-keyring.gpg netdata-repoconfig-archive-keyring.gpg
-
-all: $(FILES)
-
-netdata.list: netdata.list.in
-	cp netdata.list.in netdata.list
-	set -a && . /etc/os-release && sed -i -e "s/__DISTRO__/$${ID}/" -e "s/__SUITE__/$${VERSION_CODENAME}/" -e "s/__VARIANT__/stable/" netdata.list
-
-netdata-edge.list: netdata.list.in
-	cp netdata.list.in netdata-edge.list
-	set -a && . /etc/os-release && sed -i -e "s/__DISTRO__/$${ID}/" -e "s/__SUITE__/$${VERSION_CODENAME}/" -e "s/__VARIANT__/edge/" netdata-edge.list
-
-netdata.gpg.key:
-	curl -L https://repo.netdata.cloud/netdatabot.gpg.key > $@
-
-netdata-archive-keyring.gpg: netdata.gpg.key
-	gpg --dearmor > $@ < $<
-
-netdata-edge-archive-keyring.gpg: netdata.gpg.key
-	gpg --dearmor > $@ < $<
-
-netdata-repoconfig-archive-keyring.gpg: netdata.gpg.key
-	gpg --dearmor > $@ < $<
-
-debian/tmp:
-	mkdir -p $@
-
-install: $(FILES) debian/tmp
-	cp $(FILES) debian/tmp/
-
-clean:
-	rm -f $(FILES)
-
-.PHONY: clean
-.INTERMEDIATE: netdatabot.gpg.key
diff --git a/packaging/repoconfig/build-deb.sh b/packaging/repoconfig/build-deb.sh
index 97f929a68e..188d849cfe 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::"
 
-# 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
+echo "::group::Building Packages"
+cmake -S "${SRC_DIR}" -B "${BUILD_DIR}" -G Ninja
+cmake --build "${BUILD_DIR}"
 
-# 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
+cd "${BUILD_DIR}"
+cpack -G DEB
+echo "::endgroup::"
+
+[ -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"
diff --git a/packaging/repoconfig/build-rpm.sh b/packaging/repoconfig/build-rpm.sh
index 6c07c6619d..537b1524f9 100755
--- a/packaging/repoconfig/build-rpm.sh
+++ b/packaging/repoconfig/build-rpm.sh
@@ -1,26 +1,46 @@
 #!/bin/sh
 
-prefix='/root/rpmbuild'
+set -e
 
+SRC_DIR="$(CDPATH='' cd -- "$(dirname -- "${0}")" && pwd -P)"
+BUILD_DIR=/build
+
+echo "::group::Installing Build Dependencies"
 if command -v dnf > /dev/null ; then
     dnf distro-sync -y --nodocs || exit 1
-    dnf install -y --nodocs --setopt=install_weak_deps=False rpm-build || exit 1
+    dnf install -y --nodocs --setopt=install_weak_deps=False rpm-build cmake make || exit 1
 elif command -v yum > /dev/null ; then
     yum distro-sync -y || exit 1
-    yum install -y rpm-build || exit 1
+    yum install -y rpm-build make || exit 1
+    curl --fail -sSL --connect-timeout 20 --retry 3 --output "cmake-linux-$(uname -m).sh" "https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-$(uname -m).sh" && \
+    if [ "$(uname -m)" = "x86_64" ]; then \
+        echo '8c449dabb2b2563ec4e6d5e0fb0ae09e729680efab71527b59015131cea4a042  cmake-linux-x86_64.sh' | sha256sum -c - ; \
+    elif [ "$(uname -m)" = "aarch64" ]; then \
+        echo 'a83e01ed1cdf44c2e33e0726513b9a35a8c09e3b5a126fd720b3c8a9d5552368  cmake-linux-aarch64.sh' | sha256sum -c - ; \
+    else \
+        echo "ARCH NOT SUPPORTED BY CMAKE" ; \
+        exit 1 ; \
+    fi && \
+    chmod +x "./cmake-linux-$(uname -m).sh" && \
+    mkdir -p /cmake && \
+    "./cmake-linux-$(uname -m).sh" --skip-license --prefix=/cmake
+    PATH="/cmake/bin:${PATH}"
 elif command -v zypper > /dev/null ; then
     zypper update -y || exit 1
-    zypper install -y rpm-build || exit 1
-    prefix="/usr/src/packages"
+    zypper install -y rpm-build cmake make || exit 1
 fi
+echo "::endgroup::"
 
-mkdir -p "${prefix}/BUILD" "${prefix}/RPMS" "${prefix}/SRPMS" "${prefix}/SPECS" "${prefix}/SOURCES" || exit 1
-cp -a /netdata/packaging/repoconfig/netdata-repo.spec "${prefix}/SPECS" || exit 1
-cp -a /netdata/packaging/repoconfig/* "${prefix}/SOURCES/" || exit 1
+echo "::group::Building Packages"
+cmake -S "${SRC_DIR}" -B "${BUILD_DIR}"
+cmake --build "${BUILD_DIR}"
 
-rpmbuild -bb --rebuild "${prefix}/SPECS/netdata-repo.spec" || exit 1
+cd "${BUILD_DIR}"
+cpack -G RPM
+echo "::endgroup::"
 
-[ -d /netdata/artifacts ] || mkdir -p /netdata/artifacts
-find "${prefix}/RPMS/" -type f -name '*.rpm' -exec cp '{}' /netdata/artifacts \; || exit 1
+[ -d "${SRC_DIR}/artifacts" ] || mkdir -p "${SRC_DIR}/artifacts"
 
-chown -R --reference=/netdata /netdata/artifacts
+find "${BUILD_DIR}/packages/" -type f -name '*.rpm' -exec cp '{}' "${SRC_DIR}/artifacts" \; || exit 1
+
+chown -R --reference="${SRC_DIR}" "${SRC_DIR}/artifacts"
diff --git a/packaging/repoconfig/debian/changelog b/packaging/repoconfig/deb.changelog
similarity index 59%
rename from packaging/repoconfig/debian/changelog
rename to packaging/repoconfig/deb.changelog
index d056fa43ba..9d0f3ba751 100644
--- a/packaging/repoconfig/debian/changelog
+++ b/packaging/repoconfig/deb.changelog
@@ -1,25 +1,31 @@
-netdata-repo (2-2) unstable; urgency=medium
+@PKG_NAME@ (3-1) unstable; urgency=medium
+
+  * Migrate to CPack for package builds
+
+ -- Netdata Builder <bot@netdata.cloud>  Fri, 14 Jun 2024 08:22:00 -0400
+
+@PKG_NAME@ (2-2) unstable; urgency=medium
 
   * Version bump to keep in sync with RPM repo packages
 
  -- Netdata Builder <bot@netdata.cloud>  Mon, 13 Nov 2023 11:15:00 -0500
 
-netdata-repo (2-1) unstable; urgency=medium
+@PKG_NAME@ (2-1) unstable; urgency=medium
 
   * Switched to new package hosting infrastructure
   * Removed apt-transport-https requirement
 
  -- Netdata Builder <bot@netdata.cloud>  Wed, 18 Jan 2023 08:30:00 -0500
 
-netdata-repo (1-2) unstable; urgency=medium
+@PKG_NAME@ (1-2) unstable; urgency=medium
 
   * Fixed package file naming for repo layout compliance
 
- -- Netdata Builder <bot@netdata.cloud>  Mon, 6 Jun 2022 09:30:00 -0500
+ -- Netdata Builder <bot@netdata.cloud>  Mon, 6 Jun 2022 09:30:00 -0400
 
-netdata-repo (1-1) unstable; urgency=medium
+@PKG_NAME@ (1-1) unstable; urgency=medium
 
   * Initial Release
 
- -- Netdata Builder <bot@netdata.cloud>  Mon, 14 Jun 2021 08:00:00 -0500
+ -- Netdata Builder <bot@netdata.cloud>  Mon, 14 Jun 2021 08:00:00 -0400
 
diff --git a/packaging/repoconfig/debian/compat b/packaging/repoconfig/debian/compat
deleted file mode 100644
index ec635144f6..0000000000
--- a/packaging/repoconfig/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/packaging/repoconfig/debian/control b/packaging/repoconfig/debian/control
deleted file mode 100644
index fdea6a8293..0000000000
--- a/packaging/repoconfig/debian/control
+++ /dev/null
@@ -1,19 +0,0 @@
-Source: netdata-repo
-Section: net
-Priority: optional
-Maintainer: Netdata Builder <bot@netdata.cloud>
-Standards-Version: 3.9.6
-Build-Depends: debhelper (>= 9), curl, gnupg
-Homepage: https://netdata.cloud
-
-Package: netdata-repo
-Architecture: all
-Depends: debian-archive-keyring, gnupg
-Conflicts: netdata-repo-edge
-Description: Configuration for the official Netdata Stable package repository.
-
-Package: netdata-repo-edge
-Architecture:all
-Depends: debian-archive-keyring, gnupg
-Conflicts: netdata-repo
-Description: Configuration for the official Netdata Edge package repository.
diff --git a/packaging/repoconfig/debian/copyright b/packaging/repoconfig/debian/copyright
deleted file mode 100644
index 44b59693d1..0000000000
--- a/packaging/repoconfig/debian/copyright
+++ /dev/null
@@ -1,10 +0,0 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: Netdata
-Upstream-Contact: Costa Tsaousis <costa@netdata.cloud>
-Source: https://github.com/netdata/netdata
-
-Files: *
-Copyright: 2021-2023 Netdata Inc.
-License: GPL-3+
- On Debian systems, the complete text of the GNU General Public
- License version 3 can be found in /usr/share/common-licenses/GPL-3.
diff --git a/packaging/repoconfig/debian/rules b/packaging/repoconfig/debian/rules
deleted file mode 100755
index 0151b96ea4..0000000000
--- a/packaging/repoconfig/debian/rules
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/make -f
-
-TOP = $(CURDIR)/debian/netdata-repo
-TOP_EDGE = $(CURDIR)/debian/netdata-repo-edge
-TEMPTOP = $(CURDIR)/debian/tmp
-
-%:
-	dh $@
-
-override_dh_configure:
-	true
-
-override_dh_install:
-	mkdir -p $(TOP)/etc/apt/sources.list.d $(TOP)/etc/apt/trusted.gpg.d/
-	mv -f $(TEMPTOP)/netdata.list $(TOP)/etc/apt/sources.list.d
-	mv -f $(TEMPTOP)/netdata-archive-keyring.gpg $(TOP)/etc/apt/trusted.gpg.d
-	cp $(TEMPTOP)/netdata-repoconfig-archive-keyring.gpg $(TOP)/etc/apt/trusted.gpg.d
-	mkdir -p $(TOP_EDGE)/etc/apt/sources.list.d $(TOP_EDGE)/etc/apt/trusted.gpg.d/
-	mv -f $(TEMPTOP)/netdata-edge.list $(TOP_EDGE)/etc/apt/sources.list.d
-	mv -f $(TEMPTOP)/netdata-edge-archive-keyring.gpg $(TOP_EDGE)/etc/apt/trusted.gpg.d
-	cp $(TEMPTOP)/netdata-repoconfig-archive-keyring.gpg $(TOP_EDGE)/etc/apt/trusted.gpg.d
diff --git a/packaging/repoconfig/debian/source/format b/packaging/repoconfig/debian/source/format
deleted file mode 100644
index 163aaf8d82..0000000000
--- a/packaging/repoconfig/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/packaging/repoconfig/netdata-edge.repo.al b/packaging/repoconfig/netdata-edge.repo.al
deleted file mode 100644
index 4a300a26e7..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.al
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/amazonlinux/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/amazonlinux/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata-edge.repo.al2023 b/packaging/repoconfig/netdata-edge.repo.al2023
deleted file mode 100644
index 14290c5e43..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.al2023
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/amazonlinux/2023/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/amazonlinux/2023/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata-edge.repo.centos b/packaging/repoconfig/netdata-edge.repo.centos
deleted file mode 100644
index fd96f0d710..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.centos
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/el/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/el/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata-edge.repo.fedora b/packaging/repoconfig/netdata-edge.repo.fedora
deleted file mode 100644
index 03b0e9c7c5..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.fedora
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/fedora/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/fedora/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata-edge.repo.ol b/packaging/repoconfig/netdata-edge.repo.ol
deleted file mode 100644
index 89f74e712a..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.ol
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/ol/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/ol/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata-edge.repo.suse b/packaging/repoconfig/netdata-edge.repo.suse
deleted file mode 100644
index f65bd08d75..0000000000
--- a/packaging/repoconfig/netdata-edge.repo.suse
+++ /dev/null
@@ -1,19 +0,0 @@
-[netdata-edge]
-name=Netdata Edge
-baseurl=https://repo.netdata.cloud/repos/edge/opensuse/$releasever/$basearch
-repo_gpgcheck=1
-pkg_gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-type=rpm-md
-autorefresh=1
-
-[netdata-repoconfig]
-name=Netdata Repoconfig
-baseurl=https://repo.netdata.cloud/repos/repoconfig/opensuse/$releasever/$basearch
-repo_gpgcheck=1
-pkg_gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-type=rpm-md
-autorefresh=1
diff --git a/packaging/repoconfig/netdata-repo.spec b/packaging/repoconfig/netdata-repo.spec
deleted file mode 100644
index 64f7140e48..0000000000
--- a/packaging/repoconfig/netdata-repo.spec
+++ /dev/null
@@ -1,126 +0,0 @@
-%{?rhel:%global centos_ver %rhel}
-
-Name:           netdata-repo
-Version:        2
-Release:        3
-Summary:        Netdata stable repositories configuration.
-
-Group:          System Environment/Base
-License:        GPLv2
-
-Source0:        netdata.repo.fedora
-Source1:        netdata-edge.repo.fedora
-Source2:        netdata.repo.suse
-Source3:        netdata-edge.repo.suse
-Source4:        netdata.repo.centos
-Source5:        netdata-edge.repo.centos
-Source6:        netdata.repo.ol
-Source7:        netdata-edge.repo.ol
-Source8:        netdata.repo.al
-Source9:        netdata-edge.repo.al
-Source10:       netdata.repo.al2023
-Source11:       netdata-edge.repo.al2023
-
-BuildArch:      noarch
-
-%if 0%{?centos_ver} && 0%{?centos_ver} < 8
-Requires:       yum-plugin-priorities
-%endif
-
-%if 0%{?centos_ver} && 0%{!?amazon_linux:1} && 0%{!?oraclelinux:1}
-Requires:       epel-release
-%endif
-
-# Overlapping file installs
-Conflicts:      netdata-repo-edge
-
-%description
-This package contains the official Netdata package repository configuration for stable versions of Netdata.
-
-%prep
-%setup -q  -c -T
-
-%if 0%{?fedora}
-install -pm 644 %{SOURCE0} ./netdata.repo
-install -pm 644 %{SOURCE1} ./netdata-edge.repo
-%endif
-
-%if 0%{?suse_version}
-install -pm 644 %{SOURCE2} ./netdata.repo
-install -pm 644 %{SOURCE3} ./netdata-edge.repo
-%endif
-
-%if 0%{?centos_ver}
-install -pm 644 %{SOURCE4} ./netdata.repo
-install -pm 644 %{SOURCE5} ./netdata-edge.repo
-%endif
-
-%if 0%{?oraclelinux}
-install -pm 644 %{SOURCE6} ./netdata.repo
-install -pm 644 %{SOURCE7} ./netdata-edge.repo
-%endif
-
-%if 0%{?amzn2}
-install -pm 644 %{SOURCE8} ./netdata.repo
-install -pm 644 %{SOURCE9} ./netdata-edge.repo
-%endif
-
-%if 0%{?amzn2023}
-install -pm 644 %{SOURCE10} ./netdata.repo
-install -pm 644 %{SOURCE11} ./netdata-edge.repo
-%endif
-
-%build
-true
-
-%install
-rm -rf $RPM_BUILD_ROOT
-
-%if 0%{?suse_version}
-install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
-install -pm 644 netdata.repo $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
-install -pm 644 netdata-edge.repo $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d
-%else
-install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d
-install -pm 644 netdata.repo $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d
-install -pm 644 netdata-edge.repo $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d
-%endif
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%if 0%{?suse_version}
-%attr(644,root,root) /etc/zypp/repos.d/netdata.repo
-%else
-%attr(644,root,root) /etc/yum.repos.d/netdata.repo
-%endif
-
-%package edge
-Summary:   Netdata nightly repositories configuration.
-Group:     System Environment/Base
-
-# Overlapping file installs
-Conflicts: netdata-repo
-
-%description edge
-This package contains the official Netdata package repository configuration for nightly versions of Netdata.
-
-%files edge
-%if 0%{?suse_version}
-%attr(644,root,root) /etc/zypp/repos.d/netdata-edge.repo
-%else
-%attr(644,root,root) /etc/yum.repos.d/netdata-edge.repo
-%endif
-
-%changelog
-* Wed Apr 10 2024 Paul Szymanski <mail@pszy.de> 2-3
-- Fix repo specification for Amazon Linux 2023.
-* Mon Nov 13 2023 Austin Hemmelgarn <austin@netdata.cloud> 2-2
-- Add EPEL requirement for RHEL packages.
-* Wed Dec 7 2022 Austin Hemmelgarn <austin@netdata.cloud> 2-1
-- Switch to new hosting at repo.netdata.cloud.
-* Mon Jun 6 2022 Austin Hemmelgarn <austin@netdata.cloud> 1-2
-- Bump release to keep in sync with DEB package.
-* Mon Jun 14 2021 Austin Hemmelgarn <austin@netdata.cloud> 1-1
-- Initial revision
diff --git a/packaging/repoconfig/netdata.list.in b/packaging/repoconfig/netdata.list.in
index a49dbd91c8..b35ede441a 100644
--- a/packaging/repoconfig/netdata.list.in
+++ b/packaging/repoconfig/netdata.list.in
@@ -1,2 +1,2 @@
-deb http://repo.netdata.cloud/repos/__VARIANT__/__DISTRO__/ __SUITE__/
-deb http://repo.netdata.cloud/repos/repoconfig/__DISTRO__/ __SUITE__/
+deb http://repo.netdata.cloud/repos/@VARIANT@/@DIST_NAME@/ @SUITE@/
+deb http://repo.netdata.cloud/repos/repoconfig/@DIST_NAME@/ @SUITE@/
diff --git a/packaging/repoconfig/netdata.repo.al2023 b/packaging/repoconfig/netdata.repo.al2023
deleted file mode 100644
index 1fb446f00e..0000000000
--- a/packaging/repoconfig/netdata.repo.al2023
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata]
-name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/amazonlinux/2023/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/amazonlinux/2023/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata.repo.centos b/packaging/repoconfig/netdata.repo.centos
deleted file mode 100644
index 221e645136..0000000000
--- a/packaging/repoconfig/netdata.repo.centos
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata]
-name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/el/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/el/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata.repo.al b/packaging/repoconfig/netdata.repo.dnf
similarity index 68%
rename from packaging/repoconfig/netdata.repo.al
rename to packaging/repoconfig/netdata.repo.dnf
index 0bacb3a107..a8ab94a03f 100644
--- a/packaging/repoconfig/netdata.repo.al
+++ b/packaging/repoconfig/netdata.repo.dnf
@@ -1,6 +1,6 @@
 [netdata]
 name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/amazonlinux/$releasever/$basearch
+baseurl=https://repo.netdata.cloud/repos/@VARIANT@/@DIST_NAME@/@DIST_VERSION@/$basearch
 repo_gpgcheck=1
 gpgcheck=1
 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
@@ -11,7 +11,7 @@ priority=50
 
 [netdata-repoconfig]
 name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/amazonlinux/$releasever/$basearch
+baseurl=https://repo.netdata.cloud/repos/repoconfig/@DIST_NAME@/@DIST_VERSION@/$basearch
 repo_gpgcheck=1
 gpgcheck=1
 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
diff --git a/packaging/repoconfig/netdata.repo.fedora b/packaging/repoconfig/netdata.repo.fedora
deleted file mode 100644
index e13262acb9..0000000000
--- a/packaging/repoconfig/netdata.repo.fedora
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata]
-name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/fedora/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/fedora/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata.repo.ol b/packaging/repoconfig/netdata.repo.ol
deleted file mode 100644
index 0488670d4f..0000000000
--- a/packaging/repoconfig/netdata.repo.ol
+++ /dev/null
@@ -1,21 +0,0 @@
-[netdata]
-name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/ol/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
-
-[netdata-repoconfig]
-name=Netdata Repository Config
-baseurl=https://repo.netdata.cloud/repos/repoconfig/ol/$releasever/$basearch
-repo_gpgcheck=1
-gpgcheck=1
-gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
-enabled=1
-sslverify=1
-sslcacert=/etc/pki/tls/certs/ca-bundle.crt
-priority=50
diff --git a/packaging/repoconfig/netdata.repo.suse b/packaging/repoconfig/netdata.repo.zypp
similarity index 63%
rename from packaging/repoconfig/netdata.repo.suse
rename to packaging/repoconfig/netdata.repo.zypp
index 8204d8d4dc..9ab8473436 100644
--- a/packaging/repoconfig/netdata.repo.suse
+++ b/packaging/repoconfig/netdata.repo.zypp
@@ -1,6 +1,6 @@
 [netdata]
 name=Netdata
-baseurl=https://repo.netdata.cloud/repos/stable/opensuse/$releasever/$basearch
+baseurl=https://repo.netdata.cloud/repos/@VARIANT@/@DIST_NAME@/@DIST_VERSION@/$basearch
 repo_gpgcheck=1
 pkg_gpgcheck=1
 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
@@ -10,7 +10,7 @@ autorefresh=1
 
 [netdata-repoconfig]
 name=Netdata Repoconfig
-baseurl=https://repo.netdata.cloud/repos/repoconfig/opensuse/$releasever/$basearch
+baseurl=https://repo.netdata.cloud/repos/repoconfig/@DIST_NAME@/@DIST_VERSION@/$basearch
 repo_gpgcheck=1
 pkg_gpgcheck=1
 gpgkey=https://repo.netdata.cloud/netdatabot.gpg.key
diff --git a/packaging/repoconfig/rpm.changelog b/packaging/repoconfig/rpm.changelog
new file mode 100644
index 0000000000..5ae4aea056
--- /dev/null
+++ b/packaging/repoconfig/rpm.changelog
@@ -0,0 +1,12 @@
+* Fri Jun 14 2024 Austin Hemmelgarn <austin@netdata.cloud> 3-1
+- Migrate package build infrastructure to CPack.
+* Wed Apr 10 2024 Paul Szymanski <mail@pszy.de> 2-3
+- Fix repo specification for Amazon Linux 2023.
+* Mon Nov 13 2023 Austin Hemmelgarn <austin@netdata.cloud> 2-2
+- Add EPEL requirement for RHEL packages.
+* Wed Dec 7 2022 Austin Hemmelgarn <austin@netdata.cloud> 2-1
+- Switch to new hosting at repo.netdata.cloud.
+* Mon Jun 6 2022 Austin Hemmelgarn <austin@netdata.cloud> 1-2
+- Bump release to keep in sync with DEB package.
+* Mon Jun 14 2021 Austin Hemmelgarn <austin@netdata.cloud> 1-1
+- Initial revision