From bcf8abf874f7acf4e0ef036489a57994b22ea292 Mon Sep 17 00:00:00 2001 From: Asterisk Date: Sat, 15 Jun 2024 12:41:31 +0000 Subject: [PATCH 1/8] Change default mirror to geo.mirror.pkgbuild.com --- akshara | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akshara b/akshara index 685c272..d9a9e09 100755 --- a/akshara +++ b/akshara @@ -233,7 +233,7 @@ def update_system(): 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://cloudflaremirrors.com/archlinux/$repo/os/$arch\n') + pacman_mirrorlist_conf.write('Server = https://https://geo.mirror.pkgbuild.com/$repo/os/$arch\n') exec_chroot('mkdir', '-p', '/var/cache/pacman/pkg') exec_chroot('rm', '-rf', '/var/cache/pacman/pkg') From c47b5ff31633090862627a821ab7121b6889193b Mon Sep 17 00:00:00 2001 From: Asterisk Date: Sat, 15 Jun 2024 12:42:56 +0000 Subject: [PATCH 2/8] fix dual https:// --- akshara | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akshara b/akshara index d9a9e09..89f759f 100755 --- a/akshara +++ b/akshara @@ -233,7 +233,7 @@ def update_system(): 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://https://geo.mirror.pkgbuild.com/$repo/os/$arch\n') + pacman_mirrorlist_conf.write('Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch\n') exec_chroot('mkdir', '-p', '/var/cache/pacman/pkg') exec_chroot('rm', '-rf', '/var/cache/pacman/pkg') From 3175518459e71b2471410cdf610e764265cf993a Mon Sep 17 00:00:00 2001 From: Asterisk Date: Tue, 27 Aug 2024 21:27:57 +0000 Subject: [PATCH 3/8] Make akshara enable multilib --- akshara | 1 + 1 file changed, 1 insertion(+) diff --git a/akshara b/akshara index 89f759f..37fc2da 100755 --- a/akshara +++ b/akshara @@ -260,6 +260,7 @@ def update_system(): with open('/.new_rootfs/etc/pacman.conf', 'r') as original: data = original.read() with open('/.new_rootfs/etc/pacman.conf', 'w') as modified: modified.write(data.replace("[options]", "[options]\nParallelDownloads = 32\n")) + with open('/.new_rootfs/etc/pacman.conf', 'w') as modified: modified.write(data.replace("#[multilib]\n#Include = /etc/pacman.d/mirrorlist", "[multilib]\nInclude = /etc/pacman.d/mirrorlist")) with open('/.new_rootfs/etc/pacman.conf', 'a') as pacman_conf: pacman_conf.write(f''' From 5200aa18975c1ac7f19fe660c0ec1e3d99114359 Mon Sep 17 00:00:00 2001 From: Asterisk Date: Tue, 27 Aug 2024 21:35:41 +0000 Subject: [PATCH 4/8] Update file README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..14da333 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# akshara + +A simple system builder and immutability layer. + +## Development + +To test `akshara`, run the following on a working blendOS install: + +```sh +umount -l /usr && sudo mv ./akshara /usr/bin/akshara +``` + +Replace `./akshara` with wherever your modified copy of `akshara` is. \ No newline at end of file From 11b62648b12bc3ca6eb0b26d46de052d22b31297 Mon Sep 17 00:00:00 2001 From: Asterisk Date: Tue, 27 Aug 2024 21:36:37 +0000 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14da333..8776cc8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A simple system builder and immutability layer. ## Development -To test `akshara`, run the following on a working blendOS install: +To test a modified copy of `akshara`, run the following on a working blendOS install: ```sh umount -l /usr && sudo mv ./akshara /usr/bin/akshara From 4057162e15266a194721cdd1ce4801aa8dfb3cb8 Mon Sep 17 00:00:00 2001 From: Asterisk Date: Wed, 28 Aug 2024 00:23:28 +0000 Subject: [PATCH 6/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8776cc8..d2e7163 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A simple system builder and immutability layer. To test a modified copy of `akshara`, run the following on a working blendOS install: ```sh -umount -l /usr && sudo mv ./akshara /usr/bin/akshara +umount -l /usr && sudo mv ./akshara /usr/bin/akshara && sudo chmod +x /usr/bin/akshara ``` Replace `./akshara` with wherever your modified copy of `akshara` is. \ No newline at end of file From e2adf15f4272b0c40b25e33b65255c46db88ff58 Mon Sep 17 00:00:00 2001 From: Asterisk Date: Wed, 28 Aug 2024 00:41:45 +0000 Subject: [PATCH 7/8] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2e7163..1a1eb3f 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,6 @@ To test a modified copy of `akshara`, run the following on a working blendOS ins umount -l /usr && sudo mv ./akshara /usr/bin/akshara && sudo chmod +x /usr/bin/akshara ``` -Replace `./akshara` with wherever your modified copy of `akshara` is. \ No newline at end of file +Replace `./akshara` with wherever your modified copy of `akshara` is. + +⚠ **ANY CHANGES TO `/usr/bin/akshara` WILL BE REVERTED AFTER EVERY UPDATE!** ⚠ \ No newline at end of file From ed115df97982117d08d4357a78a9e30d5ab0332e Mon Sep 17 00:00:00 2001 From: askiiart Date: Tue, 1 Oct 2024 12:24:46 -0500 Subject: [PATCH 8/8] initial commit - switches to rate-mirrors, some minor updates, etc --- akshara | 62 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/akshara b/akshara index 37fc2da..2cd3f2f 100755 --- a/akshara +++ b/akshara @@ -19,15 +19,11 @@ import os import sys -import time import yaml -import shutil import filecmp import argparse import requests -import platform import fasteners -from threading import Event import subprocess __version = '1.0.0' @@ -136,34 +132,44 @@ def update_system(): with open('/system.yaml') as blend_release_file: blend_release = yaml.load( blend_release_file, Loader=yaml.FullLoader) + + + + # TODO: Add check that all packages actually exist 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") + if not os.path.isfile('/.update.tar.zst'): - if exec('wget', '-q', '--show-progress', 'https://geo.mirror.pkgbuild.com/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0: + if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/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', 'https://geo.mirror.pkgbuild.com/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0: + if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/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', 'sha256sum -c --ignore-missing <(wget -qO- https://geo.mirror.pkgbuild.com/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_mirror}/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', 'https://geo.mirror.pkgbuild.com/iso/latest/archlinux-bootstrap-x86_64.tar.zst', '-O', '/.update.tar.zst') != 0: + if exec('wget', '-q', '--show-progress', f'{bootstrap_mirror}/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', 'sha256sum -c --ignore-missing <(wget -qO- https://geo.mirror.pkgbuild.com/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_mirror}/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') @@ -196,9 +202,7 @@ def update_system(): 'blend-files' ] - keep = [ - '/usr/share' - ] + persistent_files = [] if (type(blend_release.get('impl')) == str and type(blend_release.get('track')) != 'custom'): @@ -224,6 +228,9 @@ def update_system(): if type(blend_release.get('user-services')) == list: user_services += blend_release.get('user-services') + if type(blend_release.get('persistent-files')) == list: + persistent_files += blend_release.get('persistent-files') + exec_chroot('rm', '-f', '/.new_rootfs/etc/resolv.conf') with open('/.new_rootfs/etc/resolv.conf', 'w') as pacman_mirrorlist_conf: @@ -243,17 +250,8 @@ def update_system(): exec_chroot('pacman-key', '--init') exec_chroot('pacman-key', '--populate') - counter = 0 - while True: - return_val = exec_chroot('pacman', '-Sy', '--ask=4', 'reflector') - counter += 1 - if counter > 30: - error('failed to download packages') - exit(50) - if return_val == 0: - break - - exec_chroot('reflector', '--latest', '5', '--protocol', 'https', '--sort', 'rate', '--save', '/etc/pacman.d/mirrorlist') + exec_chroot('sh', '-c', 'mkdir /tmp/rate-mirrors/; cd /tmp/rate-mirrors/; curl -LO $(curl -s https://api.github.com/repos/westandskif/rate-mirrors/releases/latest | grep "browser_download_url.*rate-mirrors-v.*-x86_64-unknown-linux-musl.tar.gz" | cut -d : -f 2,3 | tr -d \\")') + exec_chroot('bash', '-c', 'cd /tmp/rate-mirrors/; tar -xzf rate-mirrors*; cd $(find /tmp/rate-mirrors/ -mindepth 1 -maxdepth 1 -type d); ./rate_mirrors --disable-comments-in-file --entry-country=US --protocol=https arch --max-delay 7200 | sudo tee /etc/pacman.d/mirrorlist') #exec_chroot('sed', 's/#//g', '-i', '/etc/pacman.d/mirrorlist') #exec_chroot('bash', '-c', 'grep "^Server =" /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist.tmp; mv /etc/pacman.d/mirrorlist.tmp /etc/pacman.d/mirrorlist') @@ -293,6 +291,7 @@ Server = {package_repo["repo-url"]} counter = 0 while True: + print('running packages again') return_val = exec_chroot('pacman', '-S', '--ask=4', *packages) counter += 1 if counter > 30: @@ -304,6 +303,7 @@ Server = {package_repo["repo-url"]} counter = 0 if aur_packages != []: while True: + print('running aur_packages again') exec_chroot('useradd', '-m', '-G', 'wheel', '-s', '/bin/bash', 'aur') exec_chroot('bash', '-c', 'echo "aur ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aur') return_val = exec_chroot( @@ -327,6 +327,12 @@ Server = {package_repo["repo-url"]} if type(user_service) is str: exec_chroot('systemctl', 'enable', '--global', user_service) + for persistent_file in persistent_files: + if type(persistent_file) is str: + if os.path.exists(persistent_file): + exec('mkdir', '-p', '/.new_rootfs/'+ os.path.dirname(persistent_file)) + exec('cp', persistent_file, '/.new_rootfs/'+ persistent_file) + if type(blend_release.get('commands')) == list: for command in blend_release.get('commands'): if type(command) == str: @@ -403,7 +409,8 @@ Server = {package_repo["repo-url"]} exec('cp', '-ax', '/.new_rootfs/var/lib/pacman', '/.new.var.lib/pacman') exec('mv', '.new_rootfs', '.update_rootfs') - exec('cp', '-ax', '/.update_rootfs/etc', '/.update_rootfs/usr/etc') + # don't move /etc/shells to /usr/etc + exec('bash', '-c', 'shopt -s extglob; cd /.update_rootfs/etc; cp -ax !(shells) /.update_rootfs/usr/etc; cd -') new_boot_files = [] @@ -492,3 +499,10 @@ try: command() except KeyboardInterrupt: error('aborting') + # remove update and akshara stuff if the program is exited + exec('rm', '-rf', '/.new_rootfs/') + exec('rm', '-rf', '/.update_rootfs') + # it's basically impossible to ^C before akshara has exited but after it's created this file + # and i don't *think* that "update" would be destructive at all (unless it failed to run and would't boot), but i don't quite understand it soooo just to be on the safe side + exec('rm', '-f', '/.update') + # TODO: add similar handling for errors, and an option to not delete stuff on error/early exit