#1095441 wishlist: add a tool to validate sources.list and .sources files

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Lee Garrett
Date:
2025-02-25 19:06:01 UTC
Severity:
normal
#1095441#5
Date:
2025-02-07 23:34:15 UTC
From:
To:
Hi Julian,

when using configuration management tools like ansible it's nice to have a
method to validate a templated sources.list/.sources file before writing it to
it's final location, e.g.

apt-validate /tmp/tmp.ptsTUMNbEH/kubernetes.sources

All the tool needs to do is return zero when it parses fine, and one when
there's a syntax error.

tools like systemd, borgmatic, sshd, icinga2, etc. have similar options.

This would allow to use following task in ansible:

- name: Template .sources file
  template:
    src:        sources.j2
    dest:       /etc/apt/sources.list.d/{{ name }}.sources
    owner:      root
    group:      root
    mode:       "0644"
    validate:   '/usr/sbin/apt-validate %s'
  notify: apt update

in the case of an error the destination file never gets written, preventing apt
from breaking and requiring manual intervention.

Hope I could explain why it would be nice to have, let me know if you have any
questions.

Greets,
Lee

#1095441#10
Date:
2025-02-25 19:03:42 UTC
From:
To:
I'm not sure what that even means, tbh. Our parser is so lax that it's
more or less meaningless; you'll only get errors at update time when
it actually tries to use the sources.