Restructure to support dynamically assembly at build runtime (#199)
* restruture into dynamically assembled at build time * part 2 * ss * rename files * more * remove file --------- Co-authored-by: Meliox <na>
This commit is contained in:
1 parent
1f0078766d
commit
bfeeb94948
35 files changed
+217
-72
No files matched your search
@@ -37,13 +37,18 @@ jobs:
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y debhelper dpkg-dev
|
||||
|
||||
- name: Inject version into PVEMod_Config.pm
|
||||
- name: Inject version into Config.pm
|
||||
env:
|
||||
BUILD_VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
perl -i -pe 'BEGIN { $v = $ENV{BUILD_VERSION} }
|
||||
s/(our \$VERSION\s*=\s*'"'"')[^'"'"']*'"'"';/$1'"'"'$v'"'"';/
|
||||
' src/PVENodeInfo/PVEMod_Config.pm
|
||||
' src/node_info/files/Config.pm
|
||||
|
||||
- name: Generate dynamic debian rules
|
||||
run: |
|
||||
bash src/gen-rules.sh >> debian/rules
|
||||
bash src/gen-rules.sh conffiles >> debian/pve-mod.conffiles
|
||||
|
||||
- name: Build deb package
|
||||
run: |
|
||||
|
||||
@@ -31,18 +31,23 @@ jobs:
|
||||
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
||||
echo "Building version: $BUILD_VERSION"
|
||||
|
||||
- name: Inject version into PVEMod_Config.pm
|
||||
- name: Inject version into Config.pm
|
||||
run: |
|
||||
export BUILD_VERSION="${{ steps.version.outputs.build_version }}"
|
||||
perl -i -pe 'BEGIN { $v = $ENV{BUILD_VERSION} }
|
||||
s/(our \$VERSION\s*=\s*'"'"')[^'"'"']*'"'"';/$1'"'"'$v'"'"';/
|
||||
' src/PVENodeInfo/PVEMod_Config.pm
|
||||
' src/node_info/files/Config.pm
|
||||
|
||||
- name: Set package version in changelog
|
||||
run: |
|
||||
BUILD_VERSION="${{ steps.version.outputs.build_version }}"
|
||||
sed -i -E "0,/\(([^)]*)\)/s//(${BUILD_VERSION})/" debian/changelog
|
||||
|
||||
- name: Generate dynamic debian rules
|
||||
run: |
|
||||
bash src/gen-rules.sh >> debian/rules
|
||||
bash src/gen-rules.sh conffiles >> debian/pve-mod.conffiles
|
||||
|
||||
- name: Build package
|
||||
run: dpkg-buildpackage -us -uc -b
|
||||
|
||||
|
||||
@@ -49,14 +49,19 @@ jobs:
|
||||
- name: Install build deps
|
||||
run: sudo apt-get install -y devscripts debhelper build-essential
|
||||
|
||||
- name: Inject version into PVEMod_Config.pm
|
||||
- name: Inject version into Config.pm
|
||||
run: |
|
||||
VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/')
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
export BUILD_VERSION="${VERSION}-test-${SHORT_SHA}"
|
||||
perl -i -pe 'BEGIN { $v = $ENV{BUILD_VERSION} }
|
||||
s/(our \$VERSION\s*=\s*'"'"')[^'"'"']*'"'"';/$1'"'"'$v'"'"';/
|
||||
' src/PVENodeInfo/PVEMod_Config.pm
|
||||
' src/node_info/files/Config.pm
|
||||
|
||||
- name: Generate dynamic debian rules
|
||||
run: |
|
||||
bash src/gen-rules.sh >> debian/rules
|
||||
bash src/gen-rules.sh conffiles >> debian/pve-mod.conffiles
|
||||
|
||||
- name: Build package
|
||||
run: dpkg-buildpackage -us -uc -b
|
||||
|
||||
Vendored
-2
@@ -1,3 +1 @@
|
||||
/etc/pve-mod/pve-mod.conf
|
||||
/etc/pve-mod/conf.d/node_info.conf
|
||||
/etc/pve-mod/conf.d/nag_screen.conf
|
||||
Vendored
+15
-6
@@ -4,12 +4,21 @@ set -e
|
||||
DEFAULT_DIR="/usr/share/pve-mod"
|
||||
CONF_DIR="/etc/pve-mod"
|
||||
|
||||
# Config file pairs to compare on upgrade: "<default-file>|<user-file>"
|
||||
CONF_PAIRS="
|
||||
${DEFAULT_DIR}/pve-mod.conf.default|${CONF_DIR}/pve-mod.conf
|
||||
${DEFAULT_DIR}/conf.d/node_info.conf.default|${CONF_DIR}/conf.d/node_info.conf
|
||||
${DEFAULT_DIR}/conf.d/nag_screen.conf.default|${CONF_DIR}/conf.d/nag_screen.conf
|
||||
"
|
||||
# Build the list of config file pairs to compare on upgrade, one per line as
|
||||
# "<default-file>|<user-file>". The main config pair is fixed; per-module pairs
|
||||
# are auto-discovered from the reference copies under conf.d so adding a module
|
||||
# needs no edit here.
|
||||
_build_conf_pairs() {
|
||||
echo "${DEFAULT_DIR}/pve-mod.conf.default|${CONF_DIR}/pve-mod.conf"
|
||||
local default_conf base
|
||||
for default_conf in "${DEFAULT_DIR}"/conf.d/*.default; do
|
||||
[ -f "$default_conf" ] || continue
|
||||
base="${default_conf##*/}" # <mod>.conf.default
|
||||
base="${base%.default}" # <mod>.conf
|
||||
echo "${default_conf}|${CONF_DIR}/conf.d/${base}"
|
||||
done
|
||||
}
|
||||
CONF_PAIRS="$(_build_conf_pairs)"
|
||||
|
||||
# Extracts "section.key" pairs from an INI file, one per line.
|
||||
_extract_conf_keys() {
|
||||
|
||||
Vendored
+10
-58
@@ -3,74 +3,26 @@
|
||||
dh $@
|
||||
|
||||
override_dh_install:
|
||||
# PVE API2 facade
|
||||
install -Dm644 src/PVENodeInfo/PveMod_SensorInfo.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/API2/PVEMod_SensorInfo.pm
|
||||
# PVEMod core modules (strip PVEMod_ prefix)
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Config.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Config.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Utils.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Utils.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Store.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Store.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_ProcessManager.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/ProcessManager.pm
|
||||
# Collector plugins
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/Intel.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/Intel.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/Nvidia.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/Nvidia.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/Amd.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/Amd.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/LmSensors.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/LmSensors.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/Ups.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/Ups.pm
|
||||
install -Dm644 src/PVENodeInfo/PVEMod_Collectors/systemInformation.pm \
|
||||
debian/pve-mod/usr/share/perl5/PVE/PVEMod/Collector/SystemInformation.pm
|
||||
# JS module (rename to match loader reference)
|
||||
install -Dm644 src/PVENodeInfo/PveMod_pvemanagerlib.js \
|
||||
debian/pve-mod/usr/share/pve-manager/js/PveMod_PveNodeStatusView.js
|
||||
# ── Static section ─────────────────────────────────────────────────────
|
||||
# Generic, mod-independent files that never change when mods are added.
|
||||
# Everything mod-specific (module files, patches, per-mod configs) is
|
||||
# generated and appended below by src/gen-rules.sh at build time and is
|
||||
# NOT committed to the repository.
|
||||
#
|
||||
# Patch helpers (generic, manifest-driven)
|
||||
install -Dm755 src/Scripts/apply-patches.sh \
|
||||
debian/pve-mod/usr/lib/pve-mod/apply-patches.sh
|
||||
install -Dm755 src/Scripts/revert-patches.sh \
|
||||
debian/pve-mod/usr/lib/pve-mod/revert-patches.sh
|
||||
# node_info mod patches + manifest + hooks
|
||||
install -Dm644 src/PVENodeInfo/patches/patches.list \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/node_info/patches.list
|
||||
install -Dm644 src/PVENodeInfo/patches/01-nodes-pm-sensors.patch \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/node_info/01-nodes-pm-sensors.patch
|
||||
install -Dm644 src/PVENodeInfo/patches/02-nodes-pm-GPU-RRD-history.patch \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/node_info/02-nodes-pm-GPU-RRD-history.patch
|
||||
install -Dm644 src/PVENodeInfo/patches/03-pvemanager-js-sensors.patch \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/node_info/03-pvemanager-js-sensors.patch
|
||||
install -Dm755 src/PVENodeInfo/patches/post-apply.sh \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/node_info/post-apply.sh
|
||||
# nag_screen mod patches + manifest + hooks
|
||||
install -Dm644 src/NagScreen/patches/patches.list \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/nag_screen/patches.list
|
||||
install -Dm644 src/NagScreen/patches/01-proxmoxlib-js-nagscreen.patch \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/nag_screen/01-proxmoxlib-js-nagscreen.patch
|
||||
install -Dm755 src/NagScreen/patches/post-apply.sh \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/nag_screen/post-apply.sh
|
||||
install -Dm755 src/NagScreen/patches/post-revert.sh \
|
||||
debian/pve-mod/usr/lib/pve-mod/patches/nag_screen/post-revert.sh
|
||||
# Configure tool
|
||||
install -Dm755 src/Scripts/pve-mod-configure \
|
||||
debian/pve-mod/usr/sbin/pve-mod-configure
|
||||
# Main config (conffile for user edits)
|
||||
install -Dm644 src/pve-mod.conf \
|
||||
debian/pve-mod/etc/pve-mod/pve-mod.conf
|
||||
# Per-mod configs under conf.d (conffiles for user edits)
|
||||
install -Dm644 src/PVENodeInfo/node_info.conf \
|
||||
debian/pve-mod/etc/pve-mod/conf.d/node_info.conf
|
||||
install -Dm644 src/NagScreen/nag_screen.conf \
|
||||
debian/pve-mod/etc/pve-mod/conf.d/nag_screen.conf
|
||||
# Reference copies for upgrade key-diff (not conffiles — always updated)
|
||||
# Main config reference copy for upgrade key-diff (not a conffile)
|
||||
install -Dm644 src/pve-mod.conf \
|
||||
debian/pve-mod/usr/share/pve-mod/pve-mod.conf.default
|
||||
install -Dm644 src/PVENodeInfo/node_info.conf \
|
||||
debian/pve-mod/usr/share/pve-mod/conf.d/node_info.conf.default
|
||||
install -Dm644 src/NagScreen/nag_screen.conf \
|
||||
debian/pve-mod/usr/share/pve-mod/conf.d/nag_screen.conf.default
|
||||
# ── Dynamic section ────────────────────────────────────────────────────
|
||||
# `bash src/gen-rules.sh >> debian/rules` appends per-module install lines
|
||||
# here during CI, just before dpkg-buildpackage. Do not commit them.
|
||||
File renamed without changes.
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env bash
|
||||
# src/gen-rules.sh
|
||||
#
|
||||
# Generates the per-module portion of the Debian build configuration from each
|
||||
# module's metadata, so adding or changing a module never requires touching
|
||||
# debian/rules by hand.
|
||||
#
|
||||
# A module is any directory under src/ that contains a files/ and/or patches/
|
||||
# subdirectory (so src/Scripts/, which has neither, is ignored). The module's
|
||||
# directory name is its canonical mod key (matches the [modules] keys in
|
||||
# pve-mod.conf and the install path usr/lib/pve-mod/patches/<mod>/).
|
||||
#
|
||||
# Usage:
|
||||
# gen-rules.sh Emit dpkg install lines (tab-indented, no header).
|
||||
# Append to debian/rules' override_dh_install recipe:
|
||||
# bash src/gen-rules.sh >> debian/rules
|
||||
# gen-rules.sh conffiles Emit per-module conffile paths (one per line).
|
||||
# Append to debian/pve-mod.conffiles:
|
||||
# bash src/gen-rules.sh conffiles >> debian/pve-mod.conffiles
|
||||
#
|
||||
# For each module it emits, in order:
|
||||
# 1. files/files.list -> install each mapped file at its destination.
|
||||
# Format: <source> <destination> [permission]
|
||||
# (permission defaults to 644; source is relative to
|
||||
# the module's files/ directory).
|
||||
# 2. patches/* -> every file under patches/ recursively, including
|
||||
# patches.list and hook scripts. Shell scripts (.sh)
|
||||
# get mode 755, everything else 644. Installed under
|
||||
# usr/lib/pve-mod/patches/<mod>/<relative-path>.
|
||||
# 3. <mod>.conf -> if present in the module root, installed as a
|
||||
# conffile at etc/pve-mod/conf.d/<mod>.conf (644) plus
|
||||
# a reference copy at
|
||||
# usr/share/pve-mod/conf.d/<mod>.conf.default (644).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Resolve repository root from this script's location so paths are stable
|
||||
# regardless of the caller's working directory.
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
SRC_DIR="$REPO_ROOT/src"
|
||||
PKG_DIR="debian/pve-mod"
|
||||
|
||||
MODE="${1:-install}"
|
||||
|
||||
# Print the list of module directory names (basenames), sorted, that contain a
|
||||
# files/ or patches/ subdirectory.
|
||||
list_modules() {
|
||||
local d name
|
||||
for d in "$SRC_DIR"/*/; do
|
||||
[[ -d "$d" ]] || continue
|
||||
name="$(basename "$d")"
|
||||
if [[ -d "$d/files" || -d "$d/patches" ]]; then
|
||||
echo "$name"
|
||||
fi
|
||||
done | sort
|
||||
}
|
||||
|
||||
# Emit a single tab-indented `install -D` line.
|
||||
# Args: <mode> <relative-source> <relative-destination>
|
||||
emit_install() {
|
||||
printf '\tinstall -Dm%s %s %s/%s\n' "$1" "$2" "$PKG_DIR" "$3"
|
||||
}
|
||||
|
||||
emit_install_rules() {
|
||||
local mod="$1"
|
||||
local mod_dir="$SRC_DIR/$mod"
|
||||
local rel_mod="src/$mod"
|
||||
|
||||
# 1. Mapped files from files/files.list.
|
||||
local manifest="$mod_dir/files/files.list"
|
||||
if [[ -f "$manifest" ]]; then
|
||||
local src dest perm
|
||||
while read -r src dest perm; do
|
||||
# Tolerate CRLF line endings.
|
||||
src="${src%$'\r'}"; dest="${dest%$'\r'}"; perm="${perm%$'\r'}"
|
||||
# Skip comments and blank lines.
|
||||
[[ -z "${src:-}" || "$src" == \#* ]] && continue
|
||||
perm="${perm:-644}"
|
||||
emit_install "$perm" "$rel_mod/files/$src" "$dest"
|
||||
done < "$manifest"
|
||||
fi
|
||||
|
||||
# 2. Everything under patches/ (recursive): .sh -> 755, else 644.
|
||||
local patches_dir="$mod_dir/patches"
|
||||
if [[ -d "$patches_dir" ]]; then
|
||||
local f rel perm
|
||||
while IFS= read -r f; do
|
||||
rel="${f#"$patches_dir"/}"
|
||||
if [[ "$rel" == *.sh ]]; then
|
||||
perm=755
|
||||
else
|
||||
perm=644
|
||||
fi
|
||||
emit_install "$perm" "$rel_mod/patches/$rel" "usr/lib/pve-mod/patches/$mod/$rel"
|
||||
done < <(find "$patches_dir" -type f | sort)
|
||||
fi
|
||||
|
||||
# 3. Per-module config: conffile + reference default copy.
|
||||
local conf="$mod_dir/$mod.conf"
|
||||
if [[ -f "$conf" ]]; then
|
||||
emit_install 644 "$rel_mod/$mod.conf" "etc/pve-mod/conf.d/$mod.conf"
|
||||
emit_install 644 "$rel_mod/$mod.conf" "usr/share/pve-mod/conf.d/$mod.conf.default"
|
||||
fi
|
||||
}
|
||||
|
||||
emit_conffiles() {
|
||||
local mod="$1"
|
||||
if [[ -f "$SRC_DIR/$mod/$mod.conf" ]]; then
|
||||
echo "/etc/pve-mod/conf.d/$mod.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local mod
|
||||
case "$MODE" in
|
||||
install)
|
||||
for mod in $(list_modules); do
|
||||
emit_install_rules "$mod"
|
||||
done
|
||||
;;
|
||||
conffiles)
|
||||
for mod in $(list_modules); do
|
||||
emit_conffiles "$mod"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [install|conffiles]" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,10 @@
|
||||
# pve-mod :: nag_screen file manifest
|
||||
# Maps files in this directory to their installation destinations.
|
||||
# Format: <source> <destination> [permission]
|
||||
# source - path relative to this files/ directory
|
||||
# destination - path relative to the package root (no leading slash)
|
||||
# permission - octal mode, optional (defaults to 644)
|
||||
# Read by src/gen-rules.sh to generate the per-module debian install rules.
|
||||
#
|
||||
# The nag_screen mod ships no new files - it only patches existing Proxmox
|
||||
# files - so this manifest is intentionally empty.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
|
||||
# pve-mod :: node_info file manifest
|
||||
# Maps files in this directory to their installation destinations.
|
||||
# Format: <source> <destination> [permission]
|
||||
# source - path relative to this files/ directory
|
||||
# destination - path relative to the package root (no leading slash)
|
||||
# permission - octal mode, optional (defaults to 644)
|
||||
# Read by src/gen-rules.sh to generate the per-module debian install rules.
|
||||
|
||||
# PVE API2 facade
|
||||
PveMod_SensorInfo.pm usr/share/perl5/PVE/API2/PVEMod_SensorInfo.pm
|
||||
|
||||
# PVEMod core modules
|
||||
Config.pm usr/share/perl5/PVE/PVEMod/Config.pm
|
||||
Utils.pm usr/share/perl5/PVE/PVEMod/Utils.pm
|
||||
Store.pm usr/share/perl5/PVE/PVEMod/Store.pm
|
||||
ProcessManager.pm usr/share/perl5/PVE/PVEMod/ProcessManager.pm
|
||||
|
||||
# Collector plugins
|
||||
Collector/Intel.pm usr/share/perl5/PVE/PVEMod/Collector/Intel.pm
|
||||
Collector/Nvidia.pm usr/share/perl5/PVE/PVEMod/Collector/Nvidia.pm
|
||||
Collector/Amd.pm usr/share/perl5/PVE/PVEMod/Collector/Amd.pm
|
||||
Collector/LmSensors.pm usr/share/perl5/PVE/PVEMod/Collector/LmSensors.pm
|
||||
Collector/Ups.pm usr/share/perl5/PVE/PVEMod/Collector/Ups.pm
|
||||
Collector/systemInformation.pm usr/share/perl5/PVE/PVEMod/Collector/SystemInformation.pm
|
||||
|
||||
# JS module (rename to match loader reference)
|
||||
PveMod_pvemanagerlib.js usr/share/pve-manager/js/PveMod_PveNodeStatusView.js
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user