tmp: add benchmarking for package building and installation
This commit is contained in:
parent
08c7a4d235
commit
c968609b60
1 changed files with 23 additions and 2 deletions
25
akshara
25
akshara
|
@ -25,7 +25,7 @@ import argparse
|
|||
import requests
|
||||
import fasteners
|
||||
import subprocess
|
||||
|
||||
from datetime import datetime
|
||||
__version = '1.0.0'
|
||||
|
||||
|
||||
|
@ -114,6 +114,8 @@ def interpret_track(blend_release):
|
|||
|
||||
|
||||
def update_system():
|
||||
benchmark = True
|
||||
|
||||
if os.path.isdir('/.update_rootfs'):
|
||||
error('update already downloaded, you must reboot first')
|
||||
sys.exit(75)
|
||||
|
@ -182,7 +184,11 @@ def update_system():
|
|||
|
||||
info('generating new system...')
|
||||
|
||||
before = datetime.now()
|
||||
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('rm', '-f', '/.new_rootfs/pkglist.x86_64.txt')
|
||||
exec('rm', '-f', '/.new_rootfs/version')
|
||||
|
@ -250,7 +256,9 @@ def update_system():
|
|||
exec_chroot('pacman-key', '--init')
|
||||
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('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"]}
|
||||
''')
|
||||
|
||||
before = datetime.now()
|
||||
counter = 0
|
||||
while True:
|
||||
return_val = exec_chroot('pacman', '-Syu', '--noconfirm')
|
||||
|
@ -287,9 +296,13 @@ Server = {package_repo["repo-url"]}
|
|||
exit(50)
|
||||
if return_val == 0:
|
||||
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')
|
||||
|
||||
before = datetime.now()
|
||||
counter = 0
|
||||
while True:
|
||||
print('running packages again')
|
||||
|
@ -300,6 +313,9 @@ Server = {package_repo["repo-url"]}
|
|||
exit(50)
|
||||
if return_val == 0:
|
||||
break
|
||||
after = datetime.now()
|
||||
if benchmark:
|
||||
print(f'[BENCH]: {(before - after).seconds} seconds to install packages')
|
||||
|
||||
counter = 0
|
||||
if aur_packages != []:
|
||||
|
@ -307,10 +323,14 @@ Server = {package_repo["repo-url"]}
|
|||
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')
|
||||
before = datetime.now()
|
||||
return_val = exec_chroot(
|
||||
'runuser', '-u', 'aur', '--', 'paru', '-Sy', '--noconfirm', '--needed',
|
||||
'--noprogressbar', '--skipreview', '--removemake', '--cleanafter', '--ask=4',
|
||||
*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('rm', '-f', '/etc/sudoers.d/aur')
|
||||
counter += 1
|
||||
|
@ -320,6 +340,7 @@ Server = {package_repo["repo-url"]}
|
|||
if return_val == 0:
|
||||
break
|
||||
|
||||
|
||||
for service in services:
|
||||
if type(service) is str:
|
||||
exec_chroot('systemctl', 'enable', service)
|
||||
|
|
Loading…
Reference in a new issue