Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove root from build process #223

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 18 additions & 5 deletions devices/xiaomi.vacuum/firmwarebuilder/imagebuilder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Options:
--unprovisioned wpa2psk
--ssid YOUR_SSID
--psk YOUR_WIRELESS_PASSWORD
--fuse-ext2 Use fuse-ext2 instead of mount. This allows building the firmware without root. It is further usefull for e.g. btrfs based systems.
-h, --help Prints this message

Each parameter that takes a file as an argument accepts path in any form
Expand Down Expand Up @@ -101,6 +102,7 @@ DISABLE_LOGS=0
ENABLE_DUMMYCLOUD=0
ENABLE_VALETUDO=0
PATCH_RRLOGD=0
USE_FUSE_EXT2=0

while [ -n "$1" ]; do
PARAM="$1"
Expand Down Expand Up @@ -157,6 +159,9 @@ while [ -n "$1" ]; do
RRLOGD_PATCHER="$ARG"
shift
;;
*-fuse-ext2)
USE_FUSE_EXT2=1
;;
*-dummycloud-path)
DUMMYCLOUD_PATH="$ARG"
if [ -r "$DUMMYCLOUD_PATH/dummycloud" ]; then
Expand Down Expand Up @@ -227,7 +232,7 @@ done
BASEDIR=$(dirname "${SCRIPT}")
echo "Script path: $BASEDIR"

if [ $EUID -ne 0 ]; then
if [ $EUID -ne 0 ] && [ $USE_FUSE_EXT2 -eq 0 ]; then
echo "You need root privileges to execute this script"
exit 1
fi
Expand Down Expand Up @@ -339,6 +344,8 @@ if [ "$IS_MAC" = true ]; then
#ext4fuse doesn't support write properly
#ext4fuse disk.img image -o force
fuse-ext2 "$FW_DIR/disk.img" "$IMG_DIR" -o rw+
elif [ "$USE_FUSE_EXT2" -eq 1 ]; then
fuse-ext2 "$FW_DIR/disk.img" "$IMG_DIR" -o rw+ -o uid=$UID
else
mount -o loop "$FW_DIR/disk.img" "$IMG_DIR"
fi
Expand Down Expand Up @@ -579,10 +586,16 @@ if [ -n "$SND_DIR" ]; then
done
fi

while [ $(umount $IMG_DIR; echo $?) -ne 0 ]; do
echo "waiting for unmount..."
sleep 2
done

# writes cache to image
sync

echo "Unmount firmware image"
if [ -n "$USE_FUSE_EXT2" ]; then
fusermount -u $IMG_DIR
else
umount $IMG_DIR
fi

echo "Pack new firmware"
pushd $FW_DIR
Expand Down