-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·117 lines (98 loc) · 4.06 KB
/
build.sh
File metadata and controls
executable file
·117 lines (98 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
set -exo pipefail
source ./util.sh
echo "Preparing to build ${FULL_IMAGE_NAME}"
echo " Building image locally"
# Validate PODMAN_PR_NUM var, see the Containerfile for the pull logic.
case "${PODMAN_PR_NUM}" in
'') echo "Will install podman from the podman-next copr, the podman version is ignored" ;;
[0-9]*) ;;
*) echo 'PODMAN_PR_NUM must be empty or set to a valid PR number' 1>&2; exit 1;;
esac
# koji tags prepend "f" to the release (rpm --eval)
FEDORA_VERSION="f"$(podman run --rm "$FCOS_BASE_IMAGE" rpm --eval '%{?fedora}')
export FEDORA_VERSION
mkdir -p ./rpms
# Don't fail if koji download-build can't find any rpms
set +e
if [[ ${PODMAN_PR_NUM} != "" ]]; then
pushd ./rpms
for pkg in container-selinux crun;
do
for tag in "${FEDORA_VERSION}"-updates-candidate "${FEDORA_VERSION}"-updates-testing "${FEDORA_VERSION}"-updates-testing-pending;
do
koji download-build --latestfrom="$tag" -a "$(arch)" -a noarch "$pkg"
if [[ $? -eq 1 ]]; then
echo "Continuing..."
continue
fi
done
done
for pkg in aardvark-dns containers-common netavark;
do
for tag in $(koji list-sidetags --user=packit | grep "${FEDORA_VERSION}")
do
koji download-build --latestfrom="$tag" -a "$(arch)" -a noarch "$pkg"
if [[ $? -eq 1 ]]; then
echo "Continuing..."
continue
fi
done
done
rm -f crun-krun*.rpm crun-wasm*.rpm
popd
fi
set -e
ZSTD_CMD="zstd --rm -T0 -14"
WSL_LOG=$(mktemp)
mkdir -p "$OUTDIR"
# Spawn a subshell so we can run the WSL build in parallel as well.
(
tarfile="${OUTDIR}/$DISK_IMAGE_NAME.$CPU_ARCH.wsl.tar"
podman build --output type=tar,dest="$tarfile" \
-f podman-image/Containerfile.WSL "${PWD}"/podman-image \
--build-arg PODMAN_PR_NUM="${PODMAN_PR_NUM}" \
--build-arg FEDORA_VERSION="${FEDORA_VERSION:1}"
$ZSTD_CMD $tarfile
) &>$WSL_LOG &
# First kill the WSL job if we exit the script (ignoring error in case the job already finished)
# Then print the WSL logs so we always see what it did.
trap "kill %1 || true; echo; echo 'WSL build log:'; cat $WSL_LOG" EXIT
# See podman-rpm-info-vars.sh for all build-arg values. If PODMAN_PR_NUM is
# empty, the rpm version, release and fedora release values are of no concern
# to the build process.
podman build -t "${FULL_IMAGE_NAME_ARCH}" -v "$PWD"/rpms:/var/tmp/rpms \
-f podman-image/Containerfile.COREOS "${PWD}"/podman-image \
--build-arg FCOS_BASE_IMAGE="${FCOS_BASE_IMAGE}" \
--build-arg PODMAN_PR_NUM="${PODMAN_PR_NUM}"
# Use rpm-ostree rechunk to remove unwanted data/packages and save space where can
echo "Re-Chunking to make incremental upgrades more efficient"
rpm-ostree compose build-chunked-oci \
--bootc --from "${FULL_IMAGE_NAME_ARCH}" \
--output "oci-archive:${OUTDIR}/${DISK_IMAGE_NAME}"
echo "Transforming OCI image into disk image"
# Get supported CoreOS platforms for this architecture and convert space-separated to comma-separated
# (WSL is built separately and not included here)
PLATFORMS="${ARCH_TO_COREOS_PLATFORMS[$CPU_ARCH]// /,}"
pushd "$OUTDIR" && sh "$SRCDIR"/custom-coreos-disk-images/custom-coreos-disk-images.sh \
--platforms "$PLATFORMS" \
--ociarchive "${PWD}/${DISK_IMAGE_NAME}" \
--osname fedora-coreos \
--imgref "ostree-unverified-registry:$FULL_IMAGE_NAME" \
--metal-image-size 6144 \
--extra-kargs='ostree.prepare-root.composefs=0'
echo "Compressing disk images with zstd"
# note: we are still "in" the outdir at this point
# Only process CoreOS platforms supported by this architecture (WSL is already compressed)
for hypervisor in ${ARCH_TO_COREOS_PLATFORMS[$CPU_ARCH]}; do
# Rename the file to our preferred format
extension="${PLATFORM_TO_DISKTYPE[$hypervisor]}"
filename="${DISK_IMAGE_NAME}-${hypervisor}.${CPU_ARCH}.${extension}"
newfilename="${DISK_IMAGE_NAME}.${CPU_ARCH}.${hypervisor}.${extension}"
mv "$filename" "$newfilename"
# Compress the file
$ZSTD_CMD "$newfilename"
done
popd
# Wait for the WSL build to finish
wait -n