Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example from README does not work #10

Closed
bitfehler opened this issue Jan 22, 2020 · 1 comment
Closed

Example from README does not work #10

bitfehler opened this issue Jan 22, 2020 · 1 comment

Comments

@bitfehler
Copy link
Contributor

The README contains the following example:

sudo ./alpine-make-rootfs \  # (1)
    --branch v3.8 \  # (2)
    --packages 'ruby ruby-bigdecimal sqlite' \  # (3)
    --timezone 'Europe/Prague' \  # (4)
    --script-chroot \  # (5)
    example-$(date +%Y%m%d).tar.gz - <<'SHELL'  # (6)
        # Copy some file from the repository root to the rootfs.
        install -D -m 755 examples/hello_world.rb /app/hello_world.rb

        # Install some dev packages and gem mailcatcher.
        apk add --no-progress -t .make build-base ruby-dev sqlite-dev
        gem install --no-document mailcatcher

        # Clean-up dev packages.  (7)
        apk del --no-progress .make
SHELL

I cannot get something like this to work, and here is what I think is happening: when reading the script from stdin, it gets written to a temporary file and the SCRIPT variable gets set to the path of that file:

if [ "$SCRIPT" = '-' ]; then
SCRIPT="$TEMP_DIR/setup.sh"
write_script "$SCRIPT"

When chrooting, whatever directory the SCRIPT is in (so, in this case, the temp directory, likely /tmp) gets mounted into the chroot's /mnt:
mount_bind "${SCRIPT%/*}" "$rootfs"/mnt
However, the temp directory obviously does not contain the files from the repo, so stuff like the install ... will not work.

I am not sure if I am missing something here? I was also wondering if #1 was potentially related, but it is a little... sparse on details 😉

When using an actual file as script, everything works as expected. But of course only as long as that script is in the same directory as the files I want to copy. I suppose this is mainly a documentation issue? Also, I wanted to make sure I am not mistaken about anything. Any hints would be much appreciated, I'd even volunteer for a PR once I know the desired state of this.

jirutka added a commit to alpinelinux/alpine-make-vm-image that referenced this issue Jan 28, 2020
When using the --script-chroot option, chroot is called with just sh
(relative path), relying on the host environment's $PATH to find the
executable. At least on Arch Linux, this does not work, as Arch Linux
by default does not have /bin in the PATH (/bin is just a symlink to
/usr/bin).

Since the chroot system was just built and it is know to contain
/bin/sh, I think it makes sense to just call it explicitly here.

Related to alpinelinux/alpine-make-rootfs#10

Co-Authored-By: Conrad Hoffmann <[email protected]>
@bitfehler
Copy link
Contributor Author

👋 just wanted to point out that this was not actually fixed with the referenced commit (thanks for merging, though 🐱 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants