apt.conf man page should indicate # is also used for comments

Bug #1309658 reported by Stoyan Stoyanov
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

According to apt.conf(5) man page, the only valid comments in apt config files are:

"Lines starting with // are treated as comments (ignored), as well as all text between /* and */, just like C/C++ comments."

There are comments in debian/apt.conf.autoremove (/etc/apt/apt.conf.d/01autoremove) that start with '#' which breaks other tools like augeas that follow strictly the definition of comments in apt.conf's man page and rely on it to function properly.

1)
Description: Ubuntu 14.04 LTS
Release: 14.04

2) apt:
  Installed: 1.0.1ubuntu2
  Candidate: 1.0.1ubuntu2
  Version table:
 *** 1.0.1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status

The file can be patched by running:
$ sed -i "s/#/\/\//" apt.conf.autoremove

Tags: patch
Revision history for this message
David Kalnischkies (donkult) wrote :

As I implemented this years ago I am obviously biased, but I think not supporting "#" as a comment is a mistake as sources.list and preferences support it and most other config files you come across do comments with '#'. The autokernelremove code was an "external" contribution and it just shows that the default assumption is in fact '#'.
(all apt config files I have on my systems include #-comments btw, and I doubt I am the only one)
We should just document this fact properly instead of reverting support for it…

I wonder more why augeas is parsing our config file (but then again, I have no idea what augeas is). We have the apt-config tool to extract settings as well as python-apt, libapt-perl and libapt proper. Doing it on your own leads to a disaster sooner or later…
(just compare it with sources.list parsers… a simple codesearch reveals that most of them are fundamentally broken even in perfectly documented cases; but in most cases I have no idea why they they try to parse it in the first place…)

Revision history for this message
Stoyan Stoyanov (stoyansbg) wrote : Re: [Bug 1309658] Re: Invalid comments in debian/apt.conf.autoremove

I think that a single tool that allows you to edit various config files
preserving the validity of the syntax has its uses. Yes, it would be easier
to shoot yourself in the foot than if using the tools provided with the
distribution, but a single interface for changing name/value pairs in
different config files is priceless.

Anyway, documenting the ability to use '#' for comments in apt config files
should suffice. It will provide ground for pushing changes to other
projects parsing the apt config files.

Thanks,
Stoyan

On Fri, Apr 18, 2014 at 1:31 PM, David Kalnischkies <
<email address hidden>> wrote:

> As I implemented this years ago I am obviously biased, but I think not
> supporting "#" as a comment is a mistake as sources.list and preferences
> support it and most other config files you come across do comments with
> '#'. The autokernelremove code was an "external" contribution and it just
> shows that the default assumption is in fact '#'.
> (all apt config files I have on my systems include #-comments btw, and I
> doubt I am the only one)
> We should just document this fact properly instead of reverting support
> for it…
>
>
> I wonder more why augeas is parsing our config file (but then again, I
> have no idea what augeas is). We have the apt-config tool to extract
> settings as well as python-apt, libapt-perl and libapt proper. Doing it on
> your own leads to a disaster sooner or later…
> (just compare it with sources.list parsers… a simple codesearch reveals
> that most of them are fundamentally broken even in perfectly documented
> cases; but in most cases I have no idea why they they try to parse it in
> the first place…)
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1309658
>
> Title:
> Invalid comments in debian/apt.conf.autoremove
>
> Status in “apt” package in Ubuntu:
> New
>
> Bug description:
> According to apt.conf(5) man page, the only valid comments in apt
> config files are:
>
> "Lines starting with // are treated as comments (ignored), as well as
> all text between /* and */, just like C/C++ comments."
>
> There are comments in debian/apt.conf.autoremove
> (/etc/apt/apt.conf.d/01autoremove) that start with '#' which breaks
> other tools like augeas that follow strictly the definition of
> comments in apt.conf's man page and rely on it to function properly.
>
> 1)
> Description: Ubuntu 14.04 LTS
> Release: 14.04
>
> 2) apt:
> Installed: 1.0.1ubuntu2
> Candidate: 1.0.1ubuntu2
> Version table:
> *** 1.0.1ubuntu2 0
> 500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64
> Packages
> 100 /var/lib/dpkg/status
>
> The file can be patched by running:
> $ sed -i "s/#/\/\//" apt.conf.autoremove
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1309658/+subscriptions
>

Changed in apt (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
summary: - Invalid comments in debian/apt.conf.autoremove
+ apt.conf man page should indicate # is also used for comments
Revision history for this message
Dillon Brock (okay19) wrote :

Added a patch for this bug.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "add-comment-type-to-manpage.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Julian Andres Klode (juliank) wrote :

Thanks, @okay19, I have applied your patch in apt git. Sorry it took 5 1/2 years.

Changed in apt (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt - 2.3.7

---------------
apt (2.3.7) experimental; urgency=medium

  [ David Kalnischkies ]
  * Use full item description in broken repo error
  * Store size from volatile sources for already installed versions
  * Restore dpkg::chroot-directory functionality

  [ Dillon Brock ]
  * apt.conf(5): indicate # is also used for comments (LP: #1309658)

  [ Julian Andres Klode ]
  * Check sources.list could be parsed before adding volatile files
    (Closes: #990518)
  * pkgAcqIndex::CommonFailed: Set StatIdle before calling Init()
  * Implement exponential backoff between retries
    - acquire: Automatically reduce select() timeout as needed
    - Properly convert PulseInterval to timeval
    - Add support for a maximum delay and testing of delay
    - tests (retry-downloads): Avoid delay in second test

 -- Julian Andres Klode <email address hidden> Thu, 29 Jul 2021 16:59:39 +0200

Changed in apt (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.