代码拉取完成,页面将自动刷新
#! /usr/bin/python3
import re
import shutil
from urllib.parse import urlparse, urlunparse
from urllib.request import urlopen
import apt
import apt_pkg
ARCH_TO_EFI_NAME = {
'amd64': 'x64',
'arm64': 'aa64',
}
arch = apt_pkg.config['Apt::Architecture']
efi_name = ARCH_TO_EFI_NAME[arch]
cache = apt.Cache()
grub_efi = cache["grub-efi-%s" % (arch)].candidate
pool_parsed = urlparse(grub_efi.uri)
dists_dir = "/dists/%s/main/uefi/grub2-%s/current/" % (
grub_efi.origins[0].archive, grub_efi.architecture)
for base in (
"gcd%s.efi.signed" % (efi_name),
"grub%s.efi.signed" % (efi_name),
"grubnet%s.efi.signed" % (efi_name),
"version",
):
dists_parsed = list(pool_parsed)
dists_parsed[2] = re.sub(r"/pool/.*", dists_dir + base, dists_parsed[2])
dists_uri = urlunparse(dists_parsed)
print("Downloading %s ..." % dists_uri)
with urlopen(dists_uri) as dists, open(base, "wb") as out:
shutil.copyfileobj(dists, out)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。