Chroot Manjaro ARM + KDE Plasma + VNC on Android

So I got my hands on the official aarch64 rootfs from @Strit. Thank you so much :vulcan_salute:

I've made a script that can automatically download and chroot into the rootfs on an Android device using Termux. Now, I'd like to start developing it to somehow support most of the ARM editions. Xfce works fine through VNC:

XFCE screenshot.

Currently trying kde-plasma edition, but I only got this error at VNC start up (btw, I used TigerVNC on both editions):

KDE Plasma screenshot.

I can see a window here but the full desktop is just blank. Perhaps there's a chance to get this working.

You can try this chroot setup by following the steps below:

Android requirements.
  • Version: v7.0+ (Termux's minimum target)
  • Architecture: ARM64
Installer script setup.

Note: To change the edition (ARM profiles edition), edit the EDITION variable from the script below before executing through Termux.

Additionally, you can opt out specific packages using sed expressions according to the specified edition (see GitLab repo for the list of packages to install):

## Install profile packages
pacman -S --needed --noconfirm - <<< \$(curl -sL "${URL[manjaro-packages]}" | \\
 sed -e 's/\\s*#.*//' -e '/^\\s*$/d' \\
 -e 's/firefox-ublock-origin//' \\
 -e 's/libreoffice-fresh//')
#!/data/data/com.termux/files/usr/bin/bash

EDITION="kde-plasma"

declare -A URL=(
  [manjaro-rootfs]="https://osdn.net/projects/manjaro-arm/storage/.rootfs/Manjaro-ARM-aarch64-latest.tar.gz"
  [manjaro-packages]="https://gitlab.manjaro.org/manjaro-arm/applications/arm-profiles/-/raw/master/editions/${EDITION}?inline=false"
  [manjaro-overlays]="https://gitlab.manjaro.org/manjaro-arm/applications/arm-profiles/-/archive/master/arm-profiles-master.tar?path=overlays/${EDITION}"
  [manjaro-services]="https://gitlab.manjaro.org/manjaro-arm/applications/arm-profiles/-/raw/master/services/${EDITION}?inline=false"
)

box() {
  dialog --clear --ascii-lines --no-shadow --no-collapse --colors "$@" 2>&1 >/dev/tty
}

main() {
  case "$(box --menu "Please select an action to perform:" -1 -1 0 \
    1 "Install the latest rootfs" \
    2 "Chroot into an existing rootfs" \
    3 "Remove an existing rootfs")"
  in
    1) install;;
    2) chroot;;
    3) remove;;
    *) exit $?;;
  esac
}

remove() {
  while true; do
    directory="$(box --inputbox "Please enter the rootfs path to remove:" -1 -1 "manjaro")"
    if [[ $? != 0 ]]; then
      main
    elif [[ -z ${directory} ]]; then
      box --msgbox "Empty rootfs path. Please try again." -1 -1
      continue
    else
      break
    fi
  done
  if (box --yesno "Are you sure you want to remove '${directory}'?" -1 -1); then
    chmod -Rcf 777 ${directory} 2>&1 | \
      box --progressbox "Changing permissions of '${directory}'..." -1 -1
    rm -rvf ${directory} 2>&1 | \
      box --progressbox "Removing '${directory}'..." -1 -1
  fi
  main
}

chroot() {
  if [[ -z $1 ]]; then
    while true; do
      directory=$(box --inputbox "Please enter the rootfs path to chroot into" -1 -1 "manjaro")
      if [[ $? != 0 ]]; then
        main
      elif [[ -z ${directory} ]]; then
        box --msgbox "Empty rootfs path. Please try again" -1 -1
        continue
      elif [[ ! -d ${directory} ]]; then
        box --msgbox "Path '${directory}' does not exist. Please try again." -1 -1
        continue
      else
        break
      fi
    done
  fi
  unset LD_PRELOAD
  exec proot -l -0 \
    -r "${1:-$directory}" \
    -b /dev \
    -b /proc \
    -b "${1:-$directory}/root:/dev/shm" \
    -w /root \
    /usr/bin/env -i \
    PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/games:/usr/games \
    HOME=/root \
    TERM=${TERM} \
    LANG=en_US.UTF-8 \
    LANGUAGE=en_US \
    LC_ALL=C \
    /bin/bash --login
}

