@@ -23,19 +23,29 @@ COPY ubi-build-files-${TARGETARCH}.txt /tmp
2323# Filter existing files and exclude temporary entitlement files that may be removed during build
2424RUN set -e && \
2525 # Filter files that actually exist (files, directories, or symlinks)
26+ # This ensures we only copy files that are present, avoiding "Cannot stat" errors
2627 while IFS= read -r file; do \
2728 [ -n "$file" ] && ([ -e "$file" ] || [ -L "$file" ]) && echo "$file"; \
2829 done < /tmp/ubi-build-files-${TARGETARCH}.txt > /tmp/existing-files.txt && \
29- # Create tarball if we have files to archive
30- if [ -s /tmp/existing-files.txt ]; then \
31- tar -chf /tmp/files.tar \
32- --exclude='etc/pki/entitlement-host*' \
33- -T /tmp/existing-files.txt 2>&1 | grep -vE "(File removed before we read it|Cannot stat)" || true; \
34- # Extract only if tarball was created successfully
35- if [ -f /tmp/files.tar ]; then \
36- tar -xf /tmp/files.tar -C /image/ && \
37- rm -f /tmp/files.tar; \
38- fi; \
30+ # Verify we have files to copy (fail if list is empty to catch configuration issues)
31+ if [ ! -s /tmp/existing-files.txt ]; then \
32+ echo "ERROR: No files found to copy from ubi-build-files-${TARGETARCH}.txt" >&2; \
33+ echo "This indicates the base image may be missing required files or the file list is incorrect." >&2; \
34+ echo "Expected files from ubi-build-files-${TARGETARCH}.txt:" >&2; \
35+ cat /tmp/ubi-build-files-${TARGETARCH}.txt >&2; \
36+ exit 1; \
37+ fi && \
38+ # Create tarball, excluding only temporary entitlement files (safe to exclude)
39+ # Note: --exclude only affects files within directories being archived, not the directories themselves
40+ tar -chf /tmp/files.tar \
41+ --exclude='etc/pki/entitlement-host*' \
42+ -T /tmp/existing-files.txt 2>&1 | grep -vE "(File removed before we read it|Cannot stat)" || true; \
43+ # Extract tarball (critical files like libc.so.6, ld-linux, etc/ssl/certs are included)
44+ if [ -f /tmp/files.tar ]; then \
45+ tar -xf /tmp/files.tar -C /image/ && \
46+ rm -f /tmp/files.tar; \
47+ else \
48+ echo "WARNING: Tarball was not created, but continuing..." >&2; \
3949 fi && \
4050 # Clean up temporary file list
4151 rm -f /tmp/existing-files.txt
0 commit comments