linuxkit / kubernetes

minimal and immutable Kubernetes images built with LinuxKit
Apache License 2.0
400 stars 75 forks source link

make update-hashes is not portable #52

Closed errordeveloper closed 6 years ago

errordeveloper commented 6 years ago

It fails on macOS:

> make update-hashes
set -e ; for tag in $(linuxkit pkg show-tag pkg/kubelet) \
               $(linuxkit pkg show-tag pkg/cri-containerd) \
               $(linuxkit pkg show-tag pkg/kubernetes-docker-image-cache-common) \
               $(linuxkit pkg show-tag pkg/kubernetes-docker-image-cache-control-plane) ; do \
        image=${tag%:*} ; \
        git grep -E -l "\b$image:" | xargs --no-run-if-empty sed -i.bak -e "s,$image:[[:xdigit:]]\{40\}\(-dirty\)\?,$tag,g" ; \
    done
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
make: *** [update-hashes] Error 1
ijc commented 6 years ago

Ah, it's the old lack of xargs --no-run-if-empty on MacOS, I think.

Perhaps a while read loop will do for the inner loop instead, something like:

git grep -E -l "\b$image:" | while read f ; do sed -i.bak -e "s,$image:[[:xdigit:]]\{40\}\(-dirty\)\?,$tag,g" "$f" ; done

will do the job.

ijc commented 6 years ago

Or maybe drop the --no-run-if-empty but add a /dev/null to the end (so sed always gets some input file).

errordeveloper commented 6 years ago

Don't you think we need gsed also?

On Tue, 23 Jan 2018, 9:55 am Ian Campbell, notifications@github.com wrote:

Or maybe drop the --no-run-if-empty but add a /dev/null to the end (so sed always gets some input file).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/linuxkit/kubernetes/issues/52#issuecomment-359738218, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPWS4bYFlzPVrh8BvQS4BHYiWTWt_Vwks5tNax8gaJpZM4RoWGB .

ijc commented 6 years ago

Don't you think we need gsed also?

There's not currently any reason suggested here why we would, but I could believe it would be blocked by the xargs issue since sed is never actually executed while the problem is present so it might rear its head soon.

If the sed expression is non-portable (not sure about the portability of [:xdigit:] for example) then I would rather change it to be portable than require people to install gsed (and to hack up our build to call it when appropriate).

errordeveloper commented 6 years ago

Thanks, Ian!

On Tue, 30 Jan 2018, 11:41 am Ian Campbell, notifications@github.com wrote:

Closed #52 https://github.com/linuxkit/kubernetes/issues/52 via #55 https://github.com/linuxkit/kubernetes/pull/55.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/linuxkit/kubernetes/issues/52#event-1448356010, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPWS9rgLvCPYVa31gX85OpokqF7czqqks5tPv_ggaJpZM4RoWGB .