Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Commit

Permalink
flasher: Implement proper error-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Oct 11, 2014
1 parent 0f5bdec commit 9a43946
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
Binary file modified archikernel/flasher/META-INF/com/google/android/update-binary
Binary file not shown.
27 changes: 18 additions & 9 deletions archikernel/flasher/META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,33 @@ assert(getprop("ro.product.device") == "m0" || getprop("ro.build.product") == "m
ui_print("root@ArchiKernel:~# Ready!");
set_progress(0.1);
run_program("/sbin/mount", "-t", "auto", "/system");

ui_print("root@ArchiKernel:~# Flashing ArchiKernel");
run_program("/sbin/mount", "-t", "auto", "/data");
set_progress(0.2);
ui_print("root@ArchiKernel:~# Flashing ArchiKernel");
delete_recursive("/tmp/archikernel");
package_extract_dir("core", "/tmp/archikernel");
set_perm(0, 0, 0755, "/tmp/archikernel/init.sh");
package_extract_file("prebuilt/zImage", "/tmp/archikernel/zImage");
delete_recursive("/system/lib/modules");
package_extract_dir("prebuilt/system", "/system");
package_extract_dir("overlay", "/");
set_progress(0.5);
run_program("/tmp/archikernel/init.sh");
set_progress(0.8);
set_progress(0.3);

if run_program("/tmp/archikernel/init.sh") == "0" then
ui_print("===================================");
ui_print(" ArchiKernel Flashed Successfully ");
ui_print("Please share your experience on XDA");
ui_print("===================================");
else
ui_print("=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=");
ui_print("ERROR!!! Please attach: ");
ui_print("/data/media/0/ArchiKernelError.log");
ui_print("on forum.xda-developers.com");
ui_print("=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=");
run_program("/sbin/cp", "/tmp/archikernel/ArchiKernel.log", "/data/media/0/ArchiKernelError.log");
endif;

ui_print("===================================");
ui_print(" ArchiKernel Flashed Successfully ");
ui_print("Please share your experience on XDA");
ui_print("===================================");
set_progress(0.9);
unmount("/system");
unmount("/data");
set_progress(1.0);
19 changes: 9 additions & 10 deletions archikernel/flasher/core/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ date
echo "INFO: ArchiKernel flasher ready!"
echo "INFO: Safety check: ON, flasher will immediately terminate in case of ANY error"

if [ ! -f "$AK/mkbootimg-static" -o ! -f "$AK/unpackbootimg-static" ]; then
if [[ ! -f "$AK/mkbootimg-static" || ! -f "$AK/unpackbootimg-static" ]]; then
echo "FATAL ERROR: No bootimg tools?!"
exit 1
else
chmod 755 "$AK/mkbootimg-static" "$AK/unpackbootimg-static"
fi

echo "INFO: Pulling boot.img from $KERNEL"
if [ ! -z "$(which dump_image)" ]; then
if [[ ! -z "$(which dump_image)" ]]; then
dump_image "$KERNEL" "$AK/boot.img"
else
dd if="$KERNEL" of="$AK/boot.img"
Expand All @@ -55,14 +55,14 @@ fi
mkdir -p "$AKDROP/ramdisk"
echo "INFO: Unpacking pulled boot.img"
"$AK/unpackbootimg-static" -i "$AK/boot.img" -o "$AKDROP"
if [ -f "$AKDROP/boot.img-ramdisk.gz" ]; then
if [ "$PARSERAMDISK" -eq 1 ]; then
if [[ -f "$AKDROP/boot.img-ramdisk.gz" ]]; then
if [[ "$PARSERAMDISK" -eq 1 ]]; then
echo "INFO: Ramdisk in gzip format found, extracting..."
cd "$AKDROP/ramdisk"
gunzip -c ../boot.img-ramdisk.gz | cpio -i

# Detect AOSP/Samsung variant based on existing modules in ramdisk
if [ -d "$AKDROP/ramdisk/lib/modules" ]; then
if [[ -d "$AKDROP/ramdisk/lib/modules" ]]; then
echo "INFO: Detected Samsung variant"

# Remove all current modules from ramdisk
Expand All @@ -82,7 +82,7 @@ if [ -f "$AKDROP/boot.img-ramdisk.gz" ]; then
fi

# If we have any ramdisk content, write it
if [ -d "$AK/ramdisk" ]; then
if [[ -d "$AK/ramdisk" ]]; then
echo "INFO: Overwriting ramdisk with custom content"
find "$AK/ramdisk" -mindepth 1 -maxdepth 1 | while read line; do
cp -pR "$line" .
Expand All @@ -92,13 +92,13 @@ if [ -f "$AKDROP/boot.img-ramdisk.gz" ]; then
# If we have any executable files/folders, chmod them
TO755="sbin/ArchiKernel-Init res/uci.sh"
for FILE in $TO755; do
if [ -e "$AKDROP/ramdisk/$FILE" ]; then
if [[ -e "$AKDROP/ramdisk/$FILE" ]]; then
chmod 755 "$AKDROP/ramdisk/$FILE"
fi
done

# Add ArchiKernel Init if required
if [ "$(grep -qi "ArchiKernel-Init" "$AKDROP/ramdisk/init.rc"; echo $?)" -ne 0 ]; then
if [[ "$(grep -qi "ArchiKernel-Init" "$AKDROP/ramdisk/init.rc"; echo $?)" -ne 0 ]]; then
echo "INFO: User is flashing the kernel for the first time!"
{
echo
Expand Down Expand Up @@ -135,7 +135,7 @@ echo "INFO: Combining ArchiKernel zImage and current kernel ramdisk"
echo "INFO: newboot.img ready!"

echo "INFO: Flashing newboot.img on $KERNEL"
if [ ! -z "$(which flash_image)" ]; then
if [[ ! -z "$(which flash_image)" ]]; then
flash_image "$KERNEL" "$AK/newboot.img"
else
dd if="$AK/newboot.img" of="$KERNEL"
Expand All @@ -145,5 +145,4 @@ echo "SUCCESS: Everything finished successfully!"
touch "$AK/_OK"
date

sync
exit 0

0 comments on commit 9a43946

Please sign in to comment.