Last active
March 27, 2019 18:48
-
-
Save rektide/89deab81d697651d4bae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# uses https://github.com/osm0sis/mkbootimg | |
# some guidance via stackoverflow.com/questions/29803996/repacak-existing-boot-img-using-mkbootimg-cyanogenmod-12-1-lollipop | |
set -ex | |
CM=~/Downloads/cm-12.1-20150730-UNOFFICIAL-fireballx.zip | |
# extract: unzip, unpackbootimg, zcat, cpio | |
test -d cm || (mkdir cm && cd cm && unzip $CM) | |
test -d unpack || (mkdir unpack && cd unpack && unpackbootimg -i ../cm/boot.img -o .) | |
test -d ramdisk-cpio || (mkdir ramdisk-cpio && cd ramdisk-cpio && zcat ../unpack/boot.img-ramdisk.gz > ramdisk.cpio) | |
test -d ramdisk || (mkdir ramdisk && cd ramdisk && cpio -iv < ../ramdisk-cpio/ramdisk.cpio) | |
# you may wish to modify the extracted ramdisk at this point. | |
# just rm -r any build-* directories, and rerun to reassemble | |
# repack: cpio, gz, mkbootimg, zip | |
test -d build-cpio || (mkdir build-cpio && cd ramdisk && find . -print | cpio --create --verbose -H newc > ../build-cpio/ramdisk) | |
test -d build-gz || (mkdir build-gz && cd build-gz && gzip -k ../build-cpio/ramdisk -c > ./ramdisk.gz) | |
test -d build-bootimg || (mkdir build-bootimg && \ | |
mkbootimg --kernel unpack/boot.img-zImage \ | |
--ramdisk build-gz/ramdisk.gz \ | |
--cmdline "console=ttyHSL0,115200,n8 androidboot.hardware=qcom" \ | |
--base 0x80400000 \ | |
--pagesize 2048 \ | |
--kernel_offset 0x00008000 \ | |
--ramdisk_offset 0x01700000 \ | |
--tags_offset 0x00000100 \ | |
--output build-bootimg/boot2.img) | |
test -d build-cm || (mkdir build-cm && cd build-cm && unzip $CM && cp ../build-bootimg/boot2.img boot.img) | |
test -d build-zip || (mkdir build-zip && cd build-cm && zip -r ../build-zip/cm-hacked.zip .) | |
# unpackbootimg returns this information: | |
# BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom | |
# BOARD_KERNEL_BASE 80400000 | |
# BOARD_NAME | |
# BOARD_PAGE_SIZE 2048 | |
# BOARD_KERNEL_OFFSET 00008000 | |
# BOARD_RAMDISK_OFFSET 01700000 | |
# BOARD_TAGS_OFFSET 00000100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment