Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Apr 22, 2017
1 parent 4c96d23 commit 623a879
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 74 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*.cmd text eol=crlf

# Denote all files that are truly binary and should not be modified.
binaries/** binary
zip_static/chromeos/** binary
uninstaller/chromeos/** binary
*.jar binary
*.exe binary
*.apk binary
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ zip_static/arm/*
zip_static/arm64/*
zip_static/x86/*
zip_static/x64/*
zip_static/chromeos/*
uninstaller/arm/*
uninstaller/arm64/*
uninstaller/x86/*
uninstaller/x64/*
uninstaller/chromeos/*
ziptools/zipadjust

# Generated scripts
Expand Down
2 changes: 0 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Magisk
### Static binaries included:
* Busybox: http://forum.xda-developers.com/android/software-hacking/tool-busybox-flashable-archs-t3348543

### How to build Magisk
1. Download and install NDK
Expand Down
Binary file removed binaries/busybox-arm
Binary file not shown.
Binary file removed binaries/busybox-arm64
Binary file not shown.
Binary file removed binaries/busybox-x64
Binary file not shown.
Binary file removed binaries/busybox-x86
Binary file not shown.
16 changes: 2 additions & 14 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ EXIT /B %ERRORLEVEL%
2>NUL RMDIR /S /Q zip_static\arm64
2>NUL RMDIR /S /Q zip_static\x86
2>NUL RMDIR /S /Q zip_static\x64
2>NUL RMDIR /S /Q zip_static\chromeos
2>NUL DEL zip_static\META-INF\com\google\android\update-binary
2>NUL DEL zip_static\common\*.sh
2>NUL DEL zip_static\common\*.rc
Expand All @@ -104,7 +103,6 @@ EXIT /B %ERRORLEVEL%
2>NUL RMDIR /S /Q uninstaller\arm64
2>NUL RMDIR /S /Q uninstaller\x86
2>NUL RMDIR /S /Q uninstaller\x64
2>NUL RMDIR /S /Q uninstaller\chromeos
EXIT /B 0

:zip
Expand All @@ -119,18 +117,13 @@ EXIT /B %ERRORLEVEL%
ECHO ************************
ECHO * Adding version info
ECHO ************************
powershell.exe -nologo -noprofile -command "(gc -Raw scripts\flash_script.sh) -replace 'MAGISK_VERSION_STUB', 'Magisk v%~1 Boot Image Patcher' | sc zip_static\META-INF\com\google\android\update-binary"
powershell.exe -nologo -noprofile -command "(gc -Raw scripts\magic_mask.sh) -replace 'MAGISK_VERSION_STUB', 'setprop magisk.version \"%~1\"' | sc zip_static\common\magic_mask.sh"
powershell.exe -nologo -noprofile -command "(gc -Raw scripts\flash_script.sh) -replace 'MAGISK_VERSION_STUB', 'Magisk v%~1 Installer' | sc zip_static\META-INF\com\google\android\update-binary"
rem powershell.exe -nologo -noprofile -command "(gc -Raw scripts\magic_mask.sh) -replace 'MAGISK_VERSION_STUB', 'setprop magisk.version \"%~1\"' | sc zip_static\common\magic_mask.sh"
ECHO ************************
ECHO * Copying Files
ECHO ************************
COPY /Y scripts\custom_ramdisk_patch.sh zip_static\common\custom_ramdisk_patch.sh
COPY /Y scripts\init.magisk.rc zip_static\common\init.magisk.rc
COPY /Y binaries\busybox-arm zip_static\arm\busybox
COPY /Y binaries\busybox-arm64 zip_static\arm64\busybox
COPY /Y binaries\busybox-x86 zip_static\x86\busybox
COPY /Y binaries\busybox-x64 zip_static\x64\busybox
CALL :mkcp binaries\chromeos zip_static\chromeos
ECHO ************************
ECHO * Zipping Magisk v%~1
ECHO ************************
Expand All @@ -149,11 +142,6 @@ EXIT /B %ERRORLEVEL%
ECHO * Copying Files
ECHO ************************
CALL :mkcp scripts\magisk_uninstaller.sh uninstaller\common
COPY /Y binaries\busybox-arm uninstaller\arm\busybox
COPY /Y binaries\busybox-arm64 uninstaller\arm64\busybox
COPY /Y binaries\busybox-x86 uninstaller\x86\busybox
COPY /Y binaries\busybox-x64 uninstaller\x64\busybox
CALL :mkcp binaries\chromeos uninstaller\chromeos
ECHO ************************
ECHO * Zipping uninstaller
ECHO ************************
Expand Down
20 changes: 3 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ cleanup() {
rm -rfv zip_static/arm64
rm -rfv zip_static/x86
rm -rfv zip_static/x64
rm -rfv zip_static/chromeos
rm -rfv zip_static/META-INF/com/google/android/update-binary
rm -rfv zip_static/common/*.sh
rm -rfv zip_static/common/*.rc
Expand All @@ -35,7 +34,6 @@ cleanup() {
rm -rfv uninstaller/arm64
rm -rfv uninstaller/x86
rm -rfv uninstaller/x64
rm -rfv uninstaller/chromeos
}

mkcp() {
Expand Down Expand Up @@ -76,22 +74,17 @@ build_bin() {

zip_package() {
[ -z "$1" ] && echo -e "! Missing version info\n" && usage
[ ! -f "zip_static/arm/magiskboot" ] && error "Missing binaries!! Please run '$0 build' before zipping"
[ ! -f "zip_static/arm/magiskboot" ] && error "Missing binaries!! Please run '$ME build' before zipping"
echo "************************"
echo "* Adding version info"
echo "************************"
sed "s/MAGISK_VERSION_STUB/Magisk v$1 Boot Image Patcher/g" scripts/flash_script.sh > zip_static/META-INF/com/google/android/update-binary
sed "s/MAGISK_VERSION_STUB/setprop magisk.version \"$1\"/g" scripts/magic_mask.sh > zip_static/common/magic_mask.sh
sed "s/MAGISK_VERSION_STUB/Magisk v$1 Installer/g" scripts/flash_script.sh > zip_static/META-INF/com/google/android/update-binary
# sed "s/MAGISK_VERSION_STUB/setprop magisk.version \"$1\"/g" scripts/magic_mask.sh > zip_static/common/magic_mask.sh
echo "************************"
echo "* Copying files"
echo "************************"
cp -afv scripts/custom_ramdisk_patch.sh zip_static/common/custom_ramdisk_patch.sh
cp -afv scripts/init.magisk.rc zip_static/common/init.magisk.rc
cp -afv binaries/busybox-arm zip_static/arm/busybox
cp -afv binaries/busybox-arm64 zip_static/arm64/busybox
cp -afv binaries/busybox-x86 zip_static/x86/busybox
cp -afv binaries/busybox-x64 zip_static/x64/busybox
cp -afv binaries/chromeos/. zip_static/chromeos
echo "************************"
echo "* Zipping Magisk v$1"
echo "************************"
Expand All @@ -110,15 +103,9 @@ zip_uninstaller() {
echo "* Copying files"
echo "************************"
mkcp scripts/magisk_uninstaller.sh uninstaller/common
cp -afv binaries/busybox-arm uninstaller/arm/busybox
cp -afv binaries/busybox-arm64 uninstaller/arm64/busybox
cp -afv binaries/busybox-x86 uninstaller/x86/busybox
cp -afv binaries/busybox-x64 uninstaller/x64/busybox
cp -afv binaries/chromeos/. zip_static/chromeos
echo "************************"
echo "* Zipping uninstaller"
echo "************************"
mkcp scripts/magisk_uninstaller.sh uninstaller/common
cd uninstaller
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
Expand Down Expand Up @@ -155,7 +142,6 @@ sign_zip() {
}

DIR="$(cd "$(dirname "$0")"; pwd)"
cd "$DIR"
DEBUG=
CPUNUM=`getconf _NPROCESSORS_ONLN`
ME=$0
Expand Down
5 changes: 2 additions & 3 deletions scripts/custom_ramdisk_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ cpio_add 750 init.rc init.rc

# sepolicy patches
cpio_extract sepolicy sepolicy
LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskpolicy --load sepolicy --save sepolicy --minimal
LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magisk magiskpolicy --load sepolicy --save sepolicy --minimal
cpio_add 644 sepolicy sepolicy

# Add new items
cpio_mkdir 755 magisk
cpio_add 750 init.magisk.rc $MAGISKBIN/init.magisk.rc
cpio_add 750 sbin/magic_mask.sh $MAGISKBIN/magic_mask.sh
cpio_add 755 sbin/magisk $MAGISKBIN/magisk

42 changes: 12 additions & 30 deletions scripts/flash_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ cpio_mkdir() {
# Detection
##########################################################################################

ui_print "*****************************"
ui_print "MAGISK_VERSION_STUB"
ui_print "*****************************"
ui_print "************************"
ui_print "* MAGISK_VERSION_STUB"
ui_print "************************"

if [ ! -d "$COMMONDIR" ]; then
ui_print "! Failed: Unable to extract zip file!"
Expand Down Expand Up @@ -256,36 +256,22 @@ fi
# Environment
##########################################################################################

# TODO: Environment
ui_print "- Constructing environment"

# ui_print "- Constructing environment"
is_mounted /data && MAGISKBIN=/data/magisk || MAGISKBIN=/cache/data_bin

# is_mounted /data && MAGISKBIN=/data/magisk || MAGISKBIN=/cache/data_bin
# Copy required files
rm -rf $MAGISKBIN 2>/dev/null
mkdir -p $MAGISKBIN
cp -af $BINDIR/. $COMMONDIR/magisk.apk $COMMONDIR/init.magisk.rc $COMMONDIR/custom_ramdisk_patch.sh $MAGISKBIN

# # Copy required files
# rm -rf $MAGISKBIN 2>/dev/null
# mkdir -p $MAGISKBIN
# cp -af $BINDIR/busybox $BINDIR/magiskboot $BINDIR/magiskpolicy $COMMONDIR/magisk.apk \
# $COMMONDIR/init.magisk.rc $COMMONDIR/custom_ramdisk_patch.sh $COMMONDIR/magic_mask.sh $MAGISKBIN
# # Legacy support
# ln -sf /data/magisk/magiskpolicy $MAGISKBIN/sepolicy-inject

# chmod -R 755 $MAGISKBIN
# chcon -h u:object_r:system_file:s0 $MAGISKBIN $MAGISKBIN/*

# # Temporary busybox for installation
# rm -rf $TMPDIR/busybox 2>/dev/null
# mkdir -p $TMPDIR/busybox
# $BINDIR/busybox --install -s $TMPDIR/busybox
# rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot
# PATH=$TMPDIR/busybox:$PATH
chmod -R 755 $MAGISKBIN
chcon -h u:object_r:system_file:s0 $MAGISKBIN $MAGISKBIN/*

##########################################################################################
# Magisk Image
##########################################################################################

# TODO: Magisk Image

# Fix SuperSU.....
$BOOTMODE && $BINDIR/magiskpolicy --live "allow fsck * * *"

Expand All @@ -311,7 +297,7 @@ fi
MAGISKLOOP=$LOOPDEVICE

# Core folders and scripts
mkdir -p $COREDIR/bin $COREDIR/props $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null
mkdir -p $COREDIR/props $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null
cp -af $COMMONDIR/magiskhide/. $COREDIR/magiskhide

chmod -R 755 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
Expand Down Expand Up @@ -450,12 +436,8 @@ else
cpio_add 644 sepolicy sepolicy

# Add new items
cpio_mkdir 755 magisk

[ ! -z $SHA1 ] && echo "# STOCKSHA1=$SHA1" >> $COMMONDIR/init.magisk.rc
cpio_add 750 init.magisk.rc $COMMONDIR/init.magisk.rc

# cpio_add 750 sbin/magic_mask.sh $COMMONDIR/magic_mask.sh
cpio_add 755 sbin/magisk $BINDIR/magisk

# Create ramdisk backups
Expand Down
5 changes: 0 additions & 5 deletions scripts/magisk_uninstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ find_boot_image() {
# Environments
# Set permissions
chmod -R 755 $CHROMEDIR/futility $MAGISKBIN 2>/dev/null
# Temporary busybox for installation
mkdir -p $TMPDIR/busybox
$MAGISKBIN/busybox --install -s $TMPDIR/busybox
rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot
PATH=$TMPDIR/busybox:$PATH

# Find the boot image
find_boot_image
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added zip_static/chromeos/futility
Binary file not shown.
Binary file added zip_static/chromeos/kernel.keyblock
Binary file not shown.
Binary file added zip_static/chromeos/kernel_data_key.vbprivk
Binary file not shown.

0 comments on commit 623a879

Please sign in to comment.