handle repos better
* add bootstrap repo * add fallback for all repos * make listing `https://` optional (http must be listed if applicable)
This commit is contained in:
parent
740d3efb5d
commit
48ad492117
1 changed files with 30 additions and 15 deletions
45
akshara
Executable file → Normal file
45
akshara
Executable file → Normal file
|
@ -142,37 +142,56 @@ def update_system():
|
||||||
|
|
||||||
info('downloading Arch tarball...')
|
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
|
# 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
|
# 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
|
arch_repo = blend_release.get("arch-repo")
|
||||||
bootstrap_mirror = 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 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')
|
warn('failed download')
|
||||||
print()
|
print()
|
||||||
info('trying download again...')
|
info('trying download again...')
|
||||||
print()
|
print()
|
||||||
exec('rm', '-f', '/.update.tar.zst')
|
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')
|
error('failed download')
|
||||||
print()
|
print()
|
||||||
error('update failed')
|
error('update failed')
|
||||||
sys.exit(50)
|
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')
|
error('failed checksum verification')
|
||||||
print()
|
print()
|
||||||
info('trying download again...')
|
info('trying download again...')
|
||||||
exec('rm', '-f', '/.update.tar.zst')
|
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')
|
error('failed download')
|
||||||
print()
|
print()
|
||||||
error('update failed')
|
error('update failed')
|
||||||
sys.exit(50)
|
sys.exit(50)
|
||||||
return
|
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')
|
error('failed checksum verification')
|
||||||
print()
|
print()
|
||||||
error('update failed')
|
error('update failed')
|
||||||
|
@ -239,12 +258,8 @@ def update_system():
|
||||||
pacman_mirrorlist_conf.write('nameserver 1.1.1.1\n')
|
pacman_mirrorlist_conf.write('nameserver 1.1.1.1\n')
|
||||||
|
|
||||||
with open('/.new_rootfs/etc/pacman.d/mirrorlist', 'w') as pacman_mirrorlist_conf:
|
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(
|
||||||
pacman_mirrorlist_conf.write(
|
f'Server = {arch_repo}/$repo/os/$arch\n')
|
||||||
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')
|
|
||||||
|
|
||||||
exec_chroot('mkdir', '-p', '/var/cache/pacman/pkg')
|
exec_chroot('mkdir', '-p', '/var/cache/pacman/pkg')
|
||||||
exec_chroot('rm', '-rf', '/var/cache/pacman/pkg')
|
exec_chroot('rm', '-rf', '/var/cache/pacman/pkg')
|
||||||
|
@ -284,7 +299,7 @@ def update_system():
|
||||||
pacman_conf.write(f'''
|
pacman_conf.write(f'''
|
||||||
[breakfast]
|
[breakfast]
|
||||||
SigLevel = Never
|
SigLevel = Never
|
||||||
Server = {blend_release['repo']}
|
Server = {repo}
|
||||||
''')
|
''')
|
||||||
|
|
||||||
if type(blend_release.get('package-repos')) == list:
|
if type(blend_release.get('package-repos')) == list:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue