erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

Error when using ash from busybox #752

Open asabil opened 5 years ago

asabil commented 5 years ago

The following error is printed in our logs when startin relx release on a system running busybox 1.29.3

od: invalid option -- 't'
BusyBox v1.29.3 (2019-08-15 21:56:01 UTC) multi-call binary.
Usage: od [-aBbcDdeFfHhIiLlOovXx] [FILE]

This is when busybox is built without CONFIG_DESKTOP, which is quite common on embedded systems.

tsloughter commented 4 years ago

We need a more generic way to generate a random id then:

relx_gen_id() {
    od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
}
tsloughter commented 4 years ago

What is CONFIG_DESKTOP?

I just tested with busybox and the od command works

docker run -ti busybox
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
bdbbaa22dec6: Already exists
Digest: sha256:6915be4043561d64e0ab0f8f098dc2ac48e077fe23f488ac24b665166898115a
Status: Downloaded newer image for busybox:latest
/ # od -t x -N 4 /dev/urandom
0000000 3532a62d
0000004
asabil commented 4 years ago

busybox has a lot of build time configurations, CONFIG_DESKTOP is one such option: https://git.busybox.net/busybox/tree/Config.in#n14

The Poky distro for Yocto, which is a common embedded "build system", defaults to disabling the DESKTOP config: https://git.yoctoproject.org/cgit.cgi/poky/tree/meta/recipes-core/busybox/busybox/defconfig#n11

Of course this can and should probably be overridden (which is what we do), but if we can find a fix for this one-liner, it would make a good 1st experience.

joaohf commented 3 years ago

Hello @asabil,

Could you check if it is working for your use case now ?

The current relx_gen_id is like this:

# Generate a random id
relx_gen_id() {
    dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x  | head -n1 | awk '{print $2$3}'
}