mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: new configurations for APK/Java/Python/Yum
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -11,7 +11,6 @@ produce a single key file.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import logging
|
||||
from pathlib import Path
|
||||
@@ -74,8 +73,9 @@ class ApkModule(Module):
|
||||
lines.append(repository.url)
|
||||
logger.info("added apk repository %s", repository.url)
|
||||
if repository.key:
|
||||
content = base64.b64decode(repository.key)
|
||||
filename = _key_filename(content)
|
||||
context.write_file(f"{_KEYS_DIR}/{filename}", content)
|
||||
filename = _key_filename(repository.key.encode("utf-8"))
|
||||
context.write_file(
|
||||
f"{_KEYS_DIR}/{filename}", repository.key.encode("utf-8")
|
||||
)
|
||||
logger.info("installed apk key %s", filename)
|
||||
return lines
|
||||
|
||||
@@ -9,7 +9,6 @@ as new, enabled `.sources` files.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
@@ -86,8 +85,9 @@ class AptModule(Module):
|
||||
@staticmethod
|
||||
def _write_configured_keys(context: Context) -> None:
|
||||
for key in context.config.configurations.apt.keys:
|
||||
content = base64.b64decode(key.content)
|
||||
context.write_file(f"{_KEYRINGS_DIR}/{key.name}.asc", content)
|
||||
context.write_file(
|
||||
f"{_KEYRINGS_DIR}/{key.name}.asc", key.content.encode("utf-8")
|
||||
)
|
||||
logger.info("installed apt keyring %s", key.name)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -8,7 +8,6 @@ a real Debian/Ubuntu system, instead of reimplementing that logic here.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
@@ -41,8 +40,10 @@ class CertificatesModule(Module):
|
||||
f"{_LOCAL_CERTS_DIR}/{existing.name}", existing.read_bytes()
|
||||
)
|
||||
for certificate in context.config.configurations.certificates:
|
||||
content = base64.b64decode(certificate.content)
|
||||
context.write_file(f"{_LOCAL_CERTS_DIR}/{certificate.name}.crt", content)
|
||||
context.write_file(
|
||||
f"{_LOCAL_CERTS_DIR}/{certificate.name}.crt",
|
||||
certificate.content.encode(),
|
||||
)
|
||||
logger.info("installed root certificate %s", certificate.name)
|
||||
self._update_ca_certificates_conf(context)
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ tool targets Docker images, which are built and run as root:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import json
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
@@ -77,8 +76,7 @@ def _find_cacerts(context: Context) -> list[Path]:
|
||||
|
||||
def _decode_certificates(certificates: list[NamedContent]) -> list[x509.Certificate]:
|
||||
return [
|
||||
x509.load_pem_x509_certificate(base64.b64decode(cert.content))
|
||||
for cert in certificates
|
||||
x509.load_pem_x509_certificate(cert.content.encode()) for cert in certificates
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ used (as `rpm --import` would).
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import configparser
|
||||
import logging
|
||||
import shutil
|
||||
@@ -90,7 +89,7 @@ def _validate_gpg_key(name: str, content: bytes) -> None:
|
||||
)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"gpg is not available; the gnupg package must be installed in the environment running id-configurator"
|
||||
"gpg is not available; the GNUPG package must be installed in the environment running id-configurator"
|
||||
)
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(
|
||||
@@ -99,9 +98,10 @@ def _validate_gpg_key(name: str, content: bytes) -> None:
|
||||
|
||||
|
||||
def _import_key(context: Context, key: NamedContent) -> None:
|
||||
content = base64.b64decode(key.content)
|
||||
_validate_gpg_key(key.name, content)
|
||||
context.write_file(f"{_RPM_GPG_DIR}/RPM-GPG-KEY-{key.name}", content)
|
||||
_validate_gpg_key(key.name, key.content.encode("utf-8"))
|
||||
context.write_file(
|
||||
f"{_RPM_GPG_DIR}/RPM-GPG-KEY-{key.name}", key.content.encode("utf-8")
|
||||
)
|
||||
logger.info("imported yum/dnf GPG key %s", key.name)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user