Skip to content

Commit ebcb94c

Browse files
authored
PE-5843: add support to create new partition for content (#512)
* add support to create new partition for content * fix partition * extend partition * fix partition issue * make content , state , pseristent partition optional * fix extra partition issue
1 parent b4fbe06 commit ebcb94c

File tree

6 files changed

+1107
-10
lines changed

6 files changed

+1107
-10
lines changed

Earthfile

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,23 @@ iso-image:
879879
RUN rm -f /usr/bin/luet
880880
END
881881
COPY overlay/files/ /
882-
# IF [ "$IS_CLOUD_IMAGE" = "true" ]
883-
# COPY cloud-images/workaround/grubmenu.cfg /etc/kairos/branding/grubmenu.cfg
884-
# COPY cloud-images/workaround/custom-post-reset.yaml /system/oem/custom-post-reset.yaml
885-
# END
882+
IF [ "$IS_CLOUD_IMAGE" = "true" ]
883+
COPY cloud-images/workaround/grubmenu.cfg /etc/kairos/branding/grubmenu.cfg
884+
COPY cloud-images/workaround/custom-post-reset.yaml /system/oem/custom-post-reset.yaml
885+
RUN mkdir -p /opt/spectrocloud/scripts
886+
COPY cloudconfigs/cloud-content.sh /opt/spectrocloud/scripts/cloud-content.sh
887+
RUN chmod 755 /opt/spectrocloud/scripts/cloud-content.sh
888+
COPY cloudconfigs/cloud-extend-persistent.sh /opt/spectrocloud/scripts/cloud-extend-persistent.sh
889+
RUN chmod 755 /opt/spectrocloud/scripts/cloud-extend-persistent.sh
890+
891+
# Add local-ui if provided (extract it directly to the image)
892+
# Note: local-ui is handled directly in the iso-image build, not via content partition
893+
COPY --if-exists local-ui.tar /opt/spectrocloud/
894+
RUN if [ -f /opt/spectrocloud/local-ui.tar ]; then \
895+
tar -xf /opt/spectrocloud/local-ui.tar -C /opt/spectrocloud && \
896+
rm -f /opt/spectrocloud/local-ui.tar; \
897+
fi
898+
END
886899

887900
IF [ -f /etc/logrotate.d/stylus.conf ]
888901
RUN chmod 644 /etc/logrotate.d/stylus.conf
@@ -919,7 +932,18 @@ cloud-image:
919932
FROM --allow-privileged earthly/dind:alpine-3.19-docker-25.0.5-r0
920933
# Copy the config file first if it exists
921934
COPY --if-exists +validate-user-data/user-data /config.yaml
922-
WORKDIR /output
935+
# Copy content partition script
936+
COPY cloud-images/scripts/add-content-partition.sh /add-content-partition.sh
937+
RUN chmod +x /add-content-partition.sh && \
938+
ls -la /add-content-partition.sh && \
939+
head -n 1 /add-content-partition.sh
940+
# Copy content files, SPC, and edge-config if they exist
941+
# Note: content-* directories need to be copied preserving their names
942+
# Note: local-ui is handled directly in the iso-image build, not via content partition
943+
COPY --if-exists content-*/ /workdir/
944+
COPY --if-exists "$CLUSTERCONFIG" /workdir/spc.tgz
945+
COPY --if-exists "$EDGE_CUSTOM_CONFIG" /workdir/edge_custom_config.yaml
946+
WORKDIR /workdir
923947

924948
WITH DOCKER \
925949
--pull quay.io/kairos/auroraboot:v0.16.0 \
@@ -953,7 +977,49 @@ cloud-image:
953977
--set "disable_netboot=true" \
954978
--set "disk.raw=true" \
955979
--set "state_dir=/aurora"; \
956-
fi
980+
fi && \
981+
echo "=== Finding raw image created by auroraboot ===" && \
982+
RAW_IMG=$(find /output -type f \( -name "*.raw" -o -name "*.img" \) | head -n1) && \
983+
if [ -z "$RAW_IMG" ]; then \
984+
echo "Error: No raw image found in /output" >&2; \
985+
ls -laR /output; \
986+
exit 1; \
987+
fi && \
988+
echo "Found raw image: $RAW_IMG" && \
989+
echo "=== Adding COS_CONTENT partition ===" && \
990+
apk add --no-cache qemu-img parted multipath-tools dosfstools e2fsprogs util-linux coreutils device-mapper bash rsync gptfdisk && \
991+
echo "=== Debug: Checking for content files ===" && \
992+
echo "Current directory: $(pwd)" && \
993+
echo "Content directories:" && \
994+
ls -la /workdir/content-* 2>/dev/null || echo "No content-* directories found" && \
995+
echo "Files in /workdir:" && \
996+
ls -la /workdir/ 2>/dev/null || echo "Cannot list /workdir" && \
997+
CLUSTERCONFIG_FILE="" && \
998+
if [ -f /workdir/spc.tgz ]; then CLUSTERCONFIG_FILE="/workdir/spc.tgz"; echo "Found SPC file: $CLUSTERCONFIG_FILE"; fi && \
999+
EDGE_CUSTOM_CONFIG_FILE="" && \
1000+
if [ -f /workdir/edge_custom_config.yaml ]; then EDGE_CUSTOM_CONFIG_FILE="/workdir/edge_custom_config.yaml"; echo "Found EDGE_CUSTOM_CONFIG: $EDGE_CUSTOM_CONFIG_FILE"; fi && \
1001+
echo "=== Running add-content-partition.sh ===" && \
1002+
echo "Checking script location..." && \
1003+
ls -la /add-content-partition.sh 2>&1 || echo "Script not found at /add-content-partition.sh" && \
1004+
if [ ! -f /add-content-partition.sh ]; then \
1005+
echo "Error: Script /add-content-partition.sh not found" >&2; \
1006+
echo "Checking for script in common locations:" >&2; \
1007+
find / -name "add-content-partition.sh" 2>/dev/null | head -5 || echo "Script not found anywhere" >&2; \
1008+
exit 1; \
1009+
fi && \
1010+
echo "Script found, checking permissions..." && \
1011+
ls -la /add-content-partition.sh && \
1012+
CLUSTERCONFIG="$CLUSTERCONFIG_FILE" \
1013+
EDGE_CUSTOM_CONFIG="$EDGE_CUSTOM_CONFIG_FILE" \
1014+
bash /add-content-partition.sh "$RAW_IMG" || { \
1015+
echo "Error: Failed to add content partition. Build cannot continue." >&2; \
1016+
echo "Debug info:" >&2; \
1017+
echo " RAW_IMG: $RAW_IMG" >&2; \
1018+
echo " Current dir: $(pwd)" >&2; \
1019+
echo " Script exists: $([ -f /add-content-partition.sh ] && echo 'yes' || echo 'no')" >&2; \
1020+
echo " Script location: $(ls -la /add-content-partition.sh 2>&1 || echo 'not found')" >&2; \
1021+
exit 1; \
1022+
}
9571023
END
9581024
SAVE ARTIFACT /output/* AS LOCAL ./build/
9591025

0 commit comments

Comments
 (0)