Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove cache modules
  • Loading branch information
topjohnwu committed Nov 14, 2016
1 parent 38e5fe0 commit 5dbdc87
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 85 deletions.
118 changes: 49 additions & 69 deletions META-INF/com/google/android/update-binary
Expand Up @@ -148,13 +148,11 @@ fi
TMPDIR=/tmp
MOUNTPATH=/magisk
IMGNAME=magisk.img
CACHEPATH=/cache/magisk

if ($BOOTMODE); then
TMPDIR=/dev/tmp
MOUNTPATH=/dev/magisk_merge
IMGNAME=magisk_merge.img
CACHEPATH=/cache/magisk_merge
fi

mkdir -p $TMPDIR 2>/dev/null
Expand All @@ -168,10 +166,6 @@ fi

source config.sh

if ($CACHEMOD); then
MOUNTPATH=$CACHEPATH
fi

INSTALLER=$TMPDIR/$MODID
MODPATH=$MOUNTPATH/$MODID

Expand Down Expand Up @@ -217,49 +211,47 @@ if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=true; fi;
# You can get the Android API version from $API, the CPU architecture from $ARCH
# Useful if you are creating Android version / platform dependent mods

if (! $CACHEMOD); then
IMG=
if (is_mounted /data); then
IMG=/data/$IMGNAME
if [ ! -f "/data/magisk.img" ]; then
ui_print "! Magisk is not installed!"
ui_print "! Magisk is required for this mod!"
exit 1
fi
else
IMG=/cache/magisk.img
ui_print " "
ui_print "***********************************"
ui_print "* !! Data unavailible !! *"
ui_print "* Magisk detection is impossible *"
ui_print "* Installation will still proceed *"
ui_print "* But please make sure you have *"
ui_print "* Magisk installed!! *"
ui_print "***********************************"
ui_print " "
IMG=
if (is_mounted /data); then
IMG=/data/$IMGNAME
if [ ! -f "/data/magisk.img" ]; then
ui_print "! Magisk is not installed!"
ui_print "! Magisk is required for this mod!"
exit 1
fi
else
IMG=/cache/magisk.img
ui_print " "
ui_print "***********************************"
ui_print "* !! Data unavailible !! *"
ui_print "* Magisk detection is impossible *"
ui_print "* Installation will still proceed *"
ui_print "* But please make sure you have *"
ui_print "* Magisk installed!! *"
ui_print "***********************************"
ui_print " "
fi

payload_size_check "$ZIP" "*"
payload_size_check "$ZIP" "*"

if [ -f "$IMG" ]; then
ui_print "- $IMG detected!"
target_size_check $IMG
if [ "$reqSizeM" -gt "$curFreeM" ]; then
SIZE=$((((reqSizeM + curUsedM) / 32 + 2) * 32))
ui_print "- Resizing $IMG to ${SIZE}M..."
resize2fs $IMG ${SIZE}M
fi
else
SIZE=$(((reqSizeM / 32 + 2) * 32));
ui_print "- Creating $IMG with size ${SIZE}M"
make_ext4fs -l ${SIZE}M -a /magisk -S $INSTALLER/common/file_contexts_image $IMG
if [ -f "$IMG" ]; then
ui_print "- $IMG detected!"
target_size_check $IMG
if [ "$reqSizeM" -gt "$curFreeM" ]; then
SIZE=$((((reqSizeM + curUsedM) / 32 + 2) * 32))
ui_print "- Resizing $IMG to ${SIZE}M..."
resize2fs $IMG ${SIZE}M
fi
else
SIZE=$(((reqSizeM / 32 + 2) * 32));
ui_print "- Creating $IMG with size ${SIZE}M"
make_ext4fs -l ${SIZE}M -a /magisk -S $INSTALLER/common/file_contexts_image $IMG
fi

mount_image $IMG $MOUNTPATH
if (! is_mounted $MOUNTPATH); then
ui_print "! $IMG mount failed... abort"
exit 1
fi
mount_image $IMG $MOUNTPATH
if (! is_mounted $MOUNTPATH); then
ui_print "! $IMG mount failed... abort"
exit 1
fi

