This repository has been archived by the owner on Apr 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example build/menuconfig scripts
Signed-off-by: James Christopher Adduono <[email protected]>
- Loading branch information
Showing
3 changed files
with
233 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/bin/bash | ||
# script for building NetHunter kernels by jcadduono | ||
|
||
################### BEFORE STARTING ################ | ||
# | ||
# download a working toolchain and extract it somewhere and configure this | ||
# file to point to the toolchain's root directory. | ||
# this file should be placed in your kernel source folder with | ||
# the CONFIG section edited to work for your device. | ||
# | ||
# once you've set up the config section how you like it, you can simply run | ||
# ./build.sh [DEVICE] [TARGET] | ||
# | ||
# make a copy of your device's original defconfig file. | ||
# the new defconfig file should follow the format: | ||
# arch/arm64/configs/nethunter_yourdevice_defconfig | ||
# | ||
###################### CONFIG ###################### | ||
|
||
# default device name (change this!) | ||
DEFAULT_DEVICE=yourdevice | ||
|
||
# default target name | ||
DEFAULT_TARGET=nethunter | ||
|
||
# release version (increment this with new releases) | ||
RELEASE_VERSION=1.0 | ||
|
||
# directory containing cross-compile arm64 toolchain (change this!) | ||
TOOLCHAIN=/opt/toolchain/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu | ||
|
||
############## SCARY NO-TOUCHY STUFF ############### | ||
|
||
# root directory of kernel source git repo (default is this script's location) | ||
RDIR=$(pwd) | ||
|
||
CPU_THREADS=$(grep -c "processor" /proc/cpuinfo) | ||
# amount of cpu threads to use in kernel make process | ||
THREADS=$((CPU_THREADS + 1)) | ||
|
||
ABORT() { | ||
[ "$1" ] && echo "Error: $*" | ||
exit 1 | ||
} | ||
|
||
CONTINUE=false | ||
export ARCH=arm64 | ||
export CROSS_COMPILE=$TOOLCHAIN/bin/aarch64-linux-gnu- | ||
|
||
[ -x "${CROSS_COMPILE}gcc" ] || | ||
ABORT "Unable to find gcc cross-compiler at location: ${CROSS_COMPILE}gcc" | ||
|
||
while [ $# != 0 ]; do | ||
if [ "$1" = "--continue" ] || [ "$1" == "-c" ]; then | ||
CONTINUE=true | ||
elif [ ! "$TARGET" ]; then | ||
TARGET=$1 | ||
elif [ ! "$DEVICE" ]; then | ||
DEVICE=$1 | ||
else | ||
echo "Too many arguments!" | ||
echo "Usage: ./build.sh [--continue] [device] [target defconfig]" | ||
ABORT | ||
fi | ||
shift | ||
done | ||
|
||
[ "$DEVICE" ] || DEVICE=$DEFAULT_DEVICE | ||
[ "$TARGET" ] || TARGET=$DEFAULT_TARGET | ||
DEFCONFIG=${TARGET}_${DEVICE}_defconfig | ||
|
||
[ -f "$RDIR/arch/$ARCH/configs/${DEFCONFIG}" ] || | ||
ABORT "Config $DEFCONFIG not found in $ARCH configs!" | ||
|
||
export LOCALVERSION=$TARGET-$DEVICE-$RELEASE_VERSION | ||
|
||
CLEAN_BUILD() { | ||
echo "Cleaning build..." | ||
rm -rf build | ||
} | ||
|
||
SETUP_BUILD() { | ||
echo "Creating kernel config for $LOCALVERSION..." | ||
mkdir -p build | ||
make -C "$RDIR" O=build "$DEFCONFIG" \ | ||
|| ABORT "Failed to set up build" | ||
} | ||
|
||
BUILD_KERNEL() { | ||
echo "Starting build for $LOCALVERSION..." | ||
while ! make -C "$RDIR" O=build -j"$THREADS"; do | ||
read -rp "Build failed. Retry? " do_retry | ||
case $do_retry in | ||
Y|y) continue ;; | ||
*) return 1 ;; | ||
esac | ||
done | ||
} | ||
|
||
INSTALL_MODULES() { | ||
grep -q 'CONFIG_MODULES=y' build/.config || return 0 | ||
echo "Installing kernel modules to build/lib/modules..." | ||
while ! make -C "$RDIR" O=build \ | ||
INSTALL_MOD_PATH="." \ | ||
INSTALL_MOD_STRIP=1 \ | ||
modules_install | ||
do | ||
read -rp "Build failed. Retry? " do_retry | ||
case $do_retry in | ||
Y|y) continue ;; | ||
*) return 1 ;; | ||
esac | ||
done | ||
rm build/lib/modules/*/build build/lib/modules/*/source | ||
} | ||
|
||
cd "$RDIR" || ABORT "Failed to enter $RDIR!" | ||
|
||
if ! $CONTINUE; then | ||
CLEAN_BUILD | ||
SETUP_BUILD || | ||
ABORT "Failed to set up build!" | ||
fi | ||
|
||
BUILD_KERNEL && | ||
INSTALL_MODULES && | ||
echo "Finished building $LOCALVERSION!" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
# script for configuring NetHunter kernels by jcadduono | ||
|
||
################### BEFORE STARTING ################ | ||
# | ||
# download a working toolchain and extract it somewhere and configure this | ||
# file to point to the toolchain's root directory. | ||
# this file should be placed in your kernel source folder with | ||
# the CONFIG section edited to work for your device. | ||
# | ||
# once you've set up the config section how you like it, you can simply run | ||
# ./menuconfig.sh [DEVICE] [TARGET] | ||
# | ||
# make a copy of your device's original defconfig file. | ||
# the new defconfig file should follow the format: | ||
# arch/arm64/configs/nethunter_yourdevice_defconfig | ||
# | ||
###################### CONFIG ###################### | ||
|
||
# default device name (change this!) | ||
DEFAULT_DEVICE=yourdevice | ||
|
||
# default target name | ||
DEFAULT_TARGET=nethunter | ||
|
||
# directory containing cross-compile arm64 toolchain (change this!) | ||
TOOLCHAIN=/opt/toolchain/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu | ||
|
||
############## SCARY NO-TOUCHY STUFF ############### | ||
|
||
# root directory of kernel source git repo (default is this script's location) | ||
RDIR=$(pwd) | ||
|
||
ABORT() { | ||
[ "$1" ] && echo "Error: $*" | ||
exit 1 | ||
} | ||
|
||
export ARCH=arm64 | ||
export CROSS_COMPILE=$TOOLCHAIN/bin/aarch64-linux-gnu- | ||
|
||
[ -x "${CROSS_COMPILE}gcc" ] || | ||
ABORT "Unable to find gcc cross-compiler at location: ${CROSS_COMPILE}gcc" | ||
|
||
while [ $# != 0 ]; do | ||
if [ ! "$DEVICE" ]; then | ||
DEVICE=$1 | ||
elif [ ! "$TARGET" ]; then | ||
TARGET=$1 | ||
else | ||
echo "Too many arguments!" | ||
echo "Usage: ./menuconfig.sh [device] [target defconfig]" | ||
ABORT | ||
fi | ||
shift | ||
done | ||
|
||
[ "$DEVICE" ] || DEVICE=$DEFAULT_DEVICE | ||
[ "$TARGET" ] || TARGET=$DEFAULT_TARGET | ||
DEFCONFIG=${TARGET}_${DEVICE}_defconfig | ||
DEFCONFIG_FILE=$RDIR/arch/$ARCH/configs/$DEFCONFIG | ||
|
||
[ -f "$DEFCONFIG_FILE" ] || | ||
ABORT "Device config $DEFCONFIG not found in $ARCH configs!" | ||
|
||
cd "$RDIR" || ABORT "Failed to enter $RDIR!" | ||
|
||
echo "Cleaning build..." | ||
rm -rf build | ||
mkdir build | ||
make -s -i -C "$RDIR" O=build "$DEFCONFIG" menuconfig | ||
echo "Showing differences between old config and new config" | ||
echo "-----------------------------------------------------" | ||
if command -v colordiff >/dev/null 2>&1; then | ||
diff -Bwu --label "old config" "$DEFCONFIG_FILE" --label "new config" build/.config | colordiff | ||
else | ||
diff -Bwu --label "old config" "$DEFCONFIG_FILE" --label "new config" build/.config | ||
echo "-----------------------------------------------------" | ||
echo "Consider installing the colordiff package to make diffs easier to read" | ||
fi | ||
echo "-----------------------------------------------------" | ||
echo -n "Are you satisfied with these changes? y/N: " | ||
read -r option | ||
case $option in | ||
y|Y) | ||
cp build/.config "$DEFCONFIG_FILE" | ||
echo "Copied new config to $DEFCONFIG_FILE" | ||
;; | ||
*) | ||
echo "That's unfortunate" | ||
;; | ||
esac | ||
echo "Cleaning build..." | ||
rm -rf build | ||
echo "Done." |
8bddf3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it futile to try to build Nethunter for Pie?
I have build kernel successfully using menuconfig.sh and build.sh but when it comes to flashing via TWRP, I am having no luck patching the bootloader.
Not sure if its a A, B issue with PixelXL or just that the current builds are for up to Marshmellow and the Meta script needs to be updated for Pie.
I was thinking I could take advantage of the Magisk module support for Nethunter, but first I would like to compile a kernel with HID and Injection support.
Thank you for your consideration.
8bddf3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably an A/B thing but I don't have an A/B device to test and see what problems happen when flashing
would likely be boot-patcher.sh issue.
8bddf3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for responding.
After adding block location to devices.cfg I was able to resolve.
Now I gotta figure out which kernel module is causing the device to boot loop during bootanim.
Ref: devices.cfg