Setup necessary mounts for to-release deployment

In order to start a GA release deployment, mounts to drbd file
systems should be created to alternate ostree deployment branch
(i.e, /sysroot/ostree/<1|2>). This commit creates a yaml file to
be used by apt-ostree to do the mounts.

Test Plan:
Mounts created with success
Pkg build with success

Story: 2010676
Task: 48829

Change-Id: I53609a91475f0871475247687ae7d01278a42a82
Signed-off-by: Luis Eduardo Bonatti <LuizEduardo.Bonatti@windriver.com>
This commit is contained in:
Luis Eduardo Bonatti 2023-09-25 14:50:00 -03:00
parent 36b39028b2
commit d60e9de244
3 changed files with 76 additions and 0 deletions

View File

@ -64,4 +64,8 @@ override_dh_install:
${ROOT}/usr/sbin/platform-upgrade-precheck
install -m 444 ${METADATA_FILE} \
${ROOT}/etc/software/${METADATA_FILE}
install -m 755 scripts/chroot_mounts.sh \
${ROOT}/usr/bin/chroot_mounts.sh
install -m 444 scripts/ostree_mounts.yaml \
${ROOT}/etc/software/ostree_mounts.yaml
dh_install

View File

@ -0,0 +1,62 @@
#!/bin/bash
#
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
DEV_PATH=/dev
PLATFORM_PATH=/opt/platform
RABBIT_PATH=/var/lib/rabbitmq
POSTGRES_UPGRADE_PATH=/var/lib/postgresql/upgrade
PLATFORM_CONF_PATH=/etc/platform
TMP_PATH=/tmp
USR_PATH=/usr
ETC_PATH=/etc
PROC_PATH=/proc
mount_points=(
"$DEV_PATH"
"$PROC_PATH"
"$PLATFORM_PATH"
"$RABBIT_PATH"
"$POSTGRES_UPGRADE_PATH"
)
if [ -z "$1" ]; then
echo "Error: Ostree deployment branch parameter is missing."
exit 1
fi
OSTREE_DEPLOYMENT_BRANCH="$1"
handle_error() {
local exit_code="$1"
local error_message="$2"
echo "Error: $error_message" >&2
echo "Please check the error details and take appropriate action for recovery." >&2
exit "$exit_code"
}
for dir in "${mount_points[@]}"; do
target_dir=${OSTREE_DEPLOYMENT_BRANCH}${dir}
if [ ! -d "$target_dir" ]; then
sudo mkdir -p "$target_dir"
fi
sudo mount --bind "$dir" "$target_dir" ||
handle_error 1 "Failed to bind mount $dir to $target_dir"
done
if [ ! -d "${TMP_PATH}${PLATFORM_CONF_PATH}" ]; then
mkdir -p "${TMP_PATH}${PLATFORM_CONF_PATH}"
fi
sudo mount --bind "${OSTREE_DEPLOYMENT_BRANCH}${USR_PATH}${ETC_PATH}" "${OSTREE_DEPLOYMENT_BRANCH}${ETC_PATH}" ||
handle_error 1 "Failed to bind mount ${OSTREE_DEPLOYMENT_BRANCH}${USR_PATH}${ETC_PATH} to
${OSTREE_DEPLOYMENT_BRANCH}${ETC_PATH}"
sudo mount --bind "${PLATFORM_CONF_PATH}" "${TMP_PATH}${PLATFORM_CONF_PATH}" ||
handle_error 1 "Failed to bind mount ${PLATFORM_CONF_PATH} to ${TMP_PATH}${PLATFORM_CONF_PATH}"

View File

@ -0,0 +1,10 @@
---
- /etc/platform:/tmp/etc/platform
- "{{ OSTREE_DEPLOYMENT_BRANCH }}/usr/etc:{{ OSTREE_DEPLOYMENT_BRANCH }}/etc"
- "/dev:{{ OSTREE_DEPLOYMENT_BRANCH }}/dev"
- "/proc:{{ OSTREE_DEPLOYMENT_BRANCH }}/proc"
- "/opt/platform:{{ OSTREE_DEPLOYMENT_BRANCH }}/opt/platform"
- "/var/lib/rabbitmq:{{ OSTREE_DEPLOYMENT_BRANCH }}/var/lib/rabbitmq"
- >
"/var/lib/postgresql/upgrade:
{{ OSTREE_DEPLOYMENT_BRANCH }}/var/lib/postgresql/upgrade"