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

x86_64 is hardcoded, breaks aarch64 installs! #46

Open
IngwiePhoenix opened this issue Jan 26, 2024 · 2 comments
Open

x86_64 is hardcoded, breaks aarch64 installs! #46

IngwiePhoenix opened this issue Jan 26, 2024 · 2 comments

Comments

@IngwiePhoenix
Copy link

Hello!

I just come back from absolutely bricking my OS - OpenWrt on a FriendlyElec NanoPi R6s - and decided to have a "side system" for anything that I can not or do not want to containerize.

However, while installing, I was met with this:

https://github.com/alpinelinux/alpine-chroot-install/blob/master/alpine-chroot-install#L81-L82

I fixed it by just manually setting the values as environment variables - but I believe that this is actually not the intended way?

Thanks and kind regards,
Ingwie

@jirutka
Copy link
Member

jirutka commented Jan 27, 2024

I fixed it by just manually setting the values as environment variables - but I believe that this is actually not the intended way?

Well, the problem is that I originally wrote this script for one specific purpose – using Alpine Linux on Travis CI (and other x86_64-only CIs) – but people are now using it for many different purposes for which it was never intended. This is one of them. I guess I’ll have to completely rewrite the script to make it more suitable for the purposes people use it for today.

@IngwiePhoenix
Copy link
Author

I guess so; I certainly facelifted the enter-script a lot...

Maybe this helps? I am using this in conjunction with a symlink to /usr/local/bin/alpine and as a procd service to call dinit as an "init system". Works quite well, even across reboots.

#!/bin/sh
set -e

try_to_mount() {
  local mto mfrom
  mfrom="$1"
  mto="/usb/alpine/$2"
  if [ -z "$2" ]; then
    mto="/usb/alpine/$1"
  fi

  # Exists?
  if [ ! -d "$mto" ]; then
    mkdir -p "$mto"
  fi

  # is not mounted?
  mountpoint -q "$mto" \
  || mount --bind "$mfrom" "$mto"
}

# Mounts
## Dirs
try_to_mount /proc
try_to_mount /sys
try_to_mount /dev
try_to_mount /root
## Drives
try_to_mount /usb
try_to_mount /sdcard
try_to_mount /mnt/diskstation/bunker
try_to_mount /mnt/diskstation/scratch
## Socks
try_to_mount /var/run/tailscale /run/tailscale

ENV_FILTER_REGEX='(TERM|ARCH|CI|QEMU_EMULATOR|TRAVIS_.*)'

user='root'
if [ $# -ge 2 ] && [ "$1" = '-u' ]; then
    user="$2"; shift 2
fi
oldpwd="$(pwd)"
[ "$(id -u)" -eq 0 ] || _sudo='sudo'

tmpfile="$(mktemp)"
chmod 644 "$tmpfile"
export | sed -En "s/^([^=]+ ${ENV_FILTER_REGEX}=)('.*'|\".*\")$/\1\3/p" > "$tmpfile" || true

cd "$(dirname "$0")"
$_sudo mv "$tmpfile" env.sh
$_sudo chroot . /usr/bin/env -i su -l "$user" \
    sh -c ". /etc/profile; . /env.sh; cd '$oldpwd' 2>/dev/null; \"\$@\"" \
    -- "${@:-fish}"

I added $TERM because fish would complain about it not being set. The rest is fine.

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