关于Python-apt的使用

关于Python-apt的使用

我的目标是尽可能收集所有 Linux 发行版和所有体系结构中具有相同源代码的不同可执行文件,例如 amd64 和 i386 中的 Ubuntu 18.04 和 Debian 12,并且仅用于科学目的。

我不知道是否有任何巧妙的方法可以做到这一点,我目前正在尝试在 python-apt 中设置一个 source.list 缓存(以便其他人不会受到使用 apt 的影响),然后下载我以前的工作列出的包的可执行文件和源代码。

我的python-apt版本是2.4.0,当我运行下面的代码时,它显示GPG公钥错误;在我向源中添加'[trusted=yes]'之后,package_list没有'vim',似乎它没有缓存任何东西。

如果您能帮助我,我将不胜感激。此致。

with open('/home/etc/apt/source.list', 'w') as f:
    f.write('deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free \n')
cache = apt.Cache(rootdir=os.getcwd(), memonly=True)
# cache._run_fetcher(apt_pkg.Acquire(apt.progress.text.AcquireProgress()))
cache.update( sources_list='/tmp/source_2.list')
package_list = ['vim']  
print(cache.keys())
for package_name in package_list:
....

答案1

问题解决了,如果你遇到同样的问题,你可以试试这个:
记得检查'rootdir'是否包含你的sources.list

with open('/home/BinDiff/etc/apt/sources.list', 'w') as f:
    f.write('deb [trusted=yes] https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main ')

cache = apt.Cache(rootdir=os.getcwd(), memonly=True)
cache._run_fetcher(apt_pkg.Acquire(apt.progress.text.AcquireProgress()),allow_unauthenticated=True)

相关内容