Merge branch 'fix-arch-repo' into 'main'

Handle repos better

See merge request blendOS/system-tools/akshara!8
This commit is contained in:
Asterisk 2025-04-17 19:51:40 +00:00
commit 5bf806eea0

45
akshara Executable file → Normal file
View file

@ -142,37 +142,56 @@ def update_system():
info('downloading Arch tarball...')
# TODO: currently it errors if it doesn't have arch-repo anyways, so this doesn't need any extra checking, maybe add a check for that later though
# The mirror to use for downloading the bootstrap image
# For example, for the Arch mirror at mirrors.acm.wpi.edu, you'd use https://mirrors.acm.wpi.edu/archlinux
# Not sure why this wouldn't just use `arch-repo` but whatever
bootstrap_mirror = blend_release.get("arch-repo")
arch_repo = blend_release.get("arch-repo")
if type(arch_repo) != str:
# default arch and bootstrap repo
arch_repo = "geo.mirror.pkgbuild.com"
bootstrap_repo = blend_release.get("bootstrap-repo")
if type(bootstrap_repo) != str:
bootstrap_repo = arch_repo
# TODO: default to https if http/https isn't listed
# keeping disabled for consistency because i can't find `repo` to add it (and to add a fallback)
if not (arch_repo.startswith("https://") or arch_repo.startswith("http://")):
arch_repo = "https://" + arch_repo
if not (bootstrap_repo.startswith("https://") or bootstrap_repo.startswith("http://")):
bootstrap_repo = "https://" + bootstrap_repo
# same (fallback and https) for repo
repo = blend_release.get("repo")
if type(repo) != str:
repo = "https://pkg-repo.blendos.co"
elif not (repo.startswith("https://") or repo.startswith("http://")):
repo = "https://" + repo
if not os.path.isfile('/.update.tar.zst'):
if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
if exec('wget', '-q', '--show-progress', f'{bootstrap_repo}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
warn('failed download')
print()
info('trying download again...')
print()
exec('rm', '-f', '/.update.tar.zst')
if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
if exec('wget', '-q', '--show-progress', f'{bootstrap_repo}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
error('failed download')
print()
error('update failed')
sys.exit(50)
if exec('bash', '-c', f'sha256sum -c --ignore-missing <(wget -qO- {bootstrap_mirror}/iso/latest/sha256sums.txt | sed "s/archlinux-bootstrap-x86_64\\.tar\\.zst/.update.tar.zst/g") 2>/dev/null') != 0:
if exec('bash', '-c', f'sha256sum -c --ignore-missing <(wget -qO- {bootstrap_repo}/iso/latest/sha256sums.txt | sed "s/archlinux-bootstrap-x86_64\\.tar\\.zst/.update.tar.zst/g") 2>/dev/null') != 0:
error('failed checksum verification')
print()
info('trying download again...')
exec('rm', '-f', '/.update.tar.zst')
if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
if exec('wget', '-q', '--show-progress', f'{bootstrap_repo}/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0:
error('failed download')
print()
error('update failed')
sys.exit(50)
return
if exec('bash', '-c', f'sha256sum -c --ignore-missing <(wget -qO- {bootstrap_mirror}/iso/latest/sha256sums.txt | sed "s/archlinux-bootstrap-x86_64\\.tar\\.zst/.update.tar.zst/g") 2>/dev/null') != 0:
if exec('bash', '-c', f'sha256sum -c --ignore-missing <(wget -qO- {bootstrap_repo}/iso/latest/sha256sums.txt | sed "s/archlinux-bootstrap-x86_64\\.tar\\.zst/.update.tar.zst/g") 2>/dev/null') != 0:
error('failed checksum verification')
print()
error('update failed')
@ -239,12 +258,8 @@ def update_system():
pacman_mirrorlist_conf.write('nameserver 1.1.1.1\n')
with open('/.new_rootfs/etc/pacman.d/mirrorlist', 'w') as pacman_mirrorlist_conf:
if type(blend_release.get('arch-repo')) == str:
pacman_mirrorlist_conf.write(
f'Server = {blend_release.get("arch-repo")}/$repo/os/$arch\n')
else:
pacman_mirrorlist_conf.write(
'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch\n')
pacman_mirrorlist_conf.write(
f'Server = {arch_repo}/$repo/os/$arch\n')
exec_chroot('mkdir', '-p', '/var/cache/pacman/pkg')
exec_chroot('rm', '-rf', '/var/cache/pacman/pkg')
@ -284,7 +299,7 @@ def update_system():
pacman_conf.write(f'''
[breakfast]
SigLevel = Never
Server = {blend_release['repo']}
Server = {repo}
''')
if type(blend_release.get('package-repos')) == list: