• Bug#1104628: apt-clone: "PermissionError" with new deb822 format for so

    From Fabio Cobianchi@21:1/5 to All on Sat May 3 12:50:01 2025
    Package: apt-clone
    Version: 0.4.3+nmu3
    Severity: normal
    X-Debbugs-Cc: cob@mailbox.org

    Dear Maintainer,

    I have updated my sources list with "apt modernize-sources";
    now I have the file "/etc/apt/sources.list.d/debian.sources" and the old "/etc/apt/sources.list" does not exists anymore.

    If I run the command "apt-clone clone test" it crashes with this error:

    Traceback (most recent call last):
    File "/usr/bin/apt-clone", line 108, in <module>
    clone.save_state(args.source, args.destination,
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    args.with_dpkg_repack, args.with_dpkg_status,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    extra_files=args.extra_files)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/apt_clone.py", line 154, in save_state
    self._write_state_installed_pkgs(sourcedir, tar)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/apt_clone.py", line 192, in _write_state_installed_pkgs
    cache = self._cache_cls(rootdir=sourcedir)
    File "/usr/lib/python3/dist-packages/apt/cache.py", line 149, in __init__
    self._check_and_create_required_dirs(rootdir)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/usr/lib/python3/dist-packages/apt/cache.py", line 191, in _check_and_create_required_dirs
    open(rootdir + f, "w").close()
    ~~~~^^^^^^^^^^^^^^^^^^
    PermissionError: [Errno 13] Permission denied: '//etc/apt/sources.list'


    I think apt-clone should be aware of the new format and not crash if a
    file is missing; ideally it should backup both files if present.

    Thanks


    -- System Information:
    Debian Release: trixie/sid
    APT prefers testing
    APT policy: (500, 'testing')
    Architecture: amd64 (x86_64)
    Foreign Architectures: i386

    Kernel: Linux 6.12.22-amd64 (SMP w/16 CPU threads; PREEMPT)
    Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    Versions of packages apt-clone depends on:
    ii lsb-release 12.1-1
    ii python3 3.13.3-1
    ii python3-apt 3.0.0

    Versions of packages apt-clone recommends:
    ii dpkg-repack 1.54

    apt-clone suggests no packages.

    -- no debconf information

    --
    Fabio Cobianchi
    cob@mailbox.org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)