-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from SoftwareDefinedVehicle/airgap-containers
Airgapped installation of containers
- Loading branch information
Showing
17 changed files
with
232 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
meta-leda-components/recipes-sdv/eclipse-leda/airgap-container-installer.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# /******************************************************************************** | ||
# * Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# * | ||
# * See the NOTICE file(s) distributed with this work for additional | ||
# * information regarding copyright ownership. | ||
# * | ||
# * This program and the accompanying materials are made available under the | ||
# * terms of the Apache License 2.0 which is available at | ||
# * https://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * SPDX-License-Identifier: Apache-2.0 | ||
# ********************************************************************************/ | ||
|
||
SUMMARY = "Airgapped Container Installer" | ||
DESCRIPTION = "A service that installs pre-downloaded container images in a specified directory" | ||
|
||
FILESEXTRAPATHS:prepend := "${THISDIR}/files:" | ||
SRC_URI:append = " file://airgap-container-installer" | ||
SRC_URI:append = " file://airgap-container-installer.service.template" | ||
|
||
LICENSE = "Apache-2.0" | ||
LIC_FILES_CHKSUM = "file://${THISDIR}/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" | ||
|
||
PREINSTALLED_CTR_IMAGES_DIR ??= "/var/constainers/images" | ||
PREINSTALLED_CTR_IMAGES_DIR[doc] = "Sets the path to the directory where the downloaded container tar files are stored in the final image" | ||
|
||
inherit systemd | ||
SYSTEMD_AUTO_ENABLE = "enable" | ||
SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}" | ||
SYSTEMD_SERVICE:${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','airgap-container-installer.service','',d)}" | ||
AG_SERVICE_DIR = "${systemd_unitdir}/system" | ||
|
||
install_service() { | ||
install -d ${D}${AG_SERVICE_DIR} | ||
install -m 0644 ${WORKDIR}/airgap-container-installer.service.template ${D}${AG_SERVICE_DIR}/airgap-container-installer.service | ||
sed -e 's,@AG_BIN_DD@,${bindir},g' \ | ||
-e 's,@AG_IMG_DD@,${PREINSTALLED_CTR_IMAGES_DIR},g' \ | ||
-i ${D}${AG_SERVICE_DIR}/airgap-container-installer.service | ||
} | ||
|
||
do_install() { | ||
install -d ${D}${bindir} | ||
install -m 0755 ${WORKDIR}/airgap-container-installer ${D}${bindir} | ||
install_service | ||
} | ||
|
||
FILES:${PN} += " ${bindir}/airgap-container-installer" | ||
FILES:${PN} += " ${AG_SERVICE_DIR}/airgap-container-installer.service" | ||
|
||
PACKAGES = "${PN}" |
67 changes: 67 additions & 0 deletions
67
meta-leda-components/recipes-sdv/eclipse-leda/files/airgap-container-installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC3043 | ||
# shellcheck disable=SC1091 | ||
# shellcheck disable=SC2086 | ||
# shellcheck disable=SC2034 | ||
# shellcheck disable=SC2059 | ||
# /******************************************************************************** | ||
# * Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# * | ||
# * See the NOTICE file(s) distributed with this work for additional | ||
# * information regarding copyright ownership. | ||
# * | ||
# * This program and the accompanying materials are made available under the | ||
# * terms of the Apache License 2.0 which is available at | ||
# * https://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * SPDX-License-Identifier: Apache-2.0 | ||
# ********************************************************************************/ | ||
|
||
tar_dir=$1 | ||
IMPORTED_CTRS_LOCK_NAME="imported-ctrs.lock" | ||
|
||
if [ -z "${tar_dir}" ]; then | ||
echo "Using current working directory as image directory" | ||
tar_dir=$(pwd) | ||
fi | ||
|
||
if [ ! -d "${tar_dir}" ]; then | ||
echo "${tar_dir} either does not exist or is not a directory" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$(ls -A ${tar_dir}/*.tar* 2>/dev/null)" ]; then | ||
echo "Nothing to install" | ||
exit 0 | ||
fi | ||
|
||
# ctr image import is very slow even when importing the same image twice | ||
# we keep a list of already imported images and we skip them | ||
LOCK_PATH="${tar_dir}/${IMPORTED_CTRS_LOCK_NAME}" | ||
if [ ! -f ${LOCK_PATH} ]; then | ||
echo "Lock at ${LOCK_PATH} does not exist. Creating an empty lock." | ||
echo "# THIS FILE KEEPS A LOG OF ALL IMAGES ALREADY IMPORTED BY AIRGAP-CONTAINER-INSTALLER.SERVICE" >>${LOCK_PATH} | ||
echo "# DELETE ANY LINES FOR IMAGES THAT YOU WISH TO BE RE-IMPORTED ON SERVICE RESTART" >>${LOCK_PATH} | ||
echo "Created ${LOCK_PATH}" | ||
fi | ||
|
||
for tar_image in "${tar_dir}"/*.tar*; do | ||
echo "Loading ${tar_image}..." | ||
tar_base_name=$(basename ${tar_image}) | ||
if grep -Fxq "$tar_base_name" ${LOCK_PATH}; then | ||
# Container image already imported, skipping... | ||
echo "Already imported...Skipping" | ||
continue | ||
else | ||
echo "Importing new image" | ||
import_msg=$(ctr --namespace kanto-cm image import ${tar_image} --no-unpack) | ||
import_rc=$? | ||
if [ $import_rc -eq 0 ]; then | ||
echo "${tar_base_name}" >>${LOCK_PATH} | ||
echo "Imported" | ||
else | ||
echo "Importing ${tar_image} failed with message: ${import_msg}, rc: ${import_rc}" | ||
continue | ||
fi | ||
fi | ||
done |
28 changes: 28 additions & 0 deletions
28
...eda-components/recipes-sdv/eclipse-leda/files/airgap-container-installer.service.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# /******************************************************************************** | ||
# * Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# * | ||
# * See the NOTICE file(s) distributed with this work for additional | ||
# * information regarding copyright ownership. | ||
# * | ||
# * This program and the accompanying materials are made available under the | ||
# * terms of the Apache License 2.0 which is available at | ||
# * https://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * SPDX-License-Identifier: Apache-2.0 | ||
# ********************************************************************************/ | ||
# Eclipse Leda | ||
|
||
[Unit] | ||
Description=Airgap Container Installer | ||
After=containerd.service | ||
Before=container-management.service | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
Restart=on-failure | ||
RestartSec=5s | ||
ExecStart=@AG_BIN_DD@/airgap-container-installer @AG_IMG_DD@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
meta-leda-components/recipes-sdv/packagegroups/packagegroup-sdv-airgap-containers.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# /******************************************************************************** | ||
# * Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# * | ||
# * See the NOTICE file(s) distributed with this work for additional | ||
# * information regarding copyright ownership. | ||
# * | ||
# * This program and the accompanying materials are made available under the | ||
# * terms of the Apache License 2.0 which is available at | ||
# * https://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * SPDX-License-Identifier: Apache-2.0 | ||
# ********************************************************************************/ | ||
|
||
SUMMARY = "SDV pre-downloaded containers" | ||
DESCRIPTION = "Pre-downloaded (airgapped) containers that would be installed in the image by default" | ||
|
||
inherit packagegroup | ||
|
||
RDEPENDS:${PN} = "\ | ||
sdv-kuksa-val-databroker \ | ||
sdv-container-seatservice \ | ||
sdv-container-selfupdateagent \ | ||
sdv-container-cloudconnector \ | ||
sdv-container-vehicleupdatemanager \ | ||
sdv-container-hvacservice \ | ||
sdv-container-feedercan \ | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
meta-leda-components/recipes-sdv/sdv-containers/sdv-container-hvacservice_0.1.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# /******************************************************************************** | ||
# * Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# * | ||
# * See the NOTICE file(s) distributed with this work for additional | ||
# * information regarding copyright ownership. | ||
# * | ||
# * This program and the accompanying materials are made available under the | ||
# * terms of the Apache License 2.0 which is available at | ||
# * https://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * SPDX-License-Identifier: Apache-2.0 | ||
# ********************************************************************************/ | ||
|
||
SUMMARY = "SDV Example HVAC Service" | ||
DESCRIPTION = "Example HVAC service" | ||
|
||
inherit sdv-container-cache | ||
|
||
SRC_URI += "file://README.txt \ | ||
file://LICENSE" | ||
|
||
# According to https://wiki.yoctoproject.org/wiki/License_Infrastructure_Interest_Group | ||
LICENSE = "Apache-2.0" | ||
LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" | ||
|
||
# Define image to be pulled | ||
SDV_IMAGE_REF="ghcr.io/eclipse/kuksa.val.services/hvac_service" | ||
SDV_IMAGE_TAG="v0.1.0" | ||
|
||
# Override container architecture. If not set, recipe tries autodetection for target machine architecture. | ||
#CONTAINER_ARCH="arm64" | ||
|
||
# Skip pre-caching of a container if target architecture does not exist | ||
CONTAINER_SKIP_MISSING_ARCH="1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters