Merge pull request #66585 from dims/avoid-sed-bundled-with-darwin

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Avoid sed bundled with Darwin for building test images

Change-Id: I4fc1d495c9a42d081107829cfae0cad6d5aa29ff
Signed-off-by: Davanum Srinivas <davanum@gmail.com>



**What this PR does / why we need it**:
using plain old `sed` we run into problems on macOS. for example when you try `make all-container WHAT=net` under test/images. We should use the same pattern we use in all our scripts to ensure we use gsed or a version of sed from GNU.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:
/cc @mkumatag @BenTheElder @cjwagner 

**Release note**:

```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-07-25 12:09:42 -07:00 committed by GitHub
commit c8516782f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -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}