3

My server is hosted at OVH, and runs debian Buster. I ran apt-get update and apt-get upgrade last week without visible issue. But now I get an error message when I try to run it again:

sudo apt-get update
E: Syntax error /etc/apt/apt.conf.d/listchanges.conf:7: Extra junk at end of file

And the file itself looks clean:

[apt]
frontend=pager
email_address="root"
confirm=0
save_seen=/var/lib/apt/listchanges.db
which=both

I also tried to run unattended-upgrade -v -d --dry-run, which returns even more errors about apt configuration:

Traceback (most recent call last):
  File "/usr/bin/unattended-upgrade", line 75, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 34, in <module>
    apt_pkg.init_config()
apt_pkg.Error: E:Syntax error /etc/apt/apt.conf.d/listchanges.conf:7: Extra junk at end of file

How can I unlock this situation?

Thanks for your help!

3
  • 1
    Have you tried the following? It comes from man apt-listchanges: dpkg-reconfigure apt-listchanges
    – q.undertow
    Commented Oct 6, 2020 at 3:33
  • It returns: dpkg-query: package 'apt-listchanges' is not installed and no information is available Commented Oct 6, 2020 at 3:38
  • 1
    That may be a big part of the problem :-) Try apt-get install apt-listchanges. If that breaks, try just downloading the .deb file like curl -L -O http://deb.debian.org/debian/pool/main/a/apt-listchanges/apt-listchanges_3.19_all.deb, then install it manually with dpkg --install apt-listchanges_3.19_all.deb
    – q.undertow
    Commented Oct 6, 2020 at 4:10

1 Answer 1

4

I was able to reproduce your problem when I used your configuration file.

man apt-listchanges shows:

CONFIGURATION FILE
       apt-listchanges reads its configuration from the /etc/apt/listchanges.conf. The
       file consists of sections with names enclosed in the square brackets. Each section
       should contain lines in the key=value format. Lines starting with the "#" sign are
       treated as comments and ignored.

       Section is a name of profile that can be used as parameter of the --profile
       option.

       The configuration of the "apt" section can be managed by debconf(7), and most of
       the settings there can be changed with the help of the dpkg-reconfigure
       apt-listchanges command.

       Key is a name of some command-line option (except for --apt, --profile, --help)
       with the initial hyphens removed, and the remaining hyphens translated to
       underscores, for example: "email_format" or "save_seen".

       Value represents the value of the corresponding option. For command-line options
       that do not take argument, like "confirm" or "headers", the value should be set
       either to "1", "yes", "true", and "on" in order to enable the option, or to "0",
       "no", "false", and "off" to disable it.

       Additionally key can be one of the following keywords: "browser", "pager" or
       "xterm". The value of such configuration entry should be the name of an
       appropriate command, eventually followed by its arguments, for example:
       "pager=less -R".

       Example 1. Example configuration file

           [cmdline]
           frontend=pager

           [apt]
           frontend=xterm-pager
           email_address=root
           confirm=1

           [custom]
           frontend=browser
           browser=mozilla

       The above configuration file specifies that in command-line mode, the default
       frontend should be "pager". In apt mode, the xterm-pager frontend is default, a
       copy of the changelogs (if any) should be emailed to root, and apt-listchanges
       should ask for confirmation. If apt-listchanges is invoked with --profile=custom,
       the browser frontend will be used, and invoke mozilla.

The main thing is that you need to move /etc/apt/apt.conf.d/listchanges.conf to /etc/apt/listchanges.conf. Then things should work.

In case you're wondering why this mistake broke apt, the apt-listchanges (3.22) package deploys /etc/apt/apt.conf.d/20listchanges with the following content:

$ cat 20listchanges 
DPkg::Pre-Install-Pkgs { "/usr/bin/apt-listchanges --apt || test $? -lt 10"; };
DPkg::Tools::Options::/usr/bin/apt-listchanges::Version "2";
DPkg::Tools::Options::/usr/bin/apt-listchanges::InfoFD "20";

You can see that it isn't in the INI format that your file is in. man apt.conf describes the file-format needed by apt.conf. A raw translation of your content would yeild something like this:

Apt {
  frontend pager;
  email_address "root";
  confirm 0;
  save_seen /var/lib/apt/listchanges.db;
  which both;
};

If I change your file to this format, apt works again. That's because the file-format is respected. Probably this file doesn't do anything (because apt.conf isn't reading these keys), but at least that's how you'd write an apt.conf file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .