new ebuild generation script + homeassistant-full-2024.11.3

genebuild.py is based on genebuild.sh
usage: genebuild.py [-h] [version]
- integrations used by "core integrations" (as defined in bootstrap.py) cannot be disabled with use-flags any more
- requirements of core are read via the requirements.txt file; the requirements of each integration is read from manifest.json of that integration
- package_constraints.txt is used to create (soft) blockers
- REQUIRED_USE is generated based on the manifest files (some integrations depend on other integrations)

Also contains the generated ebuild for homeassistant-full-2024.11.3 + the dependencies not yet in the tree for my configuration

Signed-off-by: Stef Simoens <stef.github@bisse.be>
This commit is contained in:
2025-01-14 23:46:38 +01:00
parent 553203d995
commit b26562c03d
35 changed files with 2314 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ DIST homeassistant-2024.10.3.gh.tar.gz 18782063 BLAKE2B 6d124e7282815ebb106051e6
DIST homeassistant-2024.10.3.tar.gz 22982969 BLAKE2B de54bf0dc737fe6fe9990d5bef07df7eca5ff2962df6832e72de471f5b4f4f458a5e38c4d31083f09305e428a419294cf408a884620a687f6a41ce7bce0f0b0a SHA512 9666fdebc99ff6712375a2b1d4d29073e5ddb26d7d33c5e3f01f6b96b7f64fb006746998f81003bc12170dbed92de90b3d21c55ff89f395cd18701073b2f947f
DIST homeassistant-2024.10.4.gh.tar.gz 18785041 BLAKE2B bd3d63a8f16555976bb9d5b61a8c7ed7e29f709a398830b0c37fb581c35c6ff755db523b33743c92c55468b6025444333e412e2f3fd915fcc3778d723103ff32 SHA512 dd8557f7c86e045269931efa80c7cfaafdd2a53edafdff3af31e7cd2d0438c05909bd34f6fe8bb3945ef7a8f090806d207fb41e9055b21686015078209e4c553
DIST homeassistant-2024.10.4.tar.gz 23077043 BLAKE2B 2ec1562ae041e8ec37506945a4f21f121a721e004e9c20ff295c7a251c89279cc0a34f1e1dd2946edd589d8ba74b9f4d24133fd465f2cdc5331ea16720b03e9c SHA512 de1de3a649479d8e8f745a559ac9ff9f297651571bdcbfda1851006a64b8c8bd308b1769825d05dded541b0fe21c4e82f632c731de46e6a4630e03ade065712c
DIST homeassistant-2024.11.3.gh.tar.gz 18873491 BLAKE2B 7082b0b5f688e5da76fece577944927026d6594ef6d2b91c5106dd56bc3149a7f74e4394612ee526de11bf50e31a4a0167557f06f035c9a707c70fbf67cad69a SHA512 7ffbce37aa915a99a916d534bc02742b248e7b7215e05bbd6654aac4db094b89e8f7d75be726ac3caa0f769e0318267bd0753daa2f4da77142cfaa59c0c007d7
DIST homeassistant-2024.11.3.tar.gz 23432503 BLAKE2B 4c431cc5f43dd8d179c1a8292de282a9331157e04fdc20b165dc3e6ac6d2031710fc8abfc7e2f09de4f364c1b6d35398a07e40b4da0b30e414d86b44cb09321e SHA512 8f33c376ba988270262b3c3f627db85e7a44d19a5d57e7435b5d4158dcab042bf76b04ba271fcd251c614bc9d5a328984f24cbaf95b98ca0de2bc9751e956d7e
DIST homeassistant-2024.5.5.gh.tar.gz 17013825 BLAKE2B 03eba1e79d9c1c2ff8a751c84e9c51f8c4396e8d9c6ef7800d7ae8db9237d5b511f76d99aed4db7a9a851c8036dbbf129a66b67d31333338ef17a2a4805ecc04 SHA512 f84350c715438e715a694d211bd4452ca43b1a6bfee30266ee07d4d94a725df8129847db6bc94958759b971759bbdc78fd968fda769b238f0cbf5e98991e270f
DIST homeassistant-2024.5.5.tar.gz 21077969 BLAKE2B c08563c79974d99bb124d33f2deeee693a4c0b92fb1a17b9c937d8a1a125d1c4c5723e469305a6597c7aae7629713b1f1935608b4c3d29176098fb0a645513c0 SHA512 1bfab28f86ceb64d7b4c84b418811d57990a45b730b361d603a22bd8ccb64a6531cd79f5bfb1e282aaf49e3b711d74b1f94fc25915619c0a6a5fb2ef9b4c4796
DIST homeassistant-2024.6.4.gh.tar.gz 17252383 BLAKE2B cfaed713f67347e66bc54318b50fd1220aaa3cbf03517ff4be7d91f69ab701ad7899eee000182c1e1af5c2c209908c3ad325ddd05ce5b07576684ae00084015c SHA512 9bc7635b4e307ec46490681a3ea9e136fa73ecc02d7198116805d3084bd3ba634c69f67063bf1e8c3661142f06234c077662543f897c5937141bd04e6484b8ed
@@ -25,9 +27,11 @@ EBUILD homeassistant-full-2024.10.2.ebuild 87607 BLAKE2B b9c2aceeac42c2b63e6cc6a
EBUILD homeassistant-full-2024.10.3.ebuild 87607 BLAKE2B a408c1b643bd2a39d1064cdd969a416e3e3a272c23693fec932595ca7c18f4a42a3ccfea77609d63aa8335f0d191434c60cb96c7d6c69cb76c54acae8d3ddf93 SHA512 1d85e275e5c28e618876111a45753f000724a88cc1928dffd6f32cb2235843648eb026d5c20074ed855679a8e9bc1498b27bcd1dd6aad61a258e12de78d5c9a4
EBUILD homeassistant-full-2024.10.4-r1.ebuild 89730 BLAKE2B 37e9fb538755f23cbdcfb44ed0359f6e71bc87aeb50c839e6b9b6baad7035b0ee2bc1f4e0f2f7e601f772875b52e3bdab88cbe174ca68f42c160219b10fdecb6 SHA512 3831fb6187512bfcecee821f87cbc37cf52f7a3ef7252466658270c6ec0dcd651e123c56de157b9192e4398e161e375551305ee40b85128349034064634d9c78
EBUILD homeassistant-full-2024.10.4.ebuild 87607 BLAKE2B 5dd4dd9ee1662a45755794ab0cbcfa3ec2295151577ac884072f214a23c0feb442208323d6036cc168697a06aee446063ed20e3b05e1d6b749c5994e13236fa6 SHA512 5417750bf406feaa36d10b1372d496713880fb4f916201540b8c6ebf43ed756a98dfed784447997ca14a0f5f04a168331dd0a6ab04ffd249d6340ce96221b6c6
EBUILD homeassistant-full-2024.11.3.ebuild 90008 BLAKE2B c65f49d05a19aaaccfb5ee0fb1a896db77a0f4f4c16fee1c751a21fa2c2043aabf9e6630937776275b61fb76e2d22dbc179c48b6472cf67d5e184bb770ab76fd SHA512 c5819afee59a4128865629c316b330839b5c3d5282adb8985b632be363a73d52d467352cb10d1fc369db14709e84c868571eeaac7b12c25bc4b4d2d06a0d4eac
EBUILD homeassistant-full-2024.5.5.ebuild 87190 BLAKE2B 22ac1dc7d5be921e7a72cf1eb9bcd6f770f2bb5a28e7bd04daaa5afbf4ce2e25b07b2c214d3f3dcfdb3f0a688f948f0e23e760d0b03593a791872ec4afa41311 SHA512 8bcb7381d43930fb7e199e0bba32cf82adfd8afc7af4eaa6ae9dcf9a628e50e38cee70fb701aa87c10a864fea4226ff6253507720ed0ae1a988ef7dc524ef551
EBUILD homeassistant-full-2024.6.4.ebuild 87802 BLAKE2B 266b07de8f1443d187024699e46fbc0b4c3f6622faa5e233be5ce6639f7d27ed53ce4809fe3cc78f2ef2b56bc46d56cc608b6a842d7cf8def20bba19194468ce SHA512 de6fad31b936f241dfd8ac1127b4ab6c1c208725d3ac922eff8f782f66ced0d1f24b1b3614974f6fec3026be26821fd8f038b83eef3e9225c3bb610c799097e2
EBUILD homeassistant-full-9999.ebuild 89643 BLAKE2B 77b1f6a74ce370dbf10a6eb592964b186a55be2c83e9599431453fce75f4b19355b908f124a01f9d1b334ba8bb0233353f2592d2e877d8997a2de8d2d31df12e SHA512 9a95462eae04356e6a13181aacb06abe075c67ed19b9b9e6575f9c71b708d088d52156aa19737e8e954644eae9b0f5778b7312b6b29fd8359140eae19fc76c97
MISC genebuild.py 21212 BLAKE2B d2a1e731f2d1011fa140b9c3cae099e25698b17420dc26ea144be8f1f395a5dc24c8454fa0d5c77b5718c7deeb404bab29e5e1e118d7fc08de88d1fc6eb17ce5 SHA512 7b680cf09fbcbcb7bb2fc8623b5e504b6f4e106390d5dad332b3c9018b9936b63a0bfa2bac93eb16931329717a93722fbb979fb08565367a25e1ec12ff6905c2
MISC genebuild.sh 20826 BLAKE2B 21e5c5c45139392abe5f6a5b3fdb2a663ad0626333644a9bd93b78ff6a616be505d0db7c0949fef8d0b642ca1a78240623d1e2cc1c9a7b9ffb53a28fd56f4b63 SHA512 181e671e1a7b17f52a178eb83cbb05a2603451a95e9391f6e10ce21cb7a464745db8fa9628d57ed66617c2863c7a5de65024ec9417bdd6ebf2141db8d12e422c
MISC metadata.xml 96075 BLAKE2B 4bc104ea0b1abac247630842f128006f52b10cbf1e8db60f85774d1d88baeb19d5b4a887fdd1c5c1e367197f8d4383a95ea36c74bfbec64dcba08b15b99c9960 SHA512 d6dcee356e9b95398f7f111d9d73a803437a2eb9f585c71479ac29dee14a792e5da3fd0d5f80448e21f6970bcfc6c23369c798f1657a8e3d4257e80f2a87e3e0
MISC test.sh 952 BLAKE2B 15c3ca304b9de0fe03a15511c06fbef6fb0778c2566a18f4045c6c77546a933384374161f4c2185e00778e745b0fdc8a5f8ab20091f82fbfb1e9a99640ce9888 SHA512 d1e2e05d54ba946b82926edeb8faf2224560f6aa27a2fb70733208acff0162f2f675d131df26c2e5e63a55f9692a4c2e2ccd779fbf03319fd8144475dbc28465

View File

@@ -0,0 +1,483 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os
import json
import re
import requests
import shutil
import subprocess
import sys
import yaml
from packaging.requirements import Requirement, InvalidRequirement
from packaging.specifiers import SpecifierSet
from packaging.utils import canonicalize_name, canonicalize_version
def fetch_json(url):
"""Fetches JSON data from the given URL."""
response = requests.get(url)
response.raise_for_status() # raise an error for bad status codes
return response.json()
def by_version(specifier):
return specifier.version
def get_package(name, operator, version, extras = None, strict = 1):
operator_mapping = {
'==0': '>=',
'==1': '~',
'==-1': '!<',
'!=-1': '!<=',
'>=-1': '!<',
}
# 1000000000.0.0 is used as "any version"
if version != '1000000000.0.0':
version_string = operator_mapping.get(operator + str(strict), operator)
elif strict == -1:
version_string = '!'
else:
version_string = ''
name_mapping = {
'apple_weatherkit': 'dev-python/apple_weatherkit',
'atomicwrites-homeassistant': 'dev-python/atomicwrites',
'foobot_async': 'dev-python/foobot_async',
'geopy': 'sci-geosciences/geopy',
'haproxy': 'net-proxy/haproxy',
'home-assistant-cli': 'app-misc/home-assistant-cli',
'Jinja2': 'dev-python/jinja2',
'pyOpenSSL': 'dev-python/pyopenssl',
'PyJWT': 'dev-python/pyjwt',
'python-gitlab': 'dev-vcs/python-gitlab',
'Pillow': 'dev-python/pillow',
'pushover_complete': 'dev-python/pushover_complete',
'PyChromecast': 'dev-python/pychromecast',
'PyNaCl': 'dev-python/pynacl',
'PyQRCode': 'dev-python/pyqrcode',
'PyYAML': 'dev-python/pyyaml',
'sharp_aquos_rc': 'dev-python/sharp_aquos_rc',
'shodan': 'net-analyzer/shodan',
'socat': 'net-misc/socat',
'solarlog_cli': 'dev-python/solarlog_cli',
'speedtest-cli': 'net-analyzer/speedtest-cli',
'SQLAlchemy': 'dev-python/sqlalchemy',
'mutagen': 'media-libs/mutagen',
'yt-dlp': 'net-misc/yt-dlp',
}
newname = name
newname = newname.replace('.', '-')
newname = newname.replace('_', '-')
version_string += name_mapping.get(name, 'dev-python/' + newname)
# 1000000000.0.0 is used as "any version"
if version != '1000000000.0.0':
version = canonicalize_version(version, strip_trailing_zero=False)
# see pypi.eclass
version = version.replace('a', '_alpha')
version = version.replace('b', '_beta')
version = version.replace('rc', '_rc')
version = version.replace('.dev', '_pre')
version = version.replace('.post', '_p')
version_string += '-' + version
if extras is None:
extras = []
else:
extras = list(extras)
# fritzconnection has a gentoo USE flag qrcode
if name == 'fritzconnection':
extras = [e.replace('qr', 'qrcode') for e in extras]
if strict != -1 and name not in ['haproxy', 'uv']:
extras.append('${PYTHON_USEDEP}')
if len(extras) > 0:
version_string += '[' + ','.join(sorted(extras)) + ']'
return version_string
def write_header(ebuild_path, minimal = False):
# determine python version
if minimal:
# use current Python version
PYTHON_COMPAT = 'python' + str(sys.version_info.major) + '_' + str(sys.version_info.minor)
else:
# use Python versions as mentioned in .github/workflow/ci.yaml
with open(portage_coredir + '/.github/workflows/ci.yaml', 'r') as stream:
y = yaml.safe_load(stream)
PYTHON_ALL_VERSIONS = eval(y['env']['ALL_PYTHON_VERSIONS'])
del y
# and limit them to homeassistant/const.py [REQUIRED_NEXT_PYTHON_VER]
with open(portage_coredir + '/homeassistant/const.py', 'r') as const:
for line in const:
if line.startswith('REQUIRED_PYTHON_VER:'):
y = re.search('\\((.*), [0-9]+\\)', line)
PYTHON_MIN_VERSION = y.group(1).replace(', ', '.')
for v in PYTHON_ALL_VERSIONS:
if v < PYTHON_MIN_VERSION:
PYTHON_ALL_VERSIONS.remove(v)
if len(PYTHON_ALL_VERSIONS) == 1:
PYTHON_COMPAT = 'python' + str(PYTHON_ALL_VERSIONS[0]).replace('.', '_')
elif len(PYTHON_ALL_VERSIONS) == 2:
if PYTHON_ALL_VERSIONS[0][0] == PYTHON_ALL_VERSIONS[1][0]:
PYTHON_COMPAT = 'python' + PYTHON_ALL_VERSIONS[0][0] + '_{' + PYTHON_ALL_VERSIONS[0][2:] + '..' + PYTHON_ALL_VERSIONS[1][2:] + '}'
else:
PYTHON_COMPAT = 'python' + str(PYTHON_ALL_VERSIONS[0]).replace('.', '_') + ' ' + 'python' + str(PYTHON_ALL_VERSIONS[1]).replace('.', '_')
with open(ebuild_path, 'w') as ebuild_file:
# write header
lines = [
'# Distributed under the terms of the GNU General Public License v2\n',
'\n',
'EAPI=8\n',
'\n',
'DISTUTILS_USE_PEP517=setuptools\n',
'PYTHON_COMPAT=( ' + PYTHON_COMPAT + ' )\n',
'PYTHON_REQ_USE="sqlite?"\n',
'PYPI_NO_NORMALIZE=1\n',
'PYPI_PN="homeassistant"\n',
'inherit distutils-r1 pypi readme.gentoo-r1 systemd\n',
'\n',
'MY_PN=homeassistant\n',
'\n',
'if [[ ${PV} == *9999* ]]; then\n',
' inherit git-r3\n',
' EGIT_REPO_URI="https://github.com/home-assistant/core.git"\n',
' EGIT_BRANCH="dev"\n',
' S="${WORKDIR}/homeassistant-full-9999/"\n',
'else\n',
' MY_PV=${PV/_beta/b}\n',
' MY_P=${MY_PN}-${MY_PV}\n',
' SRC_URI="$(pypi_sdist_url)\n',
' https://github.com/home-assistant/core/archive/${MY_PV}.tar.gz -> ${MY_P}.gh.tar.gz"\n',
'fi\n',
'\n',
'DESCRIPTION="Open-source home automation platform running on Python."\n',
'HOMEPAGE="https://home-assistant.io/ https://git.edevau.net/onkelbeh/HomeAssistantRepository/"\n',
'\n',
'LICENSE="Apache-2.0"\n',
'SLOT="0"\n',
'KEYWORDS="amd64 arm arm64 x86"\n',
]
ebuild_file.writelines(lines)
if minimal:
ebuild_file.write('IUSE="+sqlite"\n')
ebuild_file.write('RESTRICT="!test? ( test )"\n')
ebuild_file.write('distutils_enable_tests pytest\n')
# parse arguments
# accepted parameter: version
argp = argparse.ArgumentParser(description='Generate ebuild')
argp.add_argument('version', nargs='?')
args = argp.parse_args()
# check the version
if args.version is None:
url = 'https://api.github.com/repos/home-assistant/core/releases/latest'
else:
url = 'https://api.github.com/repos/home-assistant/core/releases/tags/' + args.version.replace('_beta', 'b')
json_data = fetch_json(url)
remote_version = json_data['tag_name']
ebuild_dir = os.path.dirname(os.path.realpath(__file__))
ebuild = os.path.basename(ebuild_dir) + '-' + remote_version.replace('b', '_beta')
ebuild_path = ebuild_dir + '/' + ebuild + '.ebuild'
# generate a new revision if we are re-generating an ebuild
rev = 0
while os.path.isfile(ebuild_path := ebuild_dir + '/' + ebuild + ('-r' + str(rev) if rev > 0 else '') + '.ebuild'):
rev += 1
# write empty ebuild so we can unpack
write_header(ebuild_path, True)
# generate the new ebuild manifest
subprocess.run(['ebuild', ebuild_path, 'clean', 'digest', 'unpack'])
# core integrations (cf. bootstrap.py)
core_integrations = ['homeassistant', 'persistent_notification', 'analytics', 'application_credentials', 'automation', 'backup', 'counter', 'frontend', 'hardware', 'input_boolean', 'input_button', 'input_datetime', 'input_number', 'input_select', 'input_text', 'logger', 'network', 'person', 'scene', 'schedule', 'script', 'system_health', 'tag', 'timer', 'zone']
# requirements (key: requirement name) => req, use
requirements = {}
# definition of directories
PORTAGE_TMPDIR = '/var/tmp'
portage_coredir = PORTAGE_TMPDIR + '/portage/app-misc/' + ebuild + ('-r' + str(rev) if rev > 0 else '') + '/work/core-' + remote_version.replace('b', '_beta')
portage_hassdir = PORTAGE_TMPDIR + '/portage/app-misc/' + ebuild + ('-r' + str(rev) if rev > 0 else '') + '/work/homeassistant-' + remote_version.replace('b', '_beta')
# iterate core requirements
with open(portage_coredir + '/requirements.txt', 'r') as reqs:
for req in reqs:
try:
sr = Requirement(req)
# cf script/gen_requirements_all.py: do not hard pin these requirements
if sr.name in ['urllib3']:
newspec = []
for s in sr.specifier:
if s.operator not in ['<']:
newspec.append(str(s))
sr.specifier = SpecifierSet(','.join(newspec))
requirements[sr.name] = {'req': sr, 'use': ['core']}
except InvalidRequirement:
pass
with open(portage_coredir + '/requirements_test_pre_commit.txt', 'r') as reqs:
for req in reqs:
try:
sr = Requirement(req)
requirements[sr.name] = {'req': sr, 'use': ['test']}
except InvalidRequirement:
pass
with open(portage_coredir + '/requirements_test.txt', 'r') as reqs:
for req in reqs:
try:
sr = Requirement(req)
requirements[sr.name] = {'req': sr, 'use': ['test']}
except InvalidRequirement:
pass
# iterate integration requirements
integrations = {}
for integration in os.listdir(portage_hassdir + '/homeassistant/components'):
if os.path.isfile(portage_hassdir + '/homeassistant/components/' + integration + '/manifest.json'):
with open(portage_hassdir + '/homeassistant/components/' + integration + '/manifest.json', 'r') as file:
manifest = json.load(file)
if integration not in integrations:
integrations[integration] = {'core': (integration in core_integrations)}
if 'name' in manifest:
integrations[integration]['name'] = manifest['name']
integrations[integration]['disabled'] = ('disabled' in manifest)
if 'dependencies' in manifest:
integrations[integration]['deps'] = manifest['dependencies']
# dependencies of core dependencies ... become core as well
if integrations[integration]['core']:
for dep in integrations[integration]['deps']:
if dep in integrations:
integrations[dep]['core'] = True
else:
integrations[dep] = {'core': True}
if 'requirements' in manifest and len(manifest['requirements']) > 0:
integrations[integration]['reqs'] = []
for req in manifest['requirements']:
try:
sr = Requirement(req)
integrations[integration]['reqs'].append(sr)
if sr.name in requirements:
requirements[sr.name]['req'].specifier &= sr.specifier
requirements[sr.name]['use'].append(integration)
else:
requirements[sr.name] = {'req': sr, 'use': [integration]}
except InvalidRequirement:
pass
with open(portage_hassdir + '/homeassistant/package_constraints.txt', 'r') as reqs:
for req in reqs:
try:
sr = Requirement(req)
if sr.name in requirements:
# check and possibly rewrite to match with the ebuild
requirements[sr.name]['use'].append('REWRITE')
requirements[sr.name]['package_constraint'] = req.rstrip()
else:
# generate a blocker for the lower or equal version
requirements[sr.name] = {'req': sr, 'use': ['BLOCKER']}
except InvalidRequirement:
pass
# add manual requirements, 1000000000.0.0 means "no version" in this context
# databases
integrations['mysql'] = {'core': False, 'reqs': [Requirement('mysqlclient>=1.4.0')]}
integrations['postgres'] = {'core': False, 'reqs': [Requirement('psycopg>3.1.15')]}
integrations['sqlite'] = {'core': False, 'reqs': []}
integrations['default_config']['deps'].append('sqlite')
# extra features
integrations['cli'] = {'core': False, 'reqs': [Requirement('home-assistant-cli==1000000000.0.0')]}
integrations['socat'] = {'core': False, 'reqs': [Requirement('socat==1000000000.0.0')]}
integrations['ssl'] = {'core': False, 'reqs': [Requirement('haproxy[ssl]==1000000000.0.0')]}
integrations['systemd'] = {'core': False, 'reqs': []}
### write ebuild
rewrites = {}
write_header(ebuild_path)
with open(ebuild_path, 'a') as ebuild_file:
# header written above
# write IUSE
iuse = []
for integration in sorted(integrations.keys()):
# core deps should not have use flags
# only generate use flags for integrations that have external dependencies
if not integrations[integration]['core'] and 'reqs' in integrations[integration]:
# soft add the default_integration use flags
iuse.append(('+' if integration in integrations['default_config']['deps'] else '') + integration)
ebuild_file.write('IUSE="' + ' '.join(iuse) + '"\n')
# write RESTRICT
lines = [
'RESTRICT="!test? ( test )"\n',
'\n',
'# external deps\n',
'RDEPEND="${PYTHON_DEPS}\n',
' acct-group/${MY_PN} acct-user/${MY_PN}\n',
' app-admin/logrotate"\n',
'# make sure no conflicting main ebuild is installed\n',
'RDEPEND="${RDEPEND}\n',
' !app-misc/homeassistant-min\n',
' !app-misc/homeassistant"\n',
'\n'
]
ebuild_file.writelines(lines)
# generate core RDEPEND
ebuild_file.write('# core requirements (cf requirements.txt)\nRDEPEND="${RDEPEND}')
for req in sorted(requirements.keys(), key=str.casefold):
core_req = 'core' in requirements[req]['use']
# if requirements are used by integrations, the version needs to match strict,
# else, the version can match loosely
strict = int(not (set(requirements[req]['use']) == (set(requirements[req]['use']) & set(['core', 'test', 'REWRITE']))))
# rewrite non-strict requirements
if 'REWRITE' in requirements[req]['use'] and not strict:
old = requirements[req]['package_constraint']
new = old.replace('==', '>=')
if old != new:
rewrites[old] = new
for use in requirements[req]['use']:
try:
core_req |= integrations[use]['core']
except KeyError:
pass
if core_req:
sr = requirements[req]['req']
rdep = []
for item in sorted(sr.specifier, key=by_version):
rdep.append(get_package(sr.name, item.operator, item.version, sr.extras, strict))
ebuild_file.write('\n ' + ' '.join(rdep))
ebuild_file.write('"\n\n')
# generate blockers
ebuild_file.write('# blockers (cf package_constraints.txt, but (usually) inversed)\nRDEPEND="${RDEPEND}')
for req in sorted(requirements.keys(), key=str.casefold):
if 'BLOCKER' in requirements[req]['use']:
sr = requirements[req]['req']
rdep = []
for item in sorted(sr.specifier, key=by_version):
rdep.append(get_package(sr.name, item.operator, item.version, sr.extras, -1))
ebuild_file.write('\n ' + ' '.join(rdep))
ebuild_file.write('"\n\n')
# generate REQUIRED_USE
ebuild_file.write('# use dependencies (cf manifest.json dependencies)\nREQUIRED_USE="')
# require at lease one database engine
ebuild_file.write('\n || ( sqlite postgres mysql )')
for integration in sorted(integrations.keys()):
if not integrations[integration]['core'] and 'reqs' in integrations[integration] and 'deps' in integrations[integration]:
rdep = []
for req in sorted(integrations[integration]['deps']):
if not integrations[req]['core'] and 'reqs' in integrations[req]:
rdep.append(req)
if len(rdep) > 0:
ebuild_file.write('\n ' + integration + '? ( ' + ' '.join(rdep) + ' )')
ebuild_file.write('"\n\n')
# generate integrations RDEPEND
ebuild_file.write('# module requirements from useflags\nRDEPEND="${RDEPEND}')
for integration in sorted(integrations.keys()):
if not integrations[integration]['core'] and 'reqs' in integrations[integration] and len(integrations[integration]['reqs']) > 0:
rdep = []
for req in sorted(integrations[integration]['reqs'], key=lambda req: req.name):
for item in sorted(req.specifier, key=by_version):
rdep.append(get_package(req.name, item.operator, item.version, req.extras, 1))
ebuild_file.write('\n ' + integration + '? ( ' + ' '.join(rdep) + ' )')
ebuild_file.write('"\n\n')
# generate BDEPEND (see pyproject.toml)
lines = [
'BDEPEND="${RDEPEND}\n',
' >=dev-python/setuptools-69.2.0[${PYTHON_USEDEP}]\n',
' >=dev-python/wheel-0.43.0[${PYTHON_USEDEP}]\n',
' test? (\n',
]
ebuild_file.writelines(lines)
for req in sorted(requirements.keys(), key=str.casefold):
test_req = 'test' in requirements[req]['use']
if test_req:
sr = requirements[req]['req']
rdep = []
for item in sorted(sr.specifier, key=by_version):
rdep.append(get_package(sr.name, item.operator, item.version, sr.extras, 0))
ebuild_file.write(' ' + ' '.join(rdep) + '\n')
ebuild_file.write(' )"\n\n')
lines = [
'src_prepare() {\n',
' if use test ; then\n',
' cp --no-preserve=mode --recursive ${WORKDIR}/core-${MY_PV}/tests ${S}\n',
' chmod u+x ${S}/tests/auth/providers/test_command_line_cmd.sh\n',
' fi\n',
]
ebuild_file.writelines(lines)
# perform rewrites of homeassistant/package_constraints.txt
for old, new in rewrites.items():
ebuild_file.write(' sed -e "s|' + old + '|' + new + '|" -i homeassistant/package_constraints.txt || die\n')
lines = [
'\n',
' distutils-r1_src_prepare\n',
'}\n',
'\n',
'INSTALL_DIR="/opt/${MY_PN}"\n',
'\n',
'DISABLE_AUTOFORMATTING=1\n',
'DOC_CONTENTS="\n',
'The HA interface listens on port 8123\n',
'hass configuration is in: /etc/${MY_PN}\n',
'daemon command line arguments are configured in: /etc/conf.d/${MY_PN}\n',
'logging is to: /var/log/${MY_PN}/{server,errors,stdout}.log\n',
'The sqlite db is by default in: /etc/${MY_PN}\n',
'support at https://git.edevau.net/onkelbeh/HomeAssistantRepository\n',
'"\n',
'\n',
'DOCS="README.rst"\n',
'\n',
'python_install_all() {\n',
' dodoc ${DOCS}\n',
' distutils-r1_python_install_all\n',
' keepdir "$INSTALL_DIR"\n',
' keepdir "/etc/${MY_PN}"\n',
' fowners -R "${MY_PN}:${MY_PN}" "/etc/${MY_PN}"\n',
' keepdir "/var/log/${MY_PN}"\n',
' fowners -R "${MY_PN}:${MY_PN}" "/var/log/${MY_PN}"\n',
' newconfd "${FILESDIR}/${MY_PN}.conf.d" "${MY_PN}"\n',
' newinitd "${FILESDIR}/${MY_PN}.init.d" "${MY_PN}"\n',
' use systemd && systemd_dounit "${FILESDIR}/${MY_PN}.service"\n',
' dobin "${FILESDIR}/hasstest"\n',
' if use socat ; then\n',
' newinitd "${FILESDIR}/socat-zwave.init.d" "socat-zwave"\n',
' sed -i -e \'s/# need socat-zwave/need socat-zwave/g\' "${D}/etc/init.d/${MY_PN}" || die\n',
' fi\n',
' if use mqtt ; then\n',
' sed -i -e \'s/# need mosquitto/need mosquitto/g\' "${D}/etc/init.d/${MY_PN}" || die\n',
' fi\n',
' insinto /etc/logrotate.d\n',
' newins "${FILESDIR}/${MY_PN}.logrotate" "${MY_PN}"\n',
' readme.gentoo_create_doc\n',
'}\n',
'\n',
'pkg_postinst() {\n',
' readme.gentoo_print_elog\n',
'}\n',
'\n',
'distutils_enable_tests pytest\n',
]
ebuild_file.writelines(lines)
# clean up
subprocess.run(['ebuild', ebuild_path, 'clean', 'digest'])

File diff suppressed because one or more lines are too long