Skip to content

Commit 3817bbc

Browse files
Use resize2fs to shrink system.img
This replaces the whole make_ext4fs and mount stuff with resize2fs for shrinking the system.img like it is already done in the replace-android-image script. This will also get rid of all sudo commands which means there are no longer root rights needed to flash a device.
1 parent e1e625c commit 3817bbc

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

halium-install

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ SYSIMG=$2
2727

2828
check_prereq()
2929
{
30-
if [ ! $(which make_ext4fs) ] || [ ! -x $(which simg2img) ] || \
31-
[ ! -x $(which adb) ]; then
30+
if [ ! -x $(which simg2img) ] || [ ! -x $(which adb) ]; then
3231
echo "please install the android-tools-fsutils and android-tools-adb packages" && exit 1
3332
fi
3433
}
@@ -41,10 +40,8 @@ do_shell()
4140
convert_android_img()
4241
{
4342
if file $SYSIMG | grep -v ": Linux rev 1.0 ext4" >/dev/null; then
44-
simg2img $SYSIMG $WORKDIR/system.img.raw
45-
mkdir $TMPMOUNT
46-
mount -t ext4 -o loop $WORKDIR/system.img.raw $TMPMOUNT
47-
make_ext4fs -l 160M $WORKDIR/system.img $TMPMOUNT
43+
simg2img $SYSIMG $WORKDIR/system.img
44+
resize2fs -M $WORKDIR/system.img
4845
SYSIMAGE=$WORKDIR/system.img
4946
else
5047
SYSIMAGE=$SYSIMG
@@ -75,7 +72,6 @@ cleanup()
7572
{
7673
echo
7774
echo "cleaning up"
78-
mount | grep -q $TMPMOUNT 2>/dev/null && umount $TMPMOUNT
7975
cleanup_device
8076
rm -rf $WORKDIR
8177
echo
@@ -102,8 +98,6 @@ usage()
10298
exit 1
10399
}
104100

105-
SUDOARGS="$@"
106-
107101
while [ $# -gt 0 ]; do
108102
case "$1" in
109103
-h|--help)
@@ -156,8 +150,6 @@ if [ ! -z "$CUST_TARPATH" ] && \
156150
usage
157151
fi
158152

159-
[ $(id -u) -ne 0 ] && exec sudo $0 $SUDOARGS
160-
161153
check_prereq
162154

163155
if ! adb devices | grep -q recovery; then
@@ -168,7 +160,6 @@ fi
168160
check_mounts
169161

170162
WORKDIR=$(mktemp -d /tmp/halium-install.XXXXX)
171-
TMPMOUNT="$WORKDIR/tmpmount"
172163

173164
echo "transfering rootfs tarball ... "
174165
adb push $TARPATH /recovery/

0 commit comments

Comments
 (0)