Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Not a fix for that yet: On ilyabizyaev's device, uname -m reports i686

Copy link

Choose a reason for hiding this comment

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

Theoretically, you could just replace all i*86 architectures with i386 (or x86)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I wanted to have a solution without mapping different architecture shemes, but as their doesn't seem to be one, I'll probably do it like that.


# 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"
Copy link

Choose a reason for hiding this comment

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

As you spelled [install] without capital letters, you should do it the same way here.

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
Copy link

Choose a reason for hiding this comment

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

Just an idea, you could call it verbose mode


# 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