Skip to content

Commit

Permalink
Added AnyKernel build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuzzo committed Feb 19, 2014
1 parent f6397ab commit 14cb9c4
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 0 deletions.
30 changes: 30 additions & 0 deletions build-config
@@ -0,0 +1,30 @@
TOOLCHAINDIR=~/toolchain

TOOLCHAIN=linaro-13-02

CROSS_COMPILE=$TOOLCHAINDIR/$TOOLCHAIN/bin/arm-eabi-

LOCAL_BUILD_DIR=~/rez

TARGET_DIR=~/rez/updates

SYSTEM_PARTITION="/dev/block/mmcblk0p29"

DEFCONFIG=vigor_defconfig

FLASH_BOOT='/dev/block/mmcblk0p22'

PHONE='HTC Rezound'

# ----

N_CORES=8
VERSION=Funky-v3.2

# ----

BANNER=`cat <<EOF
ui_print("$VERSION");
ui_print("for");
ui_print("$PHONE");
EOF`
3 changes: 3 additions & 0 deletions build-initrd.sh
@@ -0,0 +1,3 @@
#!/bin/sh

cd initrd && find . | cpio --create --format='newc' | gzip -f > ../initrd.img
110 changes: 110 additions & 0 deletions build.sh
@@ -0,0 +1,110 @@
#!/bin/bash -e

msg() {
echo
echo ==== $* ====
echo
}

# -----------------------

. build-config

TOOLS_DIR=`dirname "$0"`
MAKE=$TOOLS_DIR/make.sh

# -----------------------

ZIP=$TARGET_DIR/update-$VERSION.zip
SHA1=$TOOLS_DIR/sha1.sh
UPDATE_ROOT=$LOCAL_BUILD_DIR/update
KEYS=$LOCAL_BUILD_DIR/keys
CERT=$KEYS/certificate.pem
KEY=$KEYS/key.pk8
ANYKERNEL=$LOCAL_BUILD_DIR/kernel
GLOBAL=$LOCAL_BUILD_DIR/global
POSTBOOT=$LOCAL_BUILD_DIR/postboot
VIDEOFIX=$LOCAL_BUILD_DIR/videofix
ZIMAGE=arch/arm/boot/zImage

msg Building: $VERSION
echo " Defconfig: $DEFCONFIG"
echo " Local build dir: $LOCAL_BUILD_DIR"
echo " Target dir: $TARGET_DIR"
echo " Tools dir: $TOOLS_DIR"
echo
echo " Target system partition: $SYSTEM_PARTITION"
echo

if [ -e $CERT -a -e $KEY ]
then
msg Reusing existing $CERT and $KEY
else
msg Regenerating keys, pleae enter the required information.

(
mkdir -p $KEYS
cd $KEYS
openssl genrsa -out key.pem 1024 && \
openssl req -new -key key.pem -out request.pem && \
openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem && \
openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
)
fi

if [ -e $UPDATE_ROOT ]
then
rm -rf $UPDATE_ROOT
fi

if [ -e $LOCAL_BUILD_DIR/update.zip ]
then
rm -f $LOCAL_BUILD_DIR/update.zip
fi

$MAKE $DEFCONFIG

perl -pi -e 's/(CONFIG_LOCALVERSION="[^"]*)/\1-'"$VERSION"'"/' .config

$MAKE -j$N_CORES

msg Kernel built successfully, building $ZIP

mkdir -p $UPDATE_ROOT/system/lib/modules
find . -name '*.ko' -exec cp {} $UPDATE_ROOT/system/lib/modules/ \;

mkdir -p $UPDATE_ROOT/META-INF/com/google/android
cp $TOOLS_DIR/update-binary $UPDATE_ROOT/META-INF/com/google/android

$SHA1

SUM=`sha1sum $ZIMAGE | cut --delimiter=' ' -f 1`

(
cat <<EOF
$BANNER
EOF
sed -e "s|@@SYSTEM_PARTITION@@|$SYSTEM_PARTITION|" \
-e "s|@@FLASH_BOOT@@|$FLASH_BOOT|" \
-e "s|@@SUM@@|$SUM|" \
< $TOOLS_DIR/updater-script
) > $UPDATE_ROOT/META-INF/com/google/android/updater-script


