/etc/kernel/postinst.d/apt-auto-removal creates comment with invalid # character

Bug #1076237 reported by Martin Pitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Fix Released
Undecided
Adam Conrad

Bug Description

/etc/kernel/postinst.d/apt-auto-removal does:

cat > "$config_file".dpkg-new <<EOF
# File autogenerated by $0, do not edit
APT
{
[...]

But apt does not seem to accept that. This is exposed by the current aptdaemon autopkgtest failure in https://jenkins.qa.ubuntu.com/view/Raring/view/AutoPkgTest/job/raring-adt-aptdaemon/lastFailedBuild/ARCH=i386,label=albali/ :

=====================================================================
ERROR: test_ (tests.test_configparser.ConfigurationParserTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tmp.dHacB3CTL5/dsc0-build/aptdaemon-0.45+bzr861/tests/test_configparser.py", line 63, in test_
    config = self.parser.parse(fd.readlines())
  File "/tmp/tmp.dHacB3CTL5/dsc0-build/aptdaemon-0.45+bzr861/aptdaemon/config.py", line 156, in parse
    raise Exception("Unknown char '%s' in: %s" % (char, line))
Exception: Unknown char '#' in: # File autogenerated by /etc/kernel/postinst.d/apt-auto-removal, do not edit

man apt.conf also just documents // and /* .. */ as valid comments, not #.

I think this apt script should be fixed to write a // comment instead of a # comment. Or should aptdaemon/apt accept # as well?

Revision history for this message
Martin Pitt (pitti) wrote :
tags: added: autopkgtest-failure raring
Adam Conrad (adconrad)
Changed in apt (Ubuntu):
assignee: nobody → Adam Conrad (adconrad)
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt - 0.9.7.6ubuntu3

---------------
apt (0.9.7.6ubuntu3) raring; urgency=low

  * Fix comment char in /etc/apt/apt.conf.d/01autoremove-kernels to
    use C++ style comments instead of POSIX shell style (LP: #1076237)
 -- Adam Conrad <email address hidden> Wed, 07 Nov 2012 23:10:35 -0700

Changed in apt (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
David Kalnischkies (donkult) wrote :

Just for the record: APT really supports # as comments as a convenience:

apt (0.7.22) unstable; urgency=low

  * [ABI break] support '#' in apt.conf and /etc/apt/preferences
    (closes: #189866)

 -- Michael Vogt <email address hidden> Wed, 29 Jul 2009 19:16:22 +0200

I really don't get why everyone thinks config file parsing is so damn cool that it must be reimplemented everywhere. I guess I have to try it some time. Sounds like a lot of fun.
Unnecessary to mention that aptdaemon will fail on other for-APT-valid config files also, like these including #clear option; and this time there is not even an excuse as this syntax is present since ever. Even though it might be hard to give a valid excuse provided the copyright year of config.py is 2010 … Oh dear …

My python is to limited, but from a first look it seems like it incorporates quiet a few issues like parsing/editing files which aren't parsed by APT (e.g. config.dpkg-new), #clear, #include, #-comments, …

(yes, I know that aptdaemon "needs" it to rewrite the configuration file as nobody has implemented it in libapt-pkg – properly because it sounds like so much fun – but I still don't get why because you could just append a new line to file to set a different value …)

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.