Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 30 additions & 1 deletion functions/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen, if there is a first argument?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function prints the error message if the function it calls (argument) fails

}

function clean() {
# Delete created files from last install
sudo rm $ROOTFS_DIR $IMAGE_DIR -rf
Expand Down
8 changes: 5 additions & 3 deletions halium-install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the parameters 'flash_adb' and 'flash_rsync' used?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flash_error functions calls the flash_rsync function

fi

echo "I: Cleaning up host"
Expand Down