From 7bc4e400cc38a22b5a5534c34f0b3cfc94f47680 Mon Sep 17 00:00:00 2001 From: Koen Serry <482723+koen-serry@users.noreply.github.com> Date: Fri, 17 Jul 2026 17:03:00 +0200 Subject: [PATCH 1/5] fix(debian): preserve vector.yaml as a conffile --- Cargo.toml | 5 ++- .../deb-conffile-examples-location.fix.md | 2 + distribution/debian/vector.yaml | 41 +++++++++++++++++++ scripts/verify-install.sh | 12 +++++- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 changelog.d/deb-conffile-examples-location.fix.md create mode 100644 distribution/debian/vector.yaml diff --git a/Cargo.toml b/Cargo.toml index 23b52c525ade9..a855e0a7997da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,11 +54,12 @@ workspace = true name = "vector" section = "admin" maintainer-scripts = "distribution/debian/scripts/" -conf-files = ["/etc/default/vector"] +conf-files = ["/etc/default/vector", "/etc/vector/vector.yaml"] assets = [ ["target/release/vector", "/usr/bin/", "755"], + ["distribution/debian/vector.yaml", "/etc/vector/vector.yaml", "644"], ["config/vector.yaml", "/usr/share/vector/examples/vector.yaml", "644"], - ["config/examples/*", "/etc/vector/examples/", "644"], + ["config/examples/*", "/usr/share/doc/vector/examples/", "644"], ["distribution/systemd/vector.service", "/lib/systemd/system/vector.service", "644"], ["distribution/systemd/vector.default", "/etc/default/vector", "600"], ["licenses/*", "/usr/share/vector/licenses/", "644"], diff --git a/changelog.d/deb-conffile-examples-location.fix.md b/changelog.d/deb-conffile-examples-location.fix.md new file mode 100644 index 0000000000000..1f65b2cf8a529 --- /dev/null +++ b/changelog.d/deb-conffile-examples-location.fix.md @@ -0,0 +1,2 @@ +Fixed two Debian packaging issues: `/etc/vector/vector.yaml` is now shipped as a proper Debian conffile (a stub with no active sources/sinks) so local modifications are preserved across upgrades; example configurations have been moved from `/etc/vector/examples/` to `/usr/share/doc/vector/examples/` where they belong as documentation rather than administrator-managed configuration. +authors: koenserry \ No newline at end of file diff --git a/distribution/debian/vector.yaml b/distribution/debian/vector.yaml new file mode 100644 index 0000000000000..b614de7902651 --- /dev/null +++ b/distribution/debian/vector.yaml @@ -0,0 +1,41 @@ +# __ __ __ +# \ \ / / / / +# \ V / / / +# \_/ \/ +# +# V E C T O R +# Configuration +# +# ------------------------------------------------------------------------------ +# Website: https://vector.dev +# Docs: https://vector.dev/docs +# Chat: https://chat.vector.dev +# ------------------------------------------------------------------------------ + +# Change this to use a non-default directory for Vector data storage: +# data_dir: "/var/lib/vector" + +# Example configurations are available at /usr/share/doc/vector/examples/ + +# Add your sources, transforms, and sinks here. +# See https://vector.dev/docs/reference/configuration/ for full reference. + +# sources: +# my_source: +# type: "..." + +# transforms: +# my_transform: +# type: "..." +# inputs: ["my_source"] + +# sinks: +# my_sink: +# type: "..." +# inputs: ["my_transform"] + +# Vector's API (disabled by default) +# Uncomment to try it out with the `vector top` command +# api: +# enabled: true +# address: "127.0.0.1:8686" diff --git a/scripts/verify-install.sh b/scripts/verify-install.sh index ab9e6039f3f14..92e2de5a8fe09 100755 --- a/scripts/verify-install.sh +++ b/scripts/verify-install.sh @@ -26,10 +26,18 @@ getent passwd vector || (echo "vector user missing" && exit 1) getent group vector || (echo "vector group missing" && exit 1) vector --version || (echo "vector --version failed" && exit 1) test -f /etc/default/vector || (echo "/etc/default/vector doesn't exist" && exit 1) -test ! -e /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should not be installed by default" && exit 1) test -f /usr/share/vector/examples/vector.yaml || (echo "/usr/share/vector/examples/vector.yaml doesn't exist" && exit 1) +case "$package" in + *.deb) + test -f /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should be installed by default" && exit 1) + test ! -d /etc/vector/examples || (echo "examples should not be installed under /etc/vector/examples" && exit 1) + test -f /usr/share/doc/vector/examples/stdio.yaml || (echo "/usr/share/doc/vector/examples/ examples missing" && exit 1) + ;; + *.rpm) + test ! -e /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml should not be installed by default" && exit 1) + ;; +esac -mkdir -p /etc/vector echo "FOO=bar" > /etc/default/vector echo "foo: bar" > /etc/vector/vector.yaml From 985902b9684321498201e2db226772561cbdfb25 Mon Sep 17 00:00:00 2001 From: Koen Serry <482723+koen-serry@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:53:30 +0200 Subject: [PATCH 2/5] fix(debian): preserve pre-existing vector.yaml when it becomes a conffile Since /etc/vector/vector.yaml was not a dpkg conffile before this change, a file already present at that path (created by a user, or by an older Vector package) is unknown to dpkg. Unpacking it as a new conffile makes dpkg treat it as "created by you" and stop at an interactive prompt, which breaks unattended upgrades without --force-confold/confnew. Add a preinst/postinst transition: preinst moves aside any untracked pre-existing file so dpkg can install the conffile without prompting, and postinst restores it afterwards so the content is preserved byte-for-byte. Once installed this way the path is a normal tracked conffile and standard dpkg conffile handling applies on later upgrades. Extend verify-install.sh to seed such an untracked file before the first install and assert it survives, since the existing verify path only reinstalled the same package and never exercised this transition. --- .../deb-conffile-examples-location.fix.md | 2 ++ distribution/debian/scripts/postinst | 8 ++++++++ distribution/debian/scripts/preinst | 17 +++++++++++++++++ scripts/verify-install.sh | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/changelog.d/deb-conffile-examples-location.fix.md b/changelog.d/deb-conffile-examples-location.fix.md index 1f65b2cf8a529..d8faf716f9f1e 100644 --- a/changelog.d/deb-conffile-examples-location.fix.md +++ b/changelog.d/deb-conffile-examples-location.fix.md @@ -1,2 +1,4 @@ Fixed two Debian packaging issues: `/etc/vector/vector.yaml` is now shipped as a proper Debian conffile (a stub with no active sources/sinks) so local modifications are preserved across upgrades; example configurations have been moved from `/etc/vector/examples/` to `/usr/share/doc/vector/examples/` where they belong as documentation rather than administrator-managed configuration. + +Since `/etc/vector/vector.yaml` was not previously a dpkg conffile, a pre-existing file at that path (created by a user, or by a Vector version prior to this fix) would otherwise make `dpkg` stop with an interactive "file created by you" conffile prompt, breaking unattended upgrades. Maintainer scripts now move any such untracked file aside before install and restore it afterwards, so upgrades complete without prompting and existing content is preserved byte-for-byte. authors: koenserry \ No newline at end of file diff --git a/distribution/debian/scripts/postinst b/distribution/debian/scripts/postinst index d20a3bc4cb52b..7a079d91b13d0 100755 --- a/distribution/debian/scripts/postinst +++ b/distribution/debian/scripts/postinst @@ -1,6 +1,14 @@ #!/bin/sh set -e +# Restore a pre-existing /etc/vector/vector.yaml that preinst moved aside +# (see preinst for why). This puts the user's original content back in +# place of the stub conffile dpkg just unpacked, so nothing is lost and no +# conffile prompt was ever shown. +if [ -e /etc/vector/vector.yaml.vector-preserve ]; then + mv -f /etc/vector/vector.yaml.vector-preserve /etc/vector/vector.yaml +fi + # Add Vector to adm group to read /var/logs usermod --append --groups adm vector || true diff --git a/distribution/debian/scripts/preinst b/distribution/debian/scripts/preinst index 373da4aad17ec..d1d07e903c345 100755 --- a/distribution/debian/scripts/preinst +++ b/distribution/debian/scripts/preinst @@ -12,4 +12,21 @@ mkdir -p /var/lib/vector # Make vector:vector the owner of the Vector data directory chown -R vector:vector /var/lib/vector +# /etc/vector/vector.yaml was not a dpkg conffile before this version. If a +# file already exists at that path, dpkg has no record of it and will treat +# it as "created by you", prompting interactively (or failing outright on +# unattended upgrades) before it will unpack the new conffile over it. Move +# any such untracked file out of the way so dpkg can install the conffile +# cleanly; postinst restores it afterwards so the user's content is kept +# byte-for-byte, without ever prompting. +case "$1" in + install|upgrade) + if [ -e /etc/vector/vector.yaml ] && [ ! -L /etc/vector/vector.yaml ]; then + if ! dpkg-query -W -f='${Conffiles}' vector 2>/dev/null | grep -q ' /etc/vector/vector.yaml '; then + mv /etc/vector/vector.yaml /etc/vector/vector.yaml.vector-preserve + fi + fi + ;; +esac + #DEBHELPER# diff --git a/scripts/verify-install.sh b/scripts/verify-install.sh index 92e2de5a8fe09..726acf85ee306 100755 --- a/scripts/verify-install.sh +++ b/scripts/verify-install.sh @@ -20,8 +20,27 @@ install_package () { esac } +case "$package" in + *.deb) + # Simulate a pre-existing /etc/vector/vector.yaml that predates this file + # being a dpkg conffile (e.g. a user-created file from before this fix, or + # an earlier Vector version that didn't ship one at all). Installing over + # it must not prompt (dpkg has no tty here, so a prompt would hang/fail + # this script) and must leave the user's content untouched. + mkdir -p /etc/vector + echo "unmanaged: pre-existing-config" > /etc/vector/vector.yaml + ;; +esac + install_package "$package" +case "$package" in + *.deb) + grep -q "unmanaged: pre-existing-config" /etc/vector/vector.yaml || \ + (echo "pre-existing, dpkg-untracked /etc/vector/vector.yaml was not preserved on install" && exit 1) + ;; +esac + getent passwd vector || (echo "vector user missing" && exit 1) getent group vector || (echo "vector group missing" && exit 1) vector --version || (echo "vector --version failed" && exit 1) From 80f61b88a3bfdc3cde9dd6d0d1481b6898909a3a Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 22 Jul 2026 10:06:36 -0400 Subject: [PATCH 3/5] fix(debian): add rm_conffile transitions for /etc/vector/examples/*.yaml --- distribution/debian/scripts/postinst | 23 +++++++++++++++++++++++ distribution/debian/scripts/preinst | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/distribution/debian/scripts/postinst b/distribution/debian/scripts/postinst index 7a079d91b13d0..04da2bd625dec 100755 --- a/distribution/debian/scripts/postinst +++ b/distribution/debian/scripts/postinst @@ -1,6 +1,29 @@ #!/bin/sh set -e +# Complete the rm_conffile transition started in preinst; see preinst for context. +for _example_conffile in \ + docs_example.yaml \ + environment_variables.yaml \ + es_s3_hybrid.yaml \ + file_to_cloudwatch_metrics.yaml \ + file_to_prometheus.yaml \ + http_sink_custom_retry.yaml \ + prometheus_to_console.yaml \ + stdio.yaml \ + varint_framing_protobuf.yaml \ + wrapped_json.yaml \ + namespacing/sinks/es_cluster.yaml \ + namespacing/sinks/s3_archives.yaml \ + namespacing/sources/apache_logs.yaml \ + namespacing/transforms/apache_parser.yaml \ + namespacing/transforms/apache_sample.yaml \ + namespacing/vector.yaml +do + dpkg-maintscript-helper rm_conffile \ + "/etc/vector/examples/$_example_conffile" 0.57.0 vector -- "$@" +done + # Restore a pre-existing /etc/vector/vector.yaml that preinst moved aside # (see preinst for why). This puts the user's original content back in # place of the stub conffile dpkg just unpacked, so nothing is lost and no diff --git a/distribution/debian/scripts/preinst b/distribution/debian/scripts/preinst index d1d07e903c345..f75fca120dcd1 100755 --- a/distribution/debian/scripts/preinst +++ b/distribution/debian/scripts/preinst @@ -1,6 +1,30 @@ #!/bin/sh set -e +# /etc/vector/examples/*.yaml were conffiles through v0.57.0; they moved to +# /usr/share/doc/vector/examples/. Remove unmodified copies on upgrade. +for _example_conffile in \ + docs_example.yaml \ + environment_variables.yaml \ + es_s3_hybrid.yaml \ + file_to_cloudwatch_metrics.yaml \ + file_to_prometheus.yaml \ + http_sink_custom_retry.yaml \ + prometheus_to_console.yaml \ + stdio.yaml \ + varint_framing_protobuf.yaml \ + wrapped_json.yaml \ + namespacing/sinks/es_cluster.yaml \ + namespacing/sinks/s3_archives.yaml \ + namespacing/sources/apache_logs.yaml \ + namespacing/transforms/apache_parser.yaml \ + namespacing/transforms/apache_sample.yaml \ + namespacing/vector.yaml +do + dpkg-maintscript-helper rm_conffile \ + "/etc/vector/examples/$_example_conffile" 0.57.0 vector -- "$@" +done + # Add vector:vector user & group id --user vector >/dev/null 2>&1 || \ useradd --system --shell /sbin/nologin --home-dir /var/lib/vector --user-group \ From 657e31940087ca7d1b7639eb080854f1fddd0105 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 22 Jul 2026 12:47:22 -0400 Subject: [PATCH 4/5] fix(debian): use 0.57.0-1 as rm_conffile prior-version --- distribution/debian/scripts/postinst | 2 +- distribution/debian/scripts/preinst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/debian/scripts/postinst b/distribution/debian/scripts/postinst index 04da2bd625dec..33eda4595cd45 100755 --- a/distribution/debian/scripts/postinst +++ b/distribution/debian/scripts/postinst @@ -21,7 +21,7 @@ for _example_conffile in \ namespacing/vector.yaml do dpkg-maintscript-helper rm_conffile \ - "/etc/vector/examples/$_example_conffile" 0.57.0 vector -- "$@" + "/etc/vector/examples/$_example_conffile" 0.57.0-1 vector -- "$@" done # Restore a pre-existing /etc/vector/vector.yaml that preinst moved aside diff --git a/distribution/debian/scripts/preinst b/distribution/debian/scripts/preinst index f75fca120dcd1..f0275dcc9b300 100755 --- a/distribution/debian/scripts/preinst +++ b/distribution/debian/scripts/preinst @@ -22,7 +22,7 @@ for _example_conffile in \ namespacing/vector.yaml do dpkg-maintscript-helper rm_conffile \ - "/etc/vector/examples/$_example_conffile" 0.57.0 vector -- "$@" + "/etc/vector/examples/$_example_conffile" 0.57.0-1 vector -- "$@" done # Add vector:vector user & group From bbd27f3a80c3da95cae50e45aa493f27a4eacc1c Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 22 Jul 2026 13:26:21 -0400 Subject: [PATCH 5/5] fix(debian): treat obsolete vector.yaml conffile entry as untracked --- distribution/debian/scripts/preinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/debian/scripts/preinst b/distribution/debian/scripts/preinst index f0275dcc9b300..7f5bed9f62cf7 100755 --- a/distribution/debian/scripts/preinst +++ b/distribution/debian/scripts/preinst @@ -46,7 +46,7 @@ chown -R vector:vector /var/lib/vector case "$1" in install|upgrade) if [ -e /etc/vector/vector.yaml ] && [ ! -L /etc/vector/vector.yaml ]; then - if ! dpkg-query -W -f='${Conffiles}' vector 2>/dev/null | grep -q ' /etc/vector/vector.yaml '; then + if ! dpkg-query -W -f='${Conffiles}' vector 2>/dev/null | grep -qE ' /etc/vector/vector\.yaml [0-9a-f]'; then mv /etc/vector/vector.yaml /etc/vector/vector.yaml.vector-preserve fi fi