mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 08:44:15 +02:00
[aur] respecting BAUH_ARCH_OPTIMIZE when makepkg calls are executed
This commit is contained in:
@@ -10,3 +10,7 @@ CATEGORIES_FILE_PATH = CATEGORIES_CACHE_DIR + '/aur.txt'
|
|||||||
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/aur/categories.txt'
|
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/aur/categories.txt'
|
||||||
CONFIG_DIR = '{}/.config/bauh/arch'.format(HOME_PATH)
|
CONFIG_DIR = '{}/.config/bauh/arch'.format(HOME_PATH)
|
||||||
CUSTOM_MAKEPKG_PATH = '{}/makepkg.conf'.format(CONFIG_DIR)
|
CUSTOM_MAKEPKG_PATH = '{}/makepkg.conf'.format(CONFIG_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
def should_optimize_compilation() -> bool:
|
||||||
|
return bool(int(os.getenv('BAUH_ARCH_OPTIMIZE', 1)))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import re
|
|||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from bauh.commons.system import SimpleProcess, ProcessHandler
|
from bauh.commons.system import SimpleProcess, ProcessHandler
|
||||||
from bauh.gems.arch import CUSTOM_MAKEPKG_PATH
|
from bauh.gems.arch import CUSTOM_MAKEPKG_PATH, should_optimize_compilation
|
||||||
|
|
||||||
RE_DEPS_PATTERN = re.compile(r'\n?\s+->\s(.+)\n')
|
RE_DEPS_PATTERN = re.compile(r'\n?\s+->\s(.+)\n')
|
||||||
RE_UNKNOWN_GPG_KEY = re.compile(r'\(unknown public key (\w+)\)')
|
RE_UNKNOWN_GPG_KEY = re.compile(r'\(unknown public key (\w+)\)')
|
||||||
@@ -14,9 +14,12 @@ def check(pkgdir: str, handler: ProcessHandler) -> dict:
|
|||||||
|
|
||||||
cmd = ['makepkg', '-ALcf', '--check', '--noarchive', '--nobuild', '--noprepare']
|
cmd = ['makepkg', '-ALcf', '--check', '--noarchive', '--nobuild', '--noprepare']
|
||||||
|
|
||||||
if os.path.exists(CUSTOM_MAKEPKG_PATH):
|
if should_optimize_compilation():
|
||||||
handler.watcher.print('Using custom makepkg.conf -> {}'.format(CUSTOM_MAKEPKG_PATH))
|
if os.path.exists(CUSTOM_MAKEPKG_PATH):
|
||||||
cmd.append('--config={}'.format(CUSTOM_MAKEPKG_PATH))
|
handler.watcher.print('Using custom makepkg.conf -> {}'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
cmd.append('--config={}'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
else:
|
||||||
|
handler.watcher.print('Custom optimized makepkg.conf ( {} ) not found'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
|
||||||
success, output = handler.handle_simple(SimpleProcess(cmd, cwd=pkgdir))
|
success, output = handler.handle_simple(SimpleProcess(cmd, cwd=pkgdir))
|
||||||
|
|
||||||
@@ -37,9 +40,11 @@ def check(pkgdir: str, handler: ProcessHandler) -> dict:
|
|||||||
def make(pkgdir: str, handler: ProcessHandler) -> Tuple[bool, str]:
|
def make(pkgdir: str, handler: ProcessHandler) -> Tuple[bool, str]:
|
||||||
cmd = ['makepkg', '-ALcsmf']
|
cmd = ['makepkg', '-ALcsmf']
|
||||||
|
|
||||||
if os.path.exists(CUSTOM_MAKEPKG_PATH):
|
if should_optimize_compilation():
|
||||||
handler.watcher.print('Using custom makepkg.conf -> {}'.format(CUSTOM_MAKEPKG_PATH))
|
if os.path.exists(CUSTOM_MAKEPKG_PATH):
|
||||||
cmd.append('--config={}'.format(CUSTOM_MAKEPKG_PATH))
|
handler.watcher.print('Using custom makepkg.conf -> {}'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
cmd.append('--config={}'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
else:
|
||||||
|
handler.watcher.print('Custom optimized makepkg.conf ( {} ) not found'.format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
|
||||||
return handler.handle_simple(SimpleProcess(cmd, cwd=pkgdir))
|
return handler.handle_simple(SimpleProcess(cmd, cwd=pkgdir))
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import requests
|
|||||||
|
|
||||||
from bauh.api.abstract.context import ApplicationContext
|
from bauh.api.abstract.context import ApplicationContext
|
||||||
from bauh.api.abstract.controller import SoftwareManager
|
from bauh.api.abstract.controller import SoftwareManager
|
||||||
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_PATH, CONFIG_DIR
|
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_PATH, CONFIG_DIR, should_optimize_compilation
|
||||||
|
|
||||||
URL_INDEX = 'https://aur.archlinux.org/packages.gz'
|
URL_INDEX = 'https://aur.archlinux.org/packages.gz'
|
||||||
URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
|
URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
|
||||||
@@ -75,12 +75,17 @@ class ArchCompilationOptimizer(Thread if bool(os.getenv('BAUH_DEBUG', 0)) else P
|
|||||||
def __init__(self, logger: logging.Logger):
|
def __init__(self, logger: logging.Logger):
|
||||||
super(ArchCompilationOptimizer, self).__init__(daemon=True)
|
super(ArchCompilationOptimizer, self).__init__(daemon=True)
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.compilation_optimizations = bool(int(os.getenv('BAUH_ARCH_OPTIMIZE', 1)))
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
if not self.compilation_optimizations:
|
if not should_optimize_compilation():
|
||||||
self.logger.info("Arch packages compilation optimization is disabled. Aborting...")
|
self.logger.info("Arch packages compilation optimization is disabled")
|
||||||
|
|
||||||
|
if os.path.exists(CUSTOM_MAKEPKG_PATH):
|
||||||
|
self.logger.info("Removing custom 'makepkg.conf' -> '{}'".format(CUSTOM_MAKEPKG_PATH))
|
||||||
|
os.remove(CUSTOM_MAKEPKG_PATH)
|
||||||
|
|
||||||
|
self.logger.info('Finished')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
ncpus = os.cpu_count()
|
ncpus = os.cpu_count()
|
||||||
|
|||||||
Reference in New Issue
Block a user