setup() {
chmod -cf 755 $(find ${1:-$directory} -type d) 2>&1 | \
  box --progressbox "Changing default directory permissions..." -1 -1
cat > ${1:-$directory}/root/.bash_profile <<- ...
## Fix common directory permissions
chmod -cf 750 /root /usr/share/polkit-1/rules.d
chmod -cf 755 /etc /usr /usr/share
chmod -cf 775 /var/games
chmod -cf 555 /srv/ftp /sys
chmod -cf 1777 /tmp /var/spool/mail /var/tmp
chmod -cf 2755 /var/log/journal

## Update system and install minimal base
pacman-mirrors -gf 5
pacman-key --init
pacman-key --populate
pacman -Syyuu --noconfirm base
...
[[ ! -z ${EDITION} ]] && cat >> ${1:-$directory}/root/.bash_profile <<- ...
## Install profile packages
pacman -S --needed --noconfirm - <<< \$(curl -sL "${URL[manjaro-packages]}" | \\
  sed -e 's/\\s*#.*//' -e '/^\\s*$/d' \\
  -e 's/firefox-ublock-origin//' \\
  -e 's/libreoffice-fresh//' )

## Enable profile services (optional)
for service in \$(curl -sL "${URL[manjaro-services]}"); do
  systemctl enable \${service}
done

## Install profile overlays
curl -sL "${URL[manjaro-overlays]}" | \\
  tar -xvf - -C / --wildcards --exclude='overlay.txt' \\
  arm-profiles-master-overlays-${EDITION}/overlays/${EDITION}/* --strip 3
...
cat >> ${1:-$directory}/root/.bash_profile <<- ...
## Add new user account
read -p "Please enter a new username: " username
useradd -m -G wheel -s /bin/bash \${username}
passwd \${username}
sed -i -e "/root ALL=(ALL) ALL/a \${username} ALL=(ALL) ALL" \\
  -e "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/" /etc/sudoers
echo "exec su -l \${username}" > /root/.bash_profile
bash /root/.bash_profile
...
}

install() {
  while true; do
    directory="$(box --inputbox "Please enter an installation path:" -1 -1 "manjaro")"
    if [[ $? != 0 ]]; then
      main
    elif [[ -z ${directory} ]]; then
      box --msgbox "Empty installation path. Please try again." -1 -1
      continue
    elif [[ -d ${directory} ]]; then
      if (box --yesno "Path '${directory}' already exist. Do you want to remove it?" -1 -1); then
        chmod -Rcf 777 ${directory} 2>&1 | \
          box --progressbox "Changing permissions of '${directory}'..." -1 -1
        rm -rvf ${directory} 2>&1 | \
          box --progressbox "Removing '${directory}'..." -1 -1
        break
      fi
      continue
    else
       break
    fi
  done
  mkdir -p ${directory} 2>&1 >/dev/null
  size=$(curl -sLI ${URL[manjaro-rootfs]} | awk '/content-length/ {printf "%i", ($2/1024)/1024}')
  (curl -sL ${URL[manjaro-rootfs]} | pv -ns "${size}m" - | \
    proot -l tar -xzf - -C ${directory}) 2>&1 | \
    box --gauge "Installing Manjaro (${size}MB)..." -1 -1
  status=${PIPESTATUS[0]}
  if [[ ${status} != 0 ]]; then
    box --msgbox "An error occurred (${status})." -1 -1
    main
  fi
  setup ${directory}
  chroot ${directory}
}

if [[ $# -gt 0 ]]; then
  echo "$(basename $0): No arguments required." >&2
  exit 1
fi

if ! command -v proot >/dev/null || ! command -v pv >/dev/null; then
  if (box --yesno "Missing required package(s). Do you want to install them?" -1 -1); then
    pkg install -y proot pv 2>&1 | box --progressbox "Installing package(s)..." -1 -1
    status=${PIPESTATUS[0]}
    if [[ ${status} != 0 ]]; then
      box --msgbox "An error occurred (${status})." -1 -1
      exit ${status}
    fi
  else
    exit
  fi
fi

box --msgbox "$(cat <<- '...'
\Z6β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„  β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„\Zn
\Z6β–ˆ     β–ˆ  β–„  β–ˆ   β–ˆ β–ˆβ–„β–„β–ˆ  β–ˆ  β–„  β–ˆ β–„β–„  β–ˆ     β–ˆ\Zn
\Z6β–ˆ β–ˆ β–ˆ β–ˆ     β–ˆ β–ˆ β–ˆ β–ˆ  β–ˆ  β–ˆ     β–ˆ    β– β–ˆ  β–ˆ  β–ˆ\Zn
\Z6β–ˆβ–„β–ˆβ–„β–ˆβ–„β–ˆβ–„β–„β–ˆβ–„β–„β–ˆβ–„β–ˆβ–„β–„β–„β–ˆβ–„β–„β–„β–„β–„β–ˆβ–„β–„β–ˆβ–„β–„β–ˆβ–„β–„β–ˆβ–„β–„β–ˆβ–„β–„β–„β–„β–„β–ˆ\Zn
\Z6β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„\Zn
\Z6β–ˆ β–„β–„  β–ˆ     β–ˆ     β–ˆ     β–ˆ   β–„β–„β–ˆ   β–„β–„β–ˆ\Zn
\Z6β–ˆ    β– β–ˆ  β–ˆ  β–ˆ  β–ˆ  β–ˆβ–€β–ˆ β–ˆβ–€β–ˆ   β–„β–„β–ˆβ–„β–„   β–ˆ\Zn
\Z6β–ˆβ–„β–„β–ˆβ–„β–„β–ˆβ–„β–„β–„β–„β–„β–ˆβ–„β–„β–„β–„β–„β–ˆ β–ˆβ–„β–ˆ β–ˆβ–„β–„β–ˆ  β–ˆβ–„β–„β–„β–„β–„β–ˆ\Zn
...
)" -1 -1

main
VNC server setup.

Note: You could try other VNC setup for KDE Plasma. I used TigerVNC here.

  1. Install tigervnc using pacman:
sudo pacman -S --noconfirm tigervnc
  1. Create ~/.vnc/xstartup script with execute permission:
#!/bin/bash
unset SESSION_MANAGER
export PULSE_SERVER=127.0.0.1
[[ -z ${HOME}/.Xresources ]] && xrdb ${HOME}/.Xresources
dbus-launch startplasma-x11 &
  1. Start VNC server:

Note: Replace ${name} with the desired server name.

vncserver -name ${name} :1
  1. Preview the desktop environment through a VNC viewer (e.g, realvnc). Enter the specified credentials:
  • Address: localhost:5901
  • Name: ${name}
  • Password:
  1. To kill running VNC server:

Note: This might freeze the terminal session, just force close the current one and start a new session.

vncserver -kill :1
rm -rf /root/.vnc/localhost:1.pid /tmp/.X1-lock /tmp/.X11-unix/X1

Does anyone tried this before and got success? Please share your thoughts :upside_down_face:.

1 Like

Forum kindly sponsored by