← Back to team overview

curtin-dev team mailing list archive

[Merge] ~ogayot/curtin:sources-displace into curtin:master

 

Olivier Gayot has proposed merging ~ogayot/curtin:sources-displace into curtin:master.

Commit message:
apt-config: avoid APT complaints about sources backup files

Before apt-config makes a change to ubuntu.sources or another source
file, it backs up the original file by appending the .curtin.old
extension.

However, by default, APT will emit a warning when a file with an unknown
extension is present in the etc/apt/sources.list.d directory. Currently,
known extensions are .sources and .list so when APT sees our .curtin.old
files, it does emit a warning.

 > N: Ignoring file 'ubuntu.sources.curtin.old' in directory
 '/etc/apt/sources.list.d/' as it has an invalid filename extension

Through Dir::Ignore-Files-Silently directives, APT can be configured to
ignore (i.e., not warn) some of the files that have unknown extensions.
By default, the list includes:

 Dir::Ignore-Files-Silently:: "\.disabled$";
 Dir::Ignore-Files-Silently:: "\.bak$";
 Dir::Ignore-Files-Silently:: "\.dpkg-[a-z]+$";
 Dir::Ignore-Files-Silently:: "\.ucf-[a-z]+$";
 Dir::Ignore-Files-Silently:: "\.save$";
 Dir::Ignore-Files-Silently:: "\.orig$";
 Dir::Ignore-Files-Silently:: "\.distUpgrade$";

We now back up the files using the .curtin.orig extension instead of
.curtin.old so that APT does not complain.

LP: #2058741

Signed-off-by: Olivier Gayot <olivier.gayot@xxxxxxxxxxxxx>

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #2058741 in curtin: "On a new desktop install apt complains about ubuntu.sources.curtin.old"
  https://bugs.launchpad.net/curtin/+bug/2058741

For more details, see:
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/462954

Before apt-config makes a change to ubuntu.sources or another source file, it backs up the original file by appending the .curtin.old extension.

However, by default, APT will emit a warning when a file with an unknown extension is present in the etc/apt/sources.list.d directory. Currently, known extensions are .sources and .list so when APT sees our .curtin.old files, it does emit a warning.

 > N: Ignoring file 'ubuntu.sources.curtin.old' in directory' /etc/apt/sources.list.d/' as it has an invalid filename extension

Through Dir::Ignore-Files-Silently directives, APT can be configured to ignore (i.e., not warn) some of the files that have unknown extensions. By default, the list includes:

 Dir::Ignore-Files-Silently:: "\.disabled$";
 Dir::Ignore-Files-Silently:: "\.bak$";
 Dir::Ignore-Files-Silently:: "\.dpkg-[a-z]+$";
 Dir::Ignore-Files-Silently:: "\.ucf-[a-z]+$";
 Dir::Ignore-Files-Silently:: "\.save$";
 Dir::Ignore-Files-Silently:: "\.orig$";
 Dir::Ignore-Files-Silently:: "\.distUpgrade$";

We now back up the files using the .curtin.orig extension instead of .curtin.old so that APT does not complain.
-- 
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:sources-displace into curtin:master.
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
index ce2cb75..d38cc4c 100644
--- a/curtin/commands/apt_config.py
+++ b/curtin/commands/apt_config.py
@@ -578,7 +578,7 @@ def _generate_sources_list_compat(
 
     orig = paths.target_path(target, aptsrc)
     if os.path.exists(orig):
-        os.rename(orig, orig + ".curtin.old")
+        os.rename(orig, orig + ".curtin.orig")
     util.write_file(paths.target_path(target, aptsrc), output, mode=0o644)
 
 
@@ -647,7 +647,7 @@ def _generate_sources_deb822(cfg, release, mirrors, target=None, arch=None):
 
     target_path = paths.target_path(target, sources_deb822)
     if os.path.exists(target_path):
-        os.rename(target_path, target_path + '.curtin.old')
+        os.rename(target_path, target_path + '.curtin.orig')
 
     output = '\n'.join(stanzas)
     util.write_file(target_path, output, mode=0o644)

Follow ups