Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
25 changes: 24 additions & 1 deletion functions/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,34 @@ 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() {
# 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-arm"
! [ -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
4 changes: 4 additions & 0 deletions functions/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ function usage() {
defaults : none
EOF
}

function flash_error() {
echo "Error: Couldn't copy the files to the device, is it connected?"
}
11 changes: 8 additions & 3 deletions halium-install
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export AND_IMAGE=$2
export ROOTFS_DIR=$(mktemp -d .halium-install-rootfs.XXXXX)
export IMAGE_DIR=$(mktemp -d .halium-install-imgs.XXXXX)

# Default to rsync installation
export FLASH_RSYNC="true"

# Start installer
echo "Debug: Chosen rootfs is $ROOTFS_TAR"
echo "Debug: Chosen android image is $AND_IMAGE"
Expand All @@ -74,9 +77,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_ADB ]; then
flash_adb || flash_error
elif [ $FLASH_RSYNC ]; then
flash_rsync || flash_error
fi

echo "I: Cleaning up host"
Expand Down