Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,7 @@ elif [ -x ${IGIMAGE}/post-image.sh ] ; then
else
runh ${IGTOP_IMAGE}/post-image.sh $IGconf_sys_deploydir
fi

# Save variables for subsequent build steps
mkdir -p "${IGconf_sys_deploydir}"
declare -p | grep IGconf_ > "${IGconf_sys_deploydir}/export_vars.sh"
2 changes: 2 additions & 0 deletions credentials24
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
device_user1=ubuntu
dEvIcE_UsER1pASs=ubuntu
image_name="michaels-test-build"
image_version="1.0.1-testing"
Empty file added credentials24.options
Empty file.
39 changes: 34 additions & 5 deletions digital-ocean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,42 @@ set -euo pipefail

# --- Configuration ---

IMG_DIR="work/ros2/deploy"
ORIG_IMAGE="${IMG_DIR}/ros2.img"
BASE_NAME="ros2"
# Load variables from the build step
if [ -f "deploy/export_vars.sh" ]; then
echo "Loading variables from deploy/export_vars.sh"
source "deploy/export_vars.sh"
fi

# These variables should be exported by the main build.sh script.
# This allows this deployment script to use the same configuration as the build.
IMG_DIR="${IGconf_sys_deploydir:-deploy}"
BASE_NAME="${IGconf_image_name:-ros2}"
IMAGE_SUFFIX="${IGconf_image_suffix:-img}"
ORIG_IMAGE="${IMG_DIR}/${BASE_NAME}.${IMAGE_SUFFIX}"

set -euo pipefail

# --- Configuration ---

# These variables should be exported by the build.sh script.
# This allows this deployment script to use the same configuration as the build.
IMG_DIR="${IGconf_sys_deploydir:-deploy}"
BASE_NAME="${IGconf_image_name:-michaels-test-build}"
IMAGE_SUFFIX="${IGconf_image_suffix:-img}"
ORIG_IMAGE="${IMG_DIR}/${BASE_NAME}.${IMAGE_SUFFIX}"

# Check if the original image file actually exists before proceeding.
if [ ! -f "${ORIG_IMAGE}" ]; then
echo "[ERROR] Image file not found: ${ORIG_IMAGE}"
echo "[ERROR] Make sure the build completed and IGconf_ variables are exported."
exit 1
fi

# Create a unique name for the compressed image to be uploaded.
CURRENT_DATE=$(date +%Y%m%d)
RANDOM_NUMBER=$(shuf -i 1000-9999 -n 1)
IMAGE_NAME="${BASE_NAME}_${CURRENT_DATE}_${RANDOM_NUMBER}.img"
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.xz"
UPLOAD_IMAGE_NAME="${BASE_NAME}_${CURRENT_DATE}_${RANDOM_NUMBER}.${IMAGE_SUFFIX}"
COMPRESSED_IMAGE_NAME="${UPLOAD_IMAGE_NAME}.xz"
COMPRESSED_IMAGE_FILE="${IMG_DIR}/${COMPRESSED_IMAGE_NAME}"
MASTER_DEST="/buildwork/${COMPRESSED_IMAGE_NAME}"

Expand Down
57 changes: 29 additions & 28 deletions image/post-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,33 @@ if [ -f ${IGconf_sys_outputdir}/genimage.cfg ] ; then
image2json -g ${IGconf_sys_outputdir}/genimage.cfg "${opts[@]}" > ${IGconf_sys_outputdir}/image.json
fi

msg "Deploying image and SBOM to ${deploydir}"

# Define the known source and desired destination file paths
SRC_IMG="${IGconf_sys_outputdir}/ros2.img"
SRC_SBOM="${IGconf_sys_outputdir}/${IGconf_image_name}.sbom"

DEST_IMG="${deploydir}/${IGconf_image_name}.${IGconf_image_suffix}"
DEST_SBOM="${deploydir}/${IGconf_image_name}.sbom"

# --- Deploy the image file ---
# Check if the source image file actually exists
if [ -f "${SRC_IMG}" ]; then
# Copy the source file to the destination, renaming it in the process
msg "Copying ${SRC_IMG} to ${DEST_IMG}"
cp -v "${SRC_IMG}" "${DEST_IMG}"
else
# If the source image isn't found, print a clear error and exit
die "FATAL: Source image ${SRC_IMG} not found!"
fi

files=()

for f in "${IGconf_sys_outputdir}/${IGconf_image_name}"*.${IGconf_image_suffix} ; do
files+=($f)
[[ -f "$f" ]] || continue

# Ensure that the output image is a multiple of the selected sector size
truncate -s %${IGconf_device_sector_size} $f
done

files+=("${IGconf_sys_outputdir}/${IGconf_image_name}"*.${IGconf_image_suffix}.sparse)
files+=("${IGconf_sys_outputdir}/${IGconf_image_name}"*.sbom)

msg "Deploying image and SBOM"

for f in "${files[@]}" ; do
[[ -f "$f" ]] || continue
case ${IGconf_image_compression} in
zstd)
zstd -v -f $f --sparse --output-dir-flat $deploydir
;;
none)
install -v -D -m 644 $f $deploydir
;;
*)
;;
esac
done
# --- Deploy the SBOM file ---
# Check if the source SBOM file exists
if [ -f "${SRC_SBOM}" ]; then
# Copy the source file to the destination
msg "Copying ${SRC_SBOM} to ${DEST_SBOM}"
cp -v "${SRC_SBOM}" "${DEST_SBOM}"
else
# This is not fatal, so just print a warning
msg "Warning: SBOM file ${SRC_SBOM} not found."
fi
8 changes: 1 addition & 7 deletions profile/ubuntu24-ros2-pi5
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
ubuntu/ubuntu
ubuntu/ros2
rpi/misc-utils
rpi/base/essential
ubuntu/firmware
ubuntu/kernel
ubuntu/ezmap
ubuntu/picam
ubuntu/zehno
rpi/user-credentials
rpi/misc-skel
ubuntu/dns
ubuntu/dns
35 changes: 35 additions & 0 deletions scripts/bdebstrap/customize90-image-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -eu

ROOTFS_DIR="$1"
INFO_FILE="${ROOTFS_DIR}/etc/image_info.txt"

# get distribution information from the image's /etc/os-release file.
DISTRO_INFO="Unknown"
if [ -f "${ROOTFS_DIR}/etc/os-release" ]; then
DISTRO_INFO=$(. "${ROOTFS_DIR}/etc/os-release"; echo "$PRETTY_NAME")
fi

# the Git hash of the rpi-image-gen
GIT_HASH="${GH:-"Not available"}"

# All IGconf_* variables are provided by the build system from the config and options files.
echo "Creating image info file at ${INFO_FILE}..."
cat << EOF > "${INFO_FILE}"
# Robot Image Information
# This file was automatically generated during the image build process.
IMAGE_NAME="${IGconf_image_name}"
IMAGE_VERSION="${IGconf_image_version}"
BUILD_DATE="$(date --utc +'%Y-%m-%d %H:%M:%S UTC')"
DISTRIBUTION="${DISTRO_INFO}"
BUILD_REPO_HASH="${GIT_HASH}"
EOF

# Add key info to the issue file
ISSUE_FILE="${ROOTFS_DIR}/etc/rpi-issue"
if [ -f "${ISSUE_FILE}" ]; then
echo "" >> "${ISSUE_FILE}"
echo "Image: ${IGconf_image_name} (${IGconf_image_version})" >> "${ISSUE_FILE}"
fi

echo "Image information successfully written."