Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aptsources822 lens for Deb822 style Apt sources #801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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]

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.

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?

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
2 participants