# Create mod paths
Expand All @@ -284,27 +276,17 @@ fi
cp -af $INSTALLER/module.prop $MODPATH/module.prop
if ($BOOTMODE); then
# Update info for Magisk Manager
if ($CACHEMOD); then
mktouch /cache/magisk/$MODID/update
cp -af $INSTALLER/module.prop /cache/magisk/$MODID/module.prop
else
mktouch /magisk/$MODID/update
cp -af $INSTALLER/module.prop /magisk/$MODID/module.prop
fi
fi

# post-fs mode scripts
if ($CACHEMOD) && ($POSTFS); then
cp -af $INSTALLER/common/post-fs.sh $MODPATH/post-fs.sh
mktouch /magisk/$MODID/update
cp -af $INSTALLER/module.prop /magisk/$MODID/module.prop
fi

# post-fs-data mode scripts
if (! $CACHEMOD) && ($POSTFSDATA); then
if ($POSTFSDATA); then
cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh
fi

# service mode scripts
if (! $CACHEMOD) && ($LATESTARTSERVICE); then
if ($LATESTARTSERVICE); then
cp -af $INSTALLER/common/service.sh $MODPATH/service.sh
fi

Expand All @@ -313,17 +295,15 @@ set_permissions

ui_print "- Unmounting partitions"

if (! $CACHEMOD); then
umount $MOUNTPATH
losetup -d $LOOPDEVICE
rm -rf $MOUNTPATH
# Shrink the image if possible
target_size_check $IMG
NEWDATASIZE=$(((curUsedM / 32 + 2) * 32));
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
ui_print "- Shrinking $IMG to ${NEWDATASIZE}M...";
resize2fs $IMG ${NEWDATASIZE}M;
fi
umount $MOUNTPATH
losetup -d $LOOPDEVICE
rm -rf $MOUNTPATH
# Shrink the image if possible
target_size_check $IMG
NEWDATASIZE=$(((curUsedM / 32 + 2) * 32));
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
ui_print "- Shrinking $IMG to ${NEWDATASIZE}M...";
resize2fs $IMG ${NEWDATASIZE}M;
fi

if (! $BOOTMODE); then
Expand Down
5 changes: 4 additions & 1 deletion common/post-fs-data.sh
@@ -1,4 +1,7 @@
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
MODDIR=${0%/*}

# This script will be executed in post-fs-data mode
# More info in the main Magisk thread
# More info in the main Magisk thread
4 changes: 0 additions & 4 deletions common/post-fs.sh

This file was deleted.

5 changes: 4 additions & 1 deletion common/service.sh
@@ -1,4 +1,7 @@
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
MODDIR=${0%/*}

# This script will be executed in late_start service mode
# More info in the main Magisk thread
# More info in the main Magisk thread
12 changes: 3 additions & 9 deletions config.sh
Expand Up @@ -31,9 +31,6 @@

# NOTE: This part has to be adjusted to fit your own needs

# Is this a cache mod?
CACHEMOD=false

# This will be the folder name under /magisk or /cache/magisk
# This should also be the same as the id in your module.prop to prevent confusion
MODID=template
Expand All @@ -42,13 +39,10 @@ MODID=template
# Most mods would like it to be enabled
AUTOMOUNT=true

# Set to true if you need post-fs script (Only available in cache mods)
POSTFS=false

# Set to true if you need post-fs-data script (Only available in non-cache mods)
# Set to true if you need post-fs-data script
POSTFSDATA=false

# Set to true if you need late_start service script (Only available in non-cache mods)
# Set to true if you need late_start service script
LATESTARTSERVICE=false

##########################################################################################
Expand Down Expand Up @@ -79,7 +73,7 @@ REPLACE="
/system/framework
"

# Construct your own list
# Construct your own list here
REPLACE="
"

Expand Down
1 change: 0 additions & 1 deletion module.prop
Expand Up @@ -6,4 +6,3 @@ author=topjohnwu
description=A short description
support=http://forum.xda-developers.com/showthread.php?t=3432382
donate=http://topjohnwu.github.io/donate
cacheModule=false

0 comments on commit 5dbdc87

Please sign in to comment.