Skip to content

Instantly share code, notes, and snippets.

@jbruechert
Last active December 24, 2017 00:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbruechert/498c54686636a615aaf8ddfcbf9484d4 to your computer and use it in GitHub Desktop.
Save jbruechert/498c54686636a615aaf8ddfcbf9484d4 to your computer and use it in GitHub Desktop.
Moved to https://github.com/JBBgameich/halium-install | Rewrite of the halium-install script. Usage should be similar to the official one. `halium-install $ROOTFS $ANDROID_IMAGE` Only use if the official one doesn't work!

Alternative Halium installer script

The difference to the official script from the halium-scripts repository is that this script will prepare the rootfs on your host system instead of on the device. This will make you independent of problems like old TWRP images, no busybox or not-working busyboxes on some devices.

Dependencies

  • qemu-user-static
  • qemu-system-arm
  • e2fsprogs
  • simg2img

Usage:

./halium-install <rootfs.tar.gz> <system.img>
#!/bin/bash
# Plase make sure you have qemu-user-static, qemu-system-arm, sudo and simg2img installed before running this script!
function spinner() {
local pid=$1
local delay=0.75
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf "\b\b\b\b"
}
function convert_rootfs() {
dd if=/dev/zero of=rootfs.img seek=500K bs=4096 count=0
sudo mkfs.ext4 -F rootfs.img
mkdir rootfs
sudo mount rootfs.img rootfs
sudo tar -xf $ROOTFS_TAR -C rootfs
}
function convert_androidimage() {
simg2img $AND_IMAGE system.img
sudo resize2fs -M system.img
}
function setup_ssh() {
sudo cp $(which qemu-arm-static) rootfs/usr/bin
sudo chroot rootfs passwd root
sudo LANG=C chroot rootfs dpkg-reconfigure dropbear-run
sudo rm rootfs/usr/bin/qemu-arm-static
}
function unmount() {
sudo umount rootfs
}
function flash() {
adb push system.img /data/system.img
adb push rootfs.img /data/rootfs.img
}
function clean() {
# Delete created files from last install
sudo rm rootfs -rf
sudo rm rootfs.img
sudo rm system.img
}
export ROOTFS_TAR=$1
export AND_IMAGE=$2
echo "Debug: Chosen rootfs is $ROOTFS_TAR"
echo "Debug: Chosen android image is $AND_IMAGE"
echo
echo "I: Writing rootfs into mountable image"
convert_rootfs &> /dev/null & spinner $!
echo "I: Writing android image into mountable image"
convert_androidimage &> /dev/null & spinner $!
echo "I: Setting up SSH server"
setup_ssh
echo "I: Unmounting images"
unmount &> /dev/null & spinner $!
echo "I: Pushing rootfs and android image to /data via ADB"
flash
echo "I: Cleaning up host"
clean & spinner $!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment