#1109842 apt-daily-upgrade.service creates /etc/apt/sources.list

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Colin Watson
Date:
2025-10-26 14:51:01 UTC
Severity:
normal
Tags:
#1109842#5
Date:
2025-07-24 20:46:30 UTC
From:
To:
I upgraded one of my systems from bookworm to trixie recently, and ran
"apt modernize-sources" (followed by some minor tweaks).  I then noticed
etckeeper telling me that something had created an empty
/etc/apt/sources.list again, which seemed odd.  It's hard to tell
exactly what was responsible, but there is some circumstantial evidence:

  $ ls -l --full-time /etc/apt/sources.list
  -rw-r--r-- 1 root root 0 2025-07-24 06:07:13.083478056 +0100 /etc/apt/sources.list
  $ journalctl --since='2025-07-24 06:07:10' --until='2025-07-24 06:07:16'
  Jul 24 06:07:12 riva systemd[1]: Starting apt-daily-upgrade.service - Daily apt upgrade and clean activities...
  Jul 24 06:07:15 riva systemd[1]: apt-daily-upgrade.service: Deactivated successfully.
  Jul 24 06:07:15 riva systemd[1]: Finished apt-daily-upgrade.service - Daily apt upgrade and clean activities.
  Jul 24 06:07:15 riva systemd[1]: apt-daily-upgrade.service: Consumed 3.379s CPU time, 365.9M memory peak.

I couldn't immediately see which part of that service would be
responsible for this, but I'm guessing it's not behaviour you want.

Thanks,

#1109842#10
Date:
2025-10-09 12:58:16 UTC
From:
To:
I noticed the issue on trixie:

root@mail:~# ll /etc/apt/sources.list
-rw-r--r-- 1 root root 0 Oct  9 05:38 /etc/apt/sources.list

Oct 09 05:38:33 mail systemd[1]: Starting apt-daily.service - Daily apt download
activities...
Oct 09 05:38:36 mail systemd[1]: apt-daily.service: Deactivated successfully.
Oct 09 05:38:36 mail systemd[1]: Finished apt-daily.service - Daily apt download
activities.
Oct 09 05:38:36 mail systemd[1]: apt-daily.service: Consumed 3.044s CPU time,
159.9M memory peak.

It's however not trivially reproducible. Deleting the file and starting
apt-daily will not trigger file creation, so there's at least on other condition
needed for it to be created. It does happen every few days, FWIW.

I'm tending to say this is a policy 10.7.3 violation, but currently no real harm
is done other than causing noise in config management.

Greets,
Lee

#1109842#15
Date:
2025-10-13 10:03:34 UTC
From:
To:
This issue is caused by unattended-upgrade, and is 100% reproducible.
Reassigning as such.

root@mail:~# /usr/bin/unattended-upgrade -v
Checking if system is running on battery is skipped. Please install
powermgmt-base package to check power status and skip installing updates when
the system is running on battery.
Checking if connection is metered is skipped. Please install python3-gi package
to detect metered connections and skip downloading updates.
Starting unattended upgrades script
Allowed origins are: origin=Debian,codename=trixie,label=Debian,
origin=Debian,codename=trixie,label=Debian-Security,
origin=Debian,codename=trixie-security,label=Debian-Security
Initial blacklist:
Initial whitelist (not strict):
No packages found that can be upgraded unattended and no pending auto-removals
root@mail:~# ls -l /etc/apt/sources.list
-rw-r--r-- 1 root root 0 Oct 13 12:02 /etc/apt/sources.list

#1109842#34
Date:
2025-10-26 14:48:49 UTC
From:
To:
I have pinpointed the issue in python-apt and provided a fix in form of a MR at
https://salsa.debian.org/apt-team/python-apt/-/merge_requests/107

Let me know if anything is missing.