mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
arch: optimizing tar.xz compression
This commit is contained in:
@@ -100,12 +100,15 @@ The application settings are stored in **/home/$USER/.config/bauh/config.json**
|
||||
- It is **not enabled by default**. It is necessary to enable it using the UI.
|
||||
- The user is able to search, install, uninstall, downgrade, launch and retrieve the packages history
|
||||
- It handles conflicts, and missing / optional packages installations ( include from your distro mirrors )
|
||||
- Automatically makes a simple package compilation improvement -> if **MAKEFLAGS** is not set in **/etc/makepkg.conf** and **/home/$USER/makepkg.conf** does not exist,
|
||||
then a copy of **/etc/makepkg.conf** will be generated at **/home/$USER/makepkg.conf** defining MAKEFLAGS to work with
|
||||
the number of your machine processors multiplied by 1.5 rounded up ( this feature can be disabled through the environment variable **BAUH_ARCH_OPTIMIZE=0** )
|
||||
- If (**aria2**) [https://github.com/aria2/aria2] is installed on your system and multi-threaded downloads are enabled ( see **BAUH_DOWNLOAD_MULTITHREAD** ), the source packages
|
||||
will be pre-downloaded faster ( it does **NOT** modify your **pacman** settings ).
|
||||
- Automatically makes simple package compilation improvements ( this feature can be disabled through the environment variable **BAUH_ARCH_OPTIMIZE=0** ):
|
||||
a) if **MAKEFLAGS** is not set in **/etc/makepkg.conf** and **/home/$USER/makepkg.conf** does not exist,
|
||||
then a copy of **/etc/makepkg.conf** will be generated at **/home/$USER/makepkg.conf** defining MAKEFLAGS to work with
|
||||
the number of your machine processors multiplied by 1.5 rounded up
|
||||
b) same as **a**, but related to **COMPRESSXZ** definition. If '--threads=0' is not defined, the custom file will be generated.
|
||||
|
||||
( for more information about these optimizations, check: https://wiki.archlinux.org/index.php/Makepkg )
|
||||
|
||||
### Logs
|
||||
- Installation logs are saved at **/tmp/bauh/logs/install**
|
||||
|
||||
@@ -18,6 +18,7 @@ GLOBAL_MAKEPKG = '/etc/makepkg.conf'
|
||||
USER_MAKEPKG = '{}/makepkg.conf'.format(HOME_PATH)
|
||||
|
||||
RE_MAKE_FLAGS = re.compile(r'#?\s*MAKEFLAGS\s*=\s*.+\s*')
|
||||
RE_COMPRESS_XZ = re.compile(r'#?\s*COMPRESSXZ\s*=\s*.+')
|
||||
|
||||
|
||||
class AURIndexUpdater(Thread):
|
||||
@@ -88,21 +89,39 @@ class ArchCompilationOptimizer(Thread if bool(os.getenv('BAUH_DEBUG', 0)) else P
|
||||
with open(GLOBAL_MAKEPKG) as f:
|
||||
global_makepkg = f.read()
|
||||
|
||||
makeflags = RE_MAKE_FLAGS.findall(global_makepkg)
|
||||
user_makepkg = None
|
||||
optimizations = []
|
||||
|
||||
makeflags = RE_MAKE_FLAGS.findall(global_makepkg)
|
||||
|
||||
if makeflags:
|
||||
not_commented = [f for f in makeflags if not makeflags[0].startswith('#')]
|
||||
not_commented = [f for f in makeflags if not f.startswith('#')]
|
||||
|
||||
if not not_commented:
|
||||
user_makepkg = RE_MAKE_FLAGS.sub('', global_makepkg)
|
||||
optimizations.append('MAKEFLAGS="-j{}"'.format(ncpus))
|
||||
else:
|
||||
self.logger.warning("It seems '{}' compilation flags are already customized".format(GLOBAL_MAKEPKG))
|
||||
else:
|
||||
user_makepkg = global_makepkg
|
||||
optimizations.append('MAKEFLAGS="-j{}"'.format(ncpus))
|
||||
|
||||
compress_xz = RE_COMPRESS_XZ.findall(user_makepkg if user_makepkg else global_makepkg)
|
||||
|
||||
if compress_xz:
|
||||
not_eligible = [f for f in compress_xz if not f.startswith('#') and '--threads' in f]
|
||||
|
||||
if not not_eligible:
|
||||
user_makepkg = RE_COMPRESS_XZ.sub('', global_makepkg)
|
||||
optimizations.append('COMPRESSXZ=(xz -c -z - --threads=0)')
|
||||
else:
|
||||
self.logger.warning("It seems '{}' COMPRESSXZ is already customized".format(GLOBAL_MAKEPKG))
|
||||
else:
|
||||
optimizations.append('COMPRESSXZ=(xz -c -z - --threads=0)')
|
||||
|
||||
if optimizations:
|
||||
generated_by = '# <generated by bauh>\n'
|
||||
user_makepkg = generated_by + user_makepkg + '\n' + generated_by + '\n'.join(optimizations) + '\n'
|
||||
|
||||
if user_makepkg:
|
||||
user_makepkg = '# <generated by bauh>\n' + user_makepkg + '\nMAKEFLAGS="-j{}"'.format(ncpus)
|
||||
with open(USER_MAKEPKG, 'w+') as f:
|
||||
f.write(user_makepkg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user