Skip to content

Conversation

@jvalleroy
Copy link
Contributor

We are using this lens in FreedomBox to add/remove "tor+" prefix to Apt sources URIs. Original commit: https://salsa.debian.org/freedombox-team/freedombox/-/commit/cd21c7f247135828e63379cc6d32a8edcb53a582

Closes: #297.

Signed-off-by: James Valleroy [email protected]

@georgehansper georgehansper self-assigned this Feb 1, 2023
@georgehansper
Copy link
Member

The lenses aptsources.aug and aptsources822.aug have overlapping definitions in the filter statement.
This results in an error because augeas can't determine which of the two lenses to apply. eg.

Error in /etc/apt/sources.list.d/man_examples.sources (mxfm_load)
Lenses @Aptsources822 and @Aptsources could be used to load this file

According to the man page for sources.list.d:

Filenames need to have either the extension .list or .sources depending on the contained format

This means that the existing lens should be limited to files named *.list, like this:

diff --git a/lenses/aptsources.aug b/lenses/aptsources.aug
index d7a6b3b1..e09634c7 100644
--- a/lenses/aptsources.aug
+++ b/lenses/aptsources.aug
@@ -60,7 +60,7 @@ module Aptsources =
 
   (* View: filter *)
   let filter = (incl "/etc/apt/sources.list")
-      . (incl "/etc/apt/sources.list.d/*")
+      . (incl "/etc/apt/sources.list.d/*.list")
       . Util.stdexcl

   let xfm = transform lns filter

Although this could be the subject of a separate PR, can I ask you to update this PR with the above change?

@georgehansper
Copy link
Member

The lens works well, and thank you in particular for including tests

Just one point, if I may: Each "paragraph" must be separated by a non-comment blank line
This is handled correctly by this lens.

Multiple blank lines are permitted between "paragraphs", as long as there is at least one blank line
Zero or more leading and trailing blank lines are permitted
Currently, extraneous blank lines like this are not handled by this lens

Could you please update the lens to allow leading, trailing and repeated blank lines?

SunilMohanAdapa and others added 2 commits September 9, 2025 13:21
The lens 'aptsources' parses the old, one-line style sources list. These files
must have .list as their extension[1]. On Debian 13 (Trixie) and newer systems,
the new Deb822 styled files are more common. They use .sources as their
extension. If the lens 'aptsources' tries to parse these newer files, it will
fail as the format is completely different. Users upgrading theirs systems to
Trixie will be prompted to upgrade the file format using simple command. So,
.sources files are more prevalent now.

Link: https://manpages.debian.org/trixie/apt/sources.list.5.en.html
Signed-off-by: Sunil Mohan Adapa <[email protected]>
We are using this lens in FreedomBox to add/remove "tor+" prefix to Apt sources
URIs. Original commit:
https://salsa.debian.org/freedombox-team/freedombox/-/commit/cd21c7f247135828e63379cc6d32a8edcb53a582

Closes: hercules-team#297.

[sunil: Handle DOS style line terminators for empty, comment, stanza lines]
[sunil: Allow leading, trailing and repeating empty lines]
[sunil: Don't allow spaces and tabs in empty lines separating stanzas]

Link: https://salsa.debian.org/apt-team/apt/-/blob/3c9399e643a07074d47c9bceca88e8d43ff55d36/apt-pkg/tagfile.cc#L585
Link: https://salsa.debian.org/apt-team/apt/-/blob/3c9399e643a07074d47c9bceca88e8d43ff55d36/apt-pkg/tagfile.cc#L580
Signed-off-by: James Valleroy <[email protected]>
Signed-off-by: Sunil Mohan Adapa <[email protected]>
@SunilMohanAdapa
Copy link

SunilMohanAdapa commented Sep 9, 2025

@georgehansper , Thank you for the review. I have collaborated with @jvalleroy in this MR and addressed all the review comments. Here are my changes:

  • aptsources: Limit filtering one-line style sources to *.list
  • Handle DOS style line terminators for empty, comment, stanza lines
  • Allow leading, trailing and repeating empty lines
  • Don't allow spaces and tabs in empty lines separating stanzas
  • Rebase onto current master branch for cleaner merge.

Please let me know if further changes are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lens to handle Deb822 formatted Apt sources: /etc/apt/sources.d/*.sources

3 participants