cp $ZIMAGE $ANYKERNEL
mkdir -p $UPDATE_ROOT/kernel
mkdir -p $UPDATE_ROOT/global
mkdir -p $UPDATE_ROOT/postboot
mkdir -p $UPDATE_ROOT/videofix
cp $ANYKERNEL/* $UPDATE_ROOT/kernel
cp $GLOBAL/* $UPDATE_ROOT/global
cp $POSTBOOT/* $UPDATE_ROOT/postboot
cp $VIDEOFIX/* $UPDATE_ROOT/videofix

(
cd $UPDATE_ROOT
zip -r ../update.zip .
)
java -jar $TOOLS_DIR/signapk.jar $CERT $KEY $LOCAL_BUILD_DIR/update.zip $ZIP

msg COMPLETE
4 changes: 4 additions & 0 deletions edit-initrd
@@ -0,0 +1,4 @@
#!/bin/sh

rm -rf initrd 2>/dev/null
mkdir initrd && (cd initrd && gunzip -f < ../initrd.img | cpio --extract)
10 changes: 10 additions & 0 deletions make.sh
@@ -0,0 +1,10 @@
#!/bin/bash -e

. build-config

make \
ARCH=arm \
CROSS_COMPILE="$CROSS_COMPILE" \
$*


3 changes: 3 additions & 0 deletions sha1.sh
@@ -0,0 +1,3 @@
#!/bin/bash -e

sha1sum arch/arm/boot/zImage > sha1
Binary file added signapk.jar
Binary file not shown.
Binary file added update-binary
Binary file not shown.
75 changes: 75 additions & 0 deletions updater-script
@@ -0,0 +1,75 @@

ui_print("Mounting /system");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount", "@@SYSTEM_PARTITION@@", "/system");
ui_print("Installing modules");
package_extract_dir("system", "/system");
package_extract_dir("kernel", "/tmp");
package_extract_dir("postboot", "/system/etc");
if
file_getprop("/system/build.prop","ro.aa.taskid")==264016
then
ui_print("@ Flashing Sense 3.6 OTA kernel");
endif;
if
file_getprop("/system/build.prop","ro.aa.taskid")==275361
then
ui_print("@ Flashing Sense 3.6 Global kernel");
package_extract_dir("videofix", "/system/etc/firmware");
package_extract_dir("global", "/system/lib");
endif;
if
file_getprop("/system/build.prop","ro.aa.taskid")==263510
then
ui_print("@ Flashing Sense 3.6 OTA/4.X kernel");
package_extract_dir("videofix", "/system/etc/firmware");
endif;
if
file_getprop("/system/build.prop","ro.aa.taskid")==290923
then
ui_print("@ Flashing Sense 3.6 OTA/4.X kernel");
package_extract_dir("videofix", "/system/etc/firmware");
endif;
if
file_getprop("/system/build.prop","ro.aa.taskid")==249167
then
ui_print("@ Flashing Sense 3.6 OTA/4.X kernel");
package_extract_dir("videofix", "/system/etc/firmware");
endif;
ui_print("Creating Boot Image...");
set_perm(0, 0, 0777, "/tmp/dd");
set_perm(0, 0, 0777, "/tmp/abootimg");
set_perm(0, 0, 0777, "/tmp/zip");
set_perm(0, 0, 0777, "/tmp/extractFilesFromTmpBoot.sh");
ui_print("--Extracting existing boot.img...");
run_program("/tmp/dd", "if=@@FLASH_BOOT@@", "of=/tmp/boot.img");;
ui_print("--Replacing kernel in boot.img...");
run_program("/tmp/abootimg", "-u", "/tmp/boot.img", "-k", "/tmp/zImage");
run_program("/tmp/dd", "if=/tmp/boot.img", "of=@@FLASH_BOOT@@");;
run_program("/tmp/dd", "if=@@FLASH_BOOT@@", "of=/tmp/tmp_boot.img");
run_program("/tmp/extractFilesFromTmpBoot.sh");
if
sha1_check(read_file("/tmp/boot/zImage")) == "@@SUM@@"
then
ui_print("Flash successful");
ui_print("Unmounting Filesystems");
else
ui_print("S-on or stock boot.img detected...");
ui_print("Adding zip to /sdcard...");
set_perm(0, 0, 0777, "/tmp/buildZip.sh");
set_perm(0, 0, 0777, "/tmp/copyToSD.sh");
set_perm(0, 0, 0777, "/tmp/rebootToBootloader.sh");
set_perm(0, 0, 0777, "/tmp/misctool");
run_program("/tmp/misctool", "w", "1.00.000.0");
run_program("/tmp/buildZip.sh");
run_program("/tmp/copyToSD.sh");
unmount("/sdcard");
ui_print("Done! PH98IMG.zip on /sdcard (external)");
ui_print("Script by con247 @xda.");
ui_print("Copying system files...");
ui_print("Rebooting to Bootloader (HBOOT)");
run_program("/tmp/rebootToBootloader.sh");
endif;
unmount("/system");
ui_print("Done");

0 comments on commit 14cb9c4

Please sign in to comment.