mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[feature][aur] enabled ccache during installation if available
This commit is contained in:
@@ -1,57 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
enable-background="new 0 0 515.91 728.5"
|
||||
height="24.000002"
|
||||
id="Layer_1"
|
||||
version="1.1"
|
||||
viewBox="0 0 24.000003 24.000002"
|
||||
width="24.000002"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="arch.svg"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
|
||||
id="metadata1699"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1360"
|
||||
inkscape:window-height="703"
|
||||
id="namedview1697"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:zoom="0.028808594"
|
||||
inkscape:cx="-7209.5591"
|
||||
inkscape:cy="-2410.7966"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" /><defs
|
||||
id="defs7" /><g
|
||||
id="g3824"
|
||||
transform="matrix(0.046875,0,0,0.046875,6.9430338,6.4852622)"><path
|
||||
d="m -733.62329,72.267944 c 0,203.804876 -165.21649,369.021366 -369.02141,369.021366 -203.8048,0 -369.0213,-165.21649 -369.0213,-369.021366 0,-203.804874 165.2165,-369.021364 369.0213,-369.021364 203.80492,0 369.02141,165.21649 369.02141,369.021364 z"
|
||||
id="path4878"
|
||||
style="fill:#1793d1;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
transform="matrix(0.69372682,0,0,0.69372682,872.81612,67.513546)"
|
||||
inkscape:connector-curvature="0" /><path
|
||||
d="M 107.84949,-98.602257 C 92.493787,-60.954304 83.231987,-36.328024 66.135387,0.20085614 76.617787,11.312106 89.484387,24.251686 110.3795,38.865776 87.915087,29.621786 72.591587,20.341076 61.140187,10.710446 39.259887,56.367046 4.9797874,121.40283 -64.585822,246.39777 c 54.6762094,-31.56545 97.060109,-51.0259 136.559909,-58.45149 -1.696,-7.29506 -2.6605,-15.1861 -2.595,-23.41953 l 0.065,-1.7516 c 0.8677,-35.02952 19.09,-61.96722 40.676113,-60.13821 21.5861,1.82902 38.3647,31.72582 37.4971,66.75537 -0.1631,6.59145 -0.9065,12.93234 -2.2057,18.81346 39.0709,7.64297 81.0017,27.0536 134.93811,58.192 C 269.7144,226.81765 260.2216,209.1676 251.1563,192.3577 236.8771,181.29028 221.983,166.88599 191.602,151.29245 c 20.8822,5.42606 35.8334,11.68629 47.4876,18.68371 C 146.9204,-1.6272139 139.4566,-24.429744 107.84949,-98.602257 Z"
|
||||
id="path2518"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
||||
<?xml version="1.0" ?><svg enable-background="new 0 0 515.91 728.5" height="512" id="Layer_1" version="1.1" viewBox="0 0 512.00003 512" width="512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs7"/><g id="g3824" transform="translate(148.11806,138.35224)"><path d="m -733.62329,72.267944 c 0,203.804876 -165.21649,369.021366 -369.02141,369.021366 -203.8048,0 -369.0213,-165.21649 -369.0213,-369.021366 0,-203.804874 165.2165,-369.021364 369.0213,-369.021364 203.80492,0 369.02141,165.21649 369.02141,369.021364 z" id="path4878" style="fill:#1793d1;fill-opacity:1;fill-rule:nonzero;stroke:none" transform="matrix(0.69372682,0,0,0.69372682,872.81612,67.513546)"/><path d="M 107.84949,-98.602257 C 92.493787,-60.954304 83.231987,-36.328024 66.135387,0.20085614 76.617787,11.312106 89.484387,24.251686 110.3795,38.865776 87.915087,29.621786 72.591587,20.341076 61.140187,10.710446 39.259887,56.367046 4.9797874,121.40283 -64.585822,246.39777 c 54.6762094,-31.56545 97.060109,-51.0259 136.559909,-58.45149 -1.696,-7.29506 -2.6605,-15.1861 -2.595,-23.41953 l 0.065,-1.7516 c 0.8677,-35.02952 19.09,-61.96722 40.676113,-60.13821 21.5861,1.82902 38.3647,31.72582 37.4971,66.75537 -0.1631,6.59145 -0.9065,12.93234 -2.2057,18.81346 39.0709,7.64297 81.0017,27.0536 134.93811,58.192 C 269.7144,226.81765 260.2216,209.1676 251.1563,192.3577 236.8771,181.29028 221.983,166.88599 191.602,151.29245 c 20.8822,5.42606 35.8334,11.68629 47.4876,18.68371 C 146.9204,-1.6272139 139.4566,-24.429744 107.84949,-98.602257 z" id="path2518" style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -8,15 +8,15 @@
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
enable-background="new 0 0 515.91 728.5"
|
||||
height="24.000002"
|
||||
height="512"
|
||||
id="Layer_1"
|
||||
version="1.1"
|
||||
viewBox="0 0 24.000003 24.000002"
|
||||
width="24.000002"
|
||||
viewBox="0 0 512.00003 512"
|
||||
width="512"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="mirror.svg"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
|
||||
id="metadata1699"><rdf:RDF><cc:Work
|
||||
id="metadata822"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
@@ -27,29 +27,24 @@
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1360"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="703"
|
||||
id="namedview1697"
|
||||
id="namedview820"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:zoom="0.921875"
|
||||
inkscape:cx="397.90313"
|
||||
inkscape:cy="-179.59695"
|
||||
inkscape:zoom="0.12524414"
|
||||
inkscape:cx="2489.9913"
|
||||
inkscape:cy="413.33383"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" /><defs
|
||||
id="defs7" /><g
|
||||
id="g2275"><path
|
||||
d="M 24.000004,12.000001 C 24.000004,18.627417 18.627422,24 12.000003,24 5.3725893,24 6.47896e-6,18.627417 6.47896e-6,12.000001 6.47896e-6,5.3725839 5.3725893,1.4169352e-6 12.000003,1.4169352e-6 18.627422,1.4169352e-6 24.000004,5.3725839 24.000004,12.000001 Z"
|
||||
id="g828"><path
|
||||
d="M 512.00005,256 C 512.00005,397.38491 397.38494,512.00002 256,512.00002 114.61514,512.00002 2.571788e-5,397.38491 2.571788e-5,256 2.571788e-5,114.61509 114.61514,-1.6380724e-5 256,-1.6380724e-5 397.38494,-1.6380724e-5 512.00005,114.61509 512.00005,256 Z"
|
||||
id="path4878"
|
||||
style="fill:#2ca05a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.03251844"
|
||||
style="fill:#00aa44;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.69372684"
|
||||
inkscape:connector-curvature="0" /><path
|
||||
d="M 11.998479,1.8632814 C 11.27868,3.6280292 10.844533,4.7823861 10.04313,6.4946773 10.534493,7.0155172 11.137614,7.62206 12.117073,8.307096 11.064054,7.8737834 10.345764,7.4387501 9.8089801,6.9873144 8.783341,9.127468 7.1764613,12.17602 3.9155734,18.035158 6.4785207,16.555527 8.465266,15.643319 10.316819,15.295244 c -0.0795,-0.341956 -0.124711,-0.711848 -0.12164,-1.09779 l 0.003,-0.08211 c 0.04067,-1.642008 0.894844,-2.904713 1.906693,-2.818978 1.011849,0.08573 1.798345,1.487148 1.757677,3.129158 -0.0076,0.308974 -0.04249,0.606203 -0.103392,0.881881 1.831448,0.358264 3.796954,1.268137 6.325223,2.72775 -0.49853,-0.917818 -0.943505,-1.745165 -1.368441,-2.533129 -0.669337,-0.518785 -1.367498,-1.193986 -2.791607,-1.924933 0.978853,0.254346 1.67969,0.547795 2.225981,0.875799 C 13.829928,6.4089865 13.480062,5.3401179 11.998479,1.8632814 Z"
|
||||
d="m 255.96755,39.749983 c -15.3557,37.647953 -24.6175,62.274237 -41.7141,98.803117 10.4824,11.11125 23.349,24.05083 44.24411,38.66492 -22.46441,-9.24399 -37.78791,-18.5247 -49.23931,-28.15533 -21.8803,45.6566 -56.1604,110.69238 -125.726012,235.68732 54.676212,-31.56545 97.060112,-51.0259 136.559912,-58.45149 -1.696,-7.29506 -2.6605,-15.1861 -2.595,-23.41953 l 0.065,-1.7516 c 0.8677,-35.02952 19.09,-61.96722 40.67611,-60.13821 21.5861,1.82902 38.3647,31.72582 37.4971,66.75537 -0.1631,6.59145 -0.9065,12.93234 -2.2057,18.81346 39.0709,7.64297 81.0017,27.0536 134.93811,58.192 -10.63531,-19.58012 -20.12811,-37.23017 -29.19341,-54.04007 -14.2792,-11.06742 -29.1733,-25.47171 -59.5543,-41.06525 20.8822,5.42606 35.8334,11.68629 47.4876,18.68371 -92.1692,-171.60337 -99.633,-194.4059 -131.24011,-268.578417 z"
|
||||
id="path2518"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.046875"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.8 KiB |
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
@@ -8,6 +9,7 @@ from threading import Thread
|
||||
import requests
|
||||
|
||||
from bauh.api.abstract.context import ApplicationContext
|
||||
from bauh.commons.system import run_cmd
|
||||
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, BUILD_DIR, \
|
||||
AUR_INDEX_FILE, config
|
||||
|
||||
@@ -17,7 +19,6 @@ URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
|
||||
GLOBAL_MAKEPKG = '/etc/makepkg.conf'
|
||||
|
||||
RE_MAKE_FLAGS = re.compile(r'#?\s*MAKEFLAGS\s*=\s*.+\s*')
|
||||
RE_COMPRESS_XZ = re.compile(r'#?\s*COMPRESSXZ\s*=\s*.+')
|
||||
RE_CLEAR_REPLACE = re.compile(r'[\-_.]')
|
||||
|
||||
|
||||
@@ -74,8 +75,15 @@ class ArchCompilationOptimizer(Thread):
|
||||
def __init__(self, logger: logging.Logger):
|
||||
super(ArchCompilationOptimizer, self).__init__(daemon=True)
|
||||
self.logger = logger
|
||||
self.re_compress_xz = re.compile(r'#?\s*COMPRESSXZ\s*=\s*.+')
|
||||
self.re_build_env = re.compile(r'\s+BUILDENV\s*=.+')
|
||||
self.re_ccache = re.compile(r'!?ccache')
|
||||
|
||||
def _is_ccache_installed(self) -> bool:
|
||||
return bool(run_cmd('which ccache', print_error=False))
|
||||
|
||||
def optimize(self):
|
||||
ti = time.time()
|
||||
try:
|
||||
ncpus = os.cpu_count()
|
||||
except:
|
||||
@@ -106,22 +114,50 @@ class ArchCompilationOptimizer(Thread):
|
||||
else:
|
||||
optimizations.append('MAKEFLAGS="-j$(nproc)"')
|
||||
|
||||
compress_xz = RE_COMPRESS_XZ.findall(custom_makepkg if custom_makepkg else global_makepkg)
|
||||
compress_xz = self.re_compress_xz.findall(custom_makepkg or 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:
|
||||
custom_makepkg = RE_COMPRESS_XZ.sub('', global_makepkg)
|
||||
custom_makepkg = self.re_compress_xz.sub('', custom_makepkg or 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)')
|
||||
|
||||
build_envs = self.re_build_env.findall(custom_makepkg or global_makepkg)
|
||||
|
||||
if build_envs:
|
||||
build_def = None
|
||||
for e in build_envs:
|
||||
env_line = e.strip()
|
||||
|
||||
ccache_defs = self.re_ccache.findall(env_line)
|
||||
ccache_installed = self._is_ccache_installed()
|
||||
|
||||
if ccache_defs:
|
||||
if ccache_installed:
|
||||
custom_makepkg = (custom_makepkg or global_makepkg).replace(e, '')
|
||||
|
||||
if not build_def:
|
||||
build_def = self.re_ccache.sub('', env_line).replace('(', '(ccache ')
|
||||
elif not build_def:
|
||||
build_def = self.re_ccache.sub('', env_line)
|
||||
|
||||
if build_def:
|
||||
optimizations.append(build_def)
|
||||
else:
|
||||
self.logger.warning("No BUILDENV declaration found")
|
||||
|
||||
if self._is_ccache_installed():
|
||||
self.logger.info('Adding a BUILDENV declaration')
|
||||
optimizations.append('BUILDENV=(ccache)')
|
||||
|
||||
if optimizations:
|
||||
generated_by = '# <generated by bauh>\n'
|
||||
custom_makepkg = generated_by + custom_makepkg + '\n' + generated_by + '\n'.join(optimizations) + '\n'
|
||||
custom_makepkg = custom_makepkg + '\n' + generated_by + '\n'.join(optimizations) + '\n'
|
||||
|
||||
with open(CUSTOM_MAKEPKG_FILE, 'w+') as f:
|
||||
f.write(custom_makepkg)
|
||||
@@ -134,6 +170,8 @@ class ArchCompilationOptimizer(Thread):
|
||||
self.logger.info("Removing old optimized 'makepkg.conf' at '{}'".format(CUSTOM_MAKEPKG_FILE))
|
||||
os.remove(CUSTOM_MAKEPKG_FILE)
|
||||
|
||||
tf = time.time()
|
||||
self.logger.info("Optimizations took {0:.2f} seconds".format(tf - ti))
|
||||
self.logger.info('Finished')
|
||||
|
||||
def run(self):
|
||||
|
||||
Reference in New Issue
Block a user