TheSin- / rpi-img-builder

Scripts to create custom images for RaspberryPi
MIT License
107 stars 30 forks source link

Fail to build inside docker container #18

Closed jano42 closed 6 years ago

jano42 commented 6 years ago

I've created a fresh new docker container.

https://hub.docker.com/r/yadoms/ubuntu_rpi_image/

It is based on Ubuntu 17.04, and prerequisites are installed.

When running "make" I've got an error.

The command

make UNAME=$userAccountLogin UPASS=$userAccountPassword RPASS=$rootAccountPassword

The error

chroot: failed to run command '/bin/bash': Exec format error
rootfs.mak:106: recipe for target '/builder/rootfs' failed
Makefile:21: recipe for target 'build-rootfs' failed
make[1]: *** [/builder/rootfs] Error 126
make: *** [build-rootfs] Error 2

The log

rpi_image_builder.log

I've tested with explicit 32 or 64 bits, but I still have the same errors.

Is there something missing ?

TheSin- commented 6 years ago

I don't use docker so I'm a bit in the dark here, but to me it seems like qemu-static is missing. The error is saying that /bin/bash in the roots dir is the wrong format so it can't exec it.

in the log that is 32bit aka armhf, so you need to make sure you have qemu-arm-static avail in the builder (docker?) so that it can get copied into rootfs, it then gets removed once we are done with it.

TheSin- commented 6 years ago

I'll add a check for QEMU with a proper error, maybe that will help.

TheSin- commented 6 years ago

there try that

TheSin- commented 6 years ago

did you get this working? Is this ticket still an issue?

dspasojevic commented 6 years ago

I am having what looks like a similar problem:

Processing plugins/stretch/extrapackages...
 - found packages ... adding
Processing plugins/stretch/noPersistentNetGen...
 - found files ... adding
Processing plugins/stretch/oldNetNaming...
 - found files ... adding
Processing plugins/alsa...
 - found packages ... adding
 - found postinst ... adding
Processing plugins/common...
 - found files ... adding
 - found packages ... adding
 - found postinst ... adding
Processing plugins/dbreconfig...
 - found files ... adding
 - found packages ... adding
 - found postinst ... adding
Processing plugins/disableroot...
 - found postinst ... adding
Processing plugins/extrapackages...
 - found packages ... adding
Processing plugins/fake-hwclock...
 - found packages ... adding
 - found postinst ... adding
Processing plugins/fsckboot...
 - found packages ... adding
 - found postinst ... adding
Processing plugins/hostname...
 - found files ... adding
 - found packages ... adding
 - found postinst ... adding
Processing plugins/resizefs...
 - found files ... adding
 - found packages ... adding
 - found postinst ... adding
Processing plugins/sshkeys...
 - found files ... adding
 - found postinst ... adding
Processing plugins/swap...
 - found packages ... adding
 - found postinst ... adding
Processing plugins/tmpfs...
 - found packages ... adding
 - found postinst ... adding
mount: permission denied
rootfs.mak:112: recipe for target '/opt/rpi-img-builder/rootfs' failed
make: *** [/opt/rpi-img-builder/rootfs] Error 32

Section in rootfs.mak in the version that I have is:

   111  $(ROOTFS_DIR): $(ROOTFS_DIR).base
   112      rsync --quiet --archive --devices --specials --hard-links --acls --xattrs --sparse $(ROOTFS_DIR).base/* $@

This looks to be after the QEMU check that you added.

dspasojevic commented 6 years ago

For me, the problem was solved by running the container with --privileged. It seems strange that it is necessary though.

TheSin- commented 6 years ago

sadly I know very little about docker, that being said it does run apt-get which required root proves to run. You might be able to solve this by giving the required perms to the run you want to run as?

dspasojevic commented 6 years ago

The docker container running rpi-img-builder needs the privileged permission to perform the mount, so I guess it is understandable.

My contribution to this issue is not helpful - probably different to the problem @jano42 was having.

jano42 commented 6 years ago

@TheSin- Sorry for answer delay; but issue is still opened. With the qemu check, it does not change (path is found)

jano42 commented 6 years ago

I finally manage to make qemu works. This was a problem with the Docker container and its entrypoint.

My tests are still in progress (I still have other errors which I try to solve one by one).

When all will be ok; I'll publish my docker file and my entrypoint (so you could reuse it)

jano42 commented 6 years ago

success ! I'm able to build a raspberrypi image inside docker container.

To do that, you must have a specific Docker file, using an entrypoint which is making the good commands.

See attached files Dockerfile+entrypoint.zip