Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion functions/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,36 @@ function unmount() {
sudo umount $ROOTFS_DIR
}

function flash() {
function flash_adb() {
adb push $IMAGE_DIR/rootfs.img /data/
adb push $IMAGE_DIR/system.img /data/
}

function flash_rsync() {
TARGET_ARCH=$(adb shell uname -m)

# Download prebuilt rsync
echo "[install] Installing rsync on the device ..."
! [ -f $IMAGE_DIR/rsync.bin ] && wget -O $IMAGE_DIR/rsync.bin --continue -q "https://github.com/JBBgameich/rsync-static/releases/download/continuous/rsync-$TARGET_ARCH"
! [ -f $IMAGE_DIR/rsyncd.conf ] && wget -O $IMAGE_DIR/rsyncd.conf --continue -q "https://raw.githubusercontent.com/JBBgameich/rsync-static/master/rsyncd.conf"

# Push rsync
adb push $IMAGE_DIR/rsync.bin /data/rsync >/dev/null
adb push $IMAGE_DIR/rsyncd.conf /data/rsyncd.conf >/dev/null
adb shell chmod +x /data/rsync

# Start rsync daemon on the device
adb shell '/data/rsync --daemon --config=/data/rsyncd.conf &'
adb forward tcp:6010 tcp:1873

echo "[install] Transferring files ..."
rsync -avz --progress $IMAGE_DIR/rootfs.img rsync://localhost:6010/root/data/rootfs.img
rsync -avz --progress $IMAGE_DIR/system.img rsync://localhost:6010/root/data/system.img

# Kill running rsync instances
adb shell killall rsync
}

function clean() {
# Delete created files from last install
sudo rm $ROOTFS_DIR $IMAGE_DIR -rf
Expand Down
12 changes: 12 additions & 0 deletions functions/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ function usage() {
defaults : none
EOF
}

function flash_error() {
echo "Error: Couldn't copy the files to the device, is it connected?"
}

function debug_variables() {
echo "[debug] rootfs: $ROOTFS_TAR"
echo "[debug] android image: $AND_IMAGE"
echo "[debug] release: $ROOTFS_RELEASE"
echo "[debug] install method: $FLASH_METHOD"
echo
}
20 changes: 12 additions & 8 deletions halium-install
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ export AND_IMAGE=$2
export ROOTFS_DIR=$(mktemp -d .halium-install-rootfs.XXXXX)
export IMAGE_DIR=$(mktemp -d .halium-install-imgs.XXXXX)

# Start installer
echo "Debug: Chosen rootfs is $ROOTFS_TAR"
echo "Debug: Chosen android image is $AND_IMAGE"
echo "Debug: Chosen release is $ROOTFS_RELEASE"
echo
# Set defaults
export ${FLASH_METHOD:="rsync"}
export ${DEBUG:="true"}

# Print out useful debugging information
[ $DEBUG == "true" ] && debug_variables

# Start installer
echo "I: Writing rootfs into mountable image"
convert_rootfs $IMAGE_SIZE &>/dev/null &
spinner $!
Expand All @@ -74,9 +76,11 @@ spinner $!
echo "I: Shrinking images"
shrink_images

echo "I: Pushing rootfs and android image to /data via ADB"
if ! flash $ROOTFS_RELEASE; then
echo "Error: Couldn't copy the files to the device, is it connected?"
echo "I: Pushing rootfs and android image to /data"
if [ $FLASH_METHOD == "adb" ]; then
flash_adb || flash_error
elif [ $FLASH_METHOD == "rsync" ]; then
flash_rsync || flash_error
fi

echo "I: Cleaning up host"
Expand Down