tmp: add benchmarking for package building and installation

This commit is contained in:
askiiart 2024-11-11 10:48:05 -06:00
parent 08c7a4d235
commit c968609b60
Signed by untrusted user who does not match committer: askiiart
GPG key ID: EA85979611654C30

25
akshara
View file

@ -25,7 +25,7 @@ import argparse
import requests import requests
import fasteners import fasteners
import subprocess import subprocess
from datetime import datetime
__version = '1.0.0' __version = '1.0.0'
@ -114,6 +114,8 @@ def interpret_track(blend_release):
def update_system(): def update_system():
benchmark = True
if os.path.isdir('/.update_rootfs'): if os.path.isdir('/.update_rootfs'):
error('update already downloaded, you must reboot first') error('update already downloaded, you must reboot first')
sys.exit(75) sys.exit(75)
@ -182,7 +184,11 @@ def update_system():
info('generating new system...') info('generating new system...')
before = datetime.now()
exec('tar', '--acls', '--xattrs', '-xf', '.update.tar.zst') exec('tar', '--acls', '--xattrs', '-xf', '.update.tar.zst')
after = datetime.now()
if benchmark:
print(f'[BENCH]: {(before - after).seconds} seconds to extract tarball')
exec('mv', 'root.x86_64', '.new_rootfs') exec('mv', 'root.x86_64', '.new_rootfs')
exec('rm', '-f', '/.new_rootfs/pkglist.x86_64.txt') exec('rm', '-f', '/.new_rootfs/pkglist.x86_64.txt')
exec('rm', '-f', '/.new_rootfs/version') exec('rm', '-f', '/.new_rootfs/version')
@ -250,7 +256,9 @@ def update_system():
exec_chroot('pacman-key', '--init') exec_chroot('pacman-key', '--init')
exec_chroot('pacman-key', '--populate') exec_chroot('pacman-key', '--populate')
# FIXME: If the GitHub API is down or something, this completely breaks # If the GitHub API is down or something, this completely breaks
# also it's broken currently and reflector is working now anyways soooooo
# commented out
#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 \\" | tr -d " ")') #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 \\" | 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 > /etc/pacman.d/mirrorlist') #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 > /etc/pacman.d/mirrorlist')
@ -278,6 +286,7 @@ SigLevel = Never
Server = {package_repo["repo-url"]} Server = {package_repo["repo-url"]}
''') ''')
before = datetime.now()
counter = 0 counter = 0
while True: while True:
return_val = exec_chroot('pacman', '-Syu', '--noconfirm') return_val = exec_chroot('pacman', '-Syu', '--noconfirm')
@ -287,9 +296,13 @@ Server = {package_repo["repo-url"]}
exit(50) exit(50)
if return_val == 0: if return_val == 0:
break break
after = datetime.now()
if benchmark:
print(f'[BENCH]: {(before - after).seconds} seconds to update packages')
exec('cp', '/etc/mkinitcpio.conf', '/.new_rootfs/etc/mkinitcpio.conf') exec('cp', '/etc/mkinitcpio.conf', '/.new_rootfs/etc/mkinitcpio.conf')
before = datetime.now()
counter = 0 counter = 0
while True: while True:
print('running packages again') print('running packages again')
@ -300,6 +313,9 @@ Server = {package_repo["repo-url"]}
exit(50) exit(50)
if return_val == 0: if return_val == 0:
break break
after = datetime.now()
if benchmark:
print(f'[BENCH]: {(before - after).seconds} seconds to install packages')
counter = 0 counter = 0
if aur_packages != []: if aur_packages != []:
@ -307,10 +323,14 @@ Server = {package_repo["repo-url"]}
print('running aur_packages again') print('running aur_packages again')
exec_chroot('useradd', '-m', '-G', 'wheel', '-s', '/bin/bash', 'aur') exec_chroot('useradd', '-m', '-G', 'wheel', '-s', '/bin/bash', 'aur')
exec_chroot('bash', '-c', 'echo "aur ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aur') exec_chroot('bash', '-c', 'echo "aur ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aur')
before = datetime.now()
return_val = exec_chroot( return_val = exec_chroot(
'runuser', '-u', 'aur', '--', 'paru', '-Sy', '--noconfirm', '--needed', 'runuser', '-u', 'aur', '--', 'paru', '-Sy', '--noconfirm', '--needed',
'--noprogressbar', '--skipreview', '--removemake', '--cleanafter', '--ask=4', '--noprogressbar', '--skipreview', '--removemake', '--cleanafter', '--ask=4',
*aur_packages) *aur_packages)
after = datetime.now()
if benchmark:
print(f'[BENCH]: {(before - after).seconds} seconds to install AUR packages')
exec_chroot('userdel', '-r', 'aur') exec_chroot('userdel', '-r', 'aur')
exec_chroot('rm', '-f', '/etc/sudoers.d/aur') exec_chroot('rm', '-f', '/etc/sudoers.d/aur')
counter += 1 counter += 1
@ -320,6 +340,7 @@ Server = {package_repo["repo-url"]}
if return_val == 0: if return_val == 0:
break break
for service in services: for service in services:
if type(service) is str: if type(service) is str:
exec_chroot('systemctl', 'enable', service) exec_chroot('systemctl', 'enable', service)