From 309498ec31b2903e68c4645228d2df791c9dc4a6 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Mon, 12 Mar 2018 21:02:43 +0100 Subject: [PATCH 1/5] Add initial rsync transfer support --- functions/core.sh | 31 ++++++++++++++++++++++++++++++- halium-install | 8 +++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/functions/core.sh b/functions/core.sh index 4ea6470..242ce50 100644 --- a/functions/core.sh +++ b/functions/core.sh @@ -31,11 +31,40 @@ 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 flash_error() { + if ! $1; then + echo "Error: Couldn't copy the files to the device, is it connected?" + fi +} + function clean() { # Delete created files from last install sudo rm $ROOTFS_DIR $IMAGE_DIR -rf diff --git a/halium-install b/halium-install index 183ff93..6a846a4 100755 --- a/halium-install +++ b/halium-install @@ -74,9 +74,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_error flash_adb +else + flash_error flash_rsync fi echo "I: Cleaning up host" From 2f6559b2b5cb90fd6ddbaa0e100b325b5a587d10 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 13 Mar 2018 19:19:15 +0100 Subject: [PATCH 2/5] Simplify error message --- functions/core.sh | 6 ------ functions/misc.sh | 4 ++++ halium-install | 9 ++++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/functions/core.sh b/functions/core.sh index 242ce50..9a7c929 100644 --- a/functions/core.sh +++ b/functions/core.sh @@ -59,12 +59,6 @@ function flash_rsync() { adb shell killall rsync } -function flash_error() { - if ! $1; then - echo "Error: Couldn't copy the files to the device, is it connected?" - fi -} - function clean() { # Delete created files from last install sudo rm $ROOTFS_DIR $IMAGE_DIR -rf diff --git a/functions/misc.sh b/functions/misc.sh index 17d46ef..ef0372e 100755 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -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?" +} diff --git a/halium-install b/halium-install index 6a846a4..ff87c4c 100755 --- a/halium-install +++ b/halium-install @@ -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" @@ -76,9 +79,9 @@ shrink_images echo "I: Pushing rootfs and android image to /data" if [ $FLASH_ADB ]; then - flash_error flash_adb -else - flash_error flash_rsync + flash_adb || flash_error +elif [ $FLASH_RSYNC ]; then + flash_rsync || flash_error fi echo "I: Cleaning up host" From f194176057431fa5d7a301dd18e4271c09a75ab9 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 13 Mar 2018 21:32:03 +0100 Subject: [PATCH 3/5] General clean up --- functions/misc.sh | 8 ++++++++ halium-install | 17 ++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index ef0372e..3b08ca0 100755 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -60,3 +60,11 @@ function usage() { 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 +} diff --git a/halium-install b/halium-install index ff87c4c..8ff077d 100755 --- a/halium-install +++ b/halium-install @@ -50,15 +50,14 @@ 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" +# Set defaults +export ${FLASH_METHOD:="rsync"} +export ${DEBUG:="true"} -# 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 +# 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 $! @@ -78,9 +77,9 @@ echo "I: Shrinking images" shrink_images echo "I: Pushing rootfs and android image to /data" -if [ $FLASH_ADB ]; then +if [ $FLASH_METHOD == "adb" ]; then flash_adb || flash_error -elif [ $FLASH_RSYNC ]; then +elif [ $FLASH_METHOD == "rsync" ]; then flash_rsync || flash_error fi From 1a2be97e595a624ad53762533747322889f04f12 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 13 Mar 2018 21:34:22 +0100 Subject: [PATCH 4/5] Maybe fix for x86, needs testers --- functions/core.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/core.sh b/functions/core.sh index 9a7c929..ce6c676 100644 --- a/functions/core.sh +++ b/functions/core.sh @@ -37,9 +37,11 @@ function flash_adb() { } 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-arm" + ! [ -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 From 9f42932f4c963b5ddbbb2910d4583cdc8de8baee Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Tue, 13 Mar 2018 21:38:02 +0100 Subject: [PATCH 5/5] Adress comments --- functions/misc.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 3b08ca0..72c28c0 100755 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -62,9 +62,9 @@ function flash_error() { } 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 "[debug] rootfs: $ROOTFS_TAR" + echo "[debug] android image: $AND_IMAGE" + echo "[debug] release: $ROOTFS_RELEASE" + echo "[debug] install method: $FLASH_METHOD" echo }