diff --git a/test/images/image-util.sh b/test/images/image-util.sh index 238bade438..fffd5f4b34 100755 --- a/test/images/image-util.sh +++ b/test/images/image-util.sh @@ -22,6 +22,7 @@ TASK=$1 IMAGE=$2 KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)" +source "${KUBE_ROOT}/hack/lib/util.sh" # Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" ) @@ -48,6 +49,8 @@ build() { archs=${!QEMUARCHS[@]} fi + kube::util::ensure-gnu-sed + for arch in ${archs}; do echo "Building image for ${IMAGE} ARCH: ${arch}..." @@ -66,19 +69,19 @@ build() { if [[ -f BASEIMAGE ]]; then BASEIMAGE=$(getBaseImage ${arch}) - sed -i "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile + ${SED} -i "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile fi # copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform if [[ $(grep "CROSS_BUILD_" Dockerfile) ]]; then if [[ "${arch}" == "amd64" ]]; then - sed -i "/CROSS_BUILD_/d" Dockerfile + ${SED} -i "/CROSS_BUILD_/d" Dockerfile else - sed -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile + ${SED} -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile # Register qemu-*-static for all supported processors except the current one docker run --rm --privileged multiarch/qemu-user-static:register --reset curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/${QEMUVERSION}/x86_64_qemu-${QEMUARCHS[$arch]}-static.tar.gz | tar -xz -C ${temp_dir} - sed -i "s/CROSS_BUILD_//g" Dockerfile + ${SED} -i "s/CROSS_BUILD_//g" Dockerfile fi fi @@ -101,7 +104,7 @@ push() { done # Make archs list into image manifest. Eg: 'amd64 ppc64le' to '${REGISTRY}/${IMAGE}-amd64:${TAG} ${REGISTRY}/${IMAGE}-ppc64le:${TAG}' - manifest=$(echo $archs | sed -e "s~[^ ]*~$REGISTRY\/$IMAGE\-&:$TAG~g") + manifest=$(echo $archs | ${SED} -e "s~[^ ]*~$REGISTRY\/$IMAGE\-&:$TAG~g") docker manifest create --amend ${REGISTRY}/${IMAGE}:${TAG} ${manifest} for arch in ${archs}; do docker manifest annotate --arch ${arch} ${REGISTRY}/${IMAGE}:${TAG} ${REGISTRY}/${IMAGE}-${arch}:${TAG}