Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sources.list link not handled #6

Open
Kunzol opened this issue Apr 22, 2018 · 3 comments
Open

sources.list link not handled #6

Kunzol opened this issue Apr 22, 2018 · 3 comments

Comments

@Kunzol
Copy link

Kunzol commented Apr 22, 2018

Does not work if /etc/apt/sources.list is a link.
It copies the link into the tar file, bot not the file, where the link points to.

This is mainly an issue if you change sources.list via a config package (built with the help of dh_configpackage).

While running the "clone" it prints this:

# apt-clone clone test
not installable: 
version mismatch: 
Note that you can use --with-dpkg-repack to include those packges in the clone file.

The info command on the generated tar file:

# apt-clone info test.apt-clone.tar.gz 
Traceback (most recent call last):
  File "/usr/local/bin/apt-clone", line 104, in <module>
    info = clone.info(args.source)
  File "/usr/local/lib/python2.7/dist-packages/apt_clone.py", line 375, in info
    "Date: %(date)s\n" % self._get_clone_info_dict(statefile)
  File "/usr/local/lib/python2.7/dist-packages/apt_clone.py", line 330, in _get_clone_info_dict
    distro = self._get_info_distro(statefile) or "unknown"
  File "/usr/local/lib/python2.7/dist-packages/apt_clone.py", line 319, in _get_info_distro
    f = tar.extractfile(self.TARPREFIX+"etc/apt/sources.list")
  File "/usr/lib/python2.7/tarfile.py", line 2154, in extractfile
    return self.extractfile(self._find_link_target(tarinfo))
  File "/usr/lib/python2.7/tarfile.py", line 2433, in _find_link_target
    raise KeyError("linkname %r not found" % linkname)
KeyError: "linkname './etc/apt/sources.list.test not found"

There are several solutions for this.

  1. add the link and the file the link points to.
    This could break the config package, which is installed by apt-clone on the new host.

  2. don't add the link at all
    The file would be handled by the config package which is installed on the new host by apt-clone, but requires that the config package is available without the sources.list from the clone host.

  3. add the linked file instead of the link
    The file will be overwritten by the config package on the new host, but it would break the purge of the config package, because config packages save the original file and restore it on purge.

  4. Handle the file according to the rules of "dh_configpackage"
    Use dpkg-divert --list /etc/apt/sources.list to check if the file is handled as diversion.
    Download the package and add it to the clone-tar-file and ignore /etc/apt/sources.list.
    On restore install the config package from the clone-tar first.

Example for diversion:

# dpkg-divert --list /etc/apt/sources.list
diversion of /etc/apt/sources.list to /etc/apt/sources.list.test-orig by test-repo
# dpkg-divert --listpackage /etc/apt/sources.list
test-repo
@ymartin59
Copy link

From my point of view, it is really unexpect /etc/apt/sources.list is a symbolic link (at worst, you should may replace by an hard link)... Managing repositories in /etc/apt/sources.list.d/ with .list or .list.bak file extensions is probably wiser.

@Kunzol
Copy link
Author

Kunzol commented Dec 17, 2019

If you use your own mirror you can not use /etc/apt/sources.list.d for this, because apt gives /etc/sources.list higher priority.

As I said, it is a common procedure to use dh_configpackage for replacing config files.
https://wiki.debian.org/ConfigPackages

Of course you can always develop your own procedure to do it.

@ymartin59
Copy link

@Kunzol Correct. My usage of apt sources may be "strange", here are my reasons:

  • I use Ansible to manage productive systems - so it is "easier" to add/remove a file in /etc/apt/sources.list.d when upgrading to major version
  • To avoid "priority" issue, I discard any line in /etc/sources.list (automate lines replacement in that file may lead to inconsistency)
  • On workstation, I run testing and may have to mix with unstable with package pining - again it is easier to have one file per Debian version in /etc/apt/sources.list.d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants