#!/bin/bash -e # # Copyright (c) 2009-2018 Robert Nelson <robertcnelson@gmail.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # Split out, so build_kernel.sh and build_deb.sh can share.. shopt -s nullglob . ${DIR}/version.sh if [ -f ${DIR}/system.sh ] ; then . ${DIR}/system.sh fi git_bin=$(which git) #git hard requirements: #git: --no-edit git="${git_bin} am" #git_patchset="" #git_opts if [ "${RUN_BISECT}" ] ; then git="${git_bin} apply" fi echo "Starting patch.sh" git_add () { ${git_bin} add . ${git_bin} commit -a -m 'testing patchset' } start_cleanup () { git="${git_bin} am --whitespace=fix" } cleanup () { if [ "${number}" ] ; then if [ "x${wdir}" = "x" ] ; then ${git_bin} format-patch -${number} -o ${DIR}/patches/ else if [ ! -d ${DIR}/patches/${wdir}/ ] ; then mkdir -p ${DIR}/patches/${wdir}/ fi ${git_bin} format-patch -${number} -o ${DIR}/patches/${wdir}/ unset wdir fi fi exit 2 } dir () { wdir="$1" if [ -d "${DIR}/patches/$wdir" ]; then echo "dir: $wdir" if [ "x${regenerate}" = "xenable" ] ; then start_cleanup fi number= for p in "${DIR}/patches/$wdir/"*.patch; do ${git} "$p" number=$(( $number + 1 )) done if [ "x${regenerate}" = "xenable" ] ; then cleanup fi fi unset wdir } cherrypick () { if [ ! -d ../patches/${cherrypick_dir} ] ; then mkdir -p ../patches/${cherrypick_dir} fi ${git_bin} format-patch -1 ${SHA} --start-number ${num} -o ../patches/${cherrypick_dir} num=$(($num+1)) } external_git () { git_tag="" echo "pulling: ${git_tag}" ${git_bin} pull --no-edit ${git_patchset} ${git_tag} ${git_bin} describe } aufs_fail () { echo "aufs4 failed" exit 2 } aufs4 () { echo "dir: aufs4" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then wget https://raw.githubusercontent.com/sfjro/aufs4-standalone/aufs${KERNEL_REL}/aufs4-kbuild.patch patch -p1 < aufs4-kbuild.patch || aufs_fail rm -rf aufs4-kbuild.patch ${git_bin} add . ${git_bin} commit -a -m 'merge: aufs4-kbuild' -s wget https://raw.githubusercontent.com/sfjro/aufs4-standalone/aufs${KERNEL_REL}/aufs4-base.patch patch -p1 < aufs4-base.patch || aufs_fail rm -rf aufs4-base.patch ${git_bin} add . ${git_bin} commit -a -m 'merge: aufs4-base' -s wget https://raw.githubusercontent.com/sfjro/aufs4-standalone/aufs${KERNEL_REL}/aufs4-mmap.patch patch -p1 < aufs4-mmap.patch || aufs_fail rm -rf aufs4-mmap.patch ${git_bin} add . ${git_bin} commit -a -m 'merge: aufs4-mmap' -s wget https://raw.githubusercontent.com/sfjro/aufs4-standalone/aufs${KERNEL_REL}/aufs4-standalone.patch patch -p1 < aufs4-standalone.patch || aufs_fail rm -rf aufs4-standalone.patch ${git_bin} add . ${git_bin} commit -a -m 'merge: aufs4-standalone' -s ${git_bin} format-patch -4 -o ../patches/aufs4/ cd ../ if [ ! -d ./aufs4-standalone ] ; then ${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/aufs4-standalone --depth=1 else rm -rf ./aufs4-standalone || true ${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/aufs4-standalone --depth=1 fi cd ./KERNEL/ cp -v ../aufs4-standalone/Documentation/ABI/testing/*aufs ./Documentation/ABI/testing/ mkdir -p ./Documentation/filesystems/aufs/ cp -rv ../aufs4-standalone/Documentation/filesystems/aufs/* ./Documentation/filesystems/aufs/ mkdir -p ./fs/aufs/ cp -v ../aufs4-standalone/fs/aufs/* ./fs/aufs/ cp -v ../aufs4-standalone/include/uapi/linux/aufs_type.h ./include/uapi/linux/ ${git_bin} add . ${git_bin} commit -a -m 'merge: aufs4' -s ${git_bin} format-patch -5 -o ../patches/aufs4/ rm -rf ../aufs4-standalone/ || true git reset --hard HEAD~5 start_cleanup ${git} "${DIR}/patches/aufs4/0001-merge-aufs4-kbuild.patch" ${git} "${DIR}/patches/aufs4/0002-merge-aufs4-base.patch" ${git} "${DIR}/patches/aufs4/0003-merge-aufs4-mmap.patch" ${git} "${DIR}/patches/aufs4/0004-merge-aufs4-standalone.patch" ${git} "${DIR}/patches/aufs4/0005-merge-aufs4.patch" wdir="aufs4" number=5 cleanup fi ${git} "${DIR}/patches/aufs4/0001-merge-aufs4-kbuild.patch" ${git} "${DIR}/patches/aufs4/0002-merge-aufs4-base.patch" ${git} "${DIR}/patches/aufs4/0003-merge-aufs4-mmap.patch" ${git} "${DIR}/patches/aufs4/0004-merge-aufs4-standalone.patch" ${git} "${DIR}/patches/aufs4/0005-merge-aufs4.patch" } rt_cleanup () { echo "rt: needs fixup" exit 2 } rt () { echo "dir: rt" rt_patch="${KERNEL_REL}${kernel_rt}" #un-matched kernel #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then cd ../ if [ ! -d ./linux-rt-devel ] ; then ${git_bin} clone -b linux-4.14.y-rt-patches https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git --depth=1 else rm -rf ./linux-rt-devel || true ${git_bin} clone -b linux-4.14.y-rt-patches https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git --depth=1 fi cd ./KERNEL/ exit 2 #https://raphaelhertzog.com/2012/08/08/how-to-use-quilt-to-manage-patches-in-debian-packages/ #export QUILT_PATCHES=`pwd`/linux-rt-devel/patches #export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" #quilt push -a quilt delete -r localversion.patch #fix... #quilt push -f #quilt refresh #final... #quilt pop -a #quilt push -a #git add . #git commit -a -m 'merge: CONFIG_PREEMPT_RT Patch Set' -s exit 2 fi if [ -d ../linux-rt-devel ] ; then rm -rf ../linux-rt-devel || true fi #matched kernel #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then wget -c https://www.kernel.org/pub/linux/kernel/projects/rt/${KERNEL_REL}/patch-${rt_patch}.patch.xz xzcat patch-${rt_patch}.patch.xz | patch -p1 || rt_cleanup rm -f patch-${rt_patch}.patch.xz rm -f localversion-rt ${git_bin} add . ${git_bin} commit -a -m 'merge: CONFIG_PREEMPT_RT Patch Set' -s ${git_bin} format-patch -1 -o ../patches/rt/ exit 2 fi ${git} "${DIR}/patches/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch" } wireguard_fail () { echo "WireGuard failed" exit 2 } wireguard () { echo "dir: WireGuard" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then cd ../ if [ ! -d ./WireGuard ] ; then ${git_bin} clone https://git.zx2c4.com/WireGuard --depth=1 else rm -rf ./WireGuard || true ${git_bin} clone https://git.zx2c4.com/WireGuard --depth=1 fi cd ./KERNEL/ ../WireGuard/contrib/kernel-tree/create-patch.sh | patch -p1 || wireguard_fail ${git_bin} add . ${git_bin} commit -a -m 'merge: WireGuard' -s ${git_bin} format-patch -1 -o ../patches/WireGuard/ rm -rf ../WireGuard/ || true git reset --hard HEAD^ start_cleanup ${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch" wdir="WireGuard" number=1 cleanup fi ${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch" } local_patch () { echo "dir: dir" ${git} "${DIR}/patches/dir/0001-patch.patch" } #external_git #aufs4 #rt #wireguard #local_patch pre_backports () { echo "dir: backports/${subsystem}" cd ~/linux-src/ ${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master ${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master --tags ${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master --tags if [ ! "x${backport_tag}" = "x" ] ; then ${git_bin} checkout ${backport_tag} -b tmp fi cd - } post_backports () { if [ ! "x${backport_tag}" = "x" ] ; then cd ~/linux-src/ ${git_bin} checkout master -f ; ${git_bin} branch -D tmp cd - fi ${git_bin} add . ${git_bin} commit -a -m "backports: ${subsystem}: from: linux.git" -s if [ ! -d ../patches/backports/${subsystem}/ ] ; then mkdir -p ../patches/backports/${subsystem}/ fi ${git_bin} format-patch -1 -o ../patches/backports/${subsystem}/ } patch_backports (){ echo "dir: backports/${subsystem}" ${git} "${DIR}/patches/backports/${subsystem}/0001-backports-${subsystem}-from-linux.git.patch" } backports () { backport_tag="v4.x-y" subsystem="xyz" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then pre_backports mkdir -p ./x/ cp -v ~/linux-src/x/* ./x/ post_backports exit 2 else patch_backports fi } reverts () { echo "dir: reverts" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then start_cleanup fi #https://github.com/torvalds/linux/commit/00f0ea70d2b82b7d7afeb1bdedc9169eb8ea6675 # #Causes bone_capemgr to get stuck on slot 1 and just eventually exit "without" checking slot2/3/4... # #[ 5.406775] bone_capemgr bone_capemgr: Baseboard: 'A335BNLT,00C0,2516BBBK2626' #[ 5.414178] bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4 #[ 5.422573] bone_capemgr bone_capemgr: Failed to add slot #1 #${git} "${DIR}/patches/reverts/0001-Revert-eeprom-at24-check-if-the-chip-is-functional-i.patch" if [ "x${regenerate}" = "xenable" ] ; then wdir="reverts" number=1 cleanup fi } drivers () { dir 'drivers/btrfs' dir 'drivers/pwm' dir 'drivers/spi' dir 'drivers/tsl2550' dir 'drivers/tps65217' dir 'drivers/opp' dir 'drivers/wiznet' dir 'drivers/ti/overlays' echo "dir: drivers/ti/firmware" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then start_cleanup fi #http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=summary #git clone git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git #cd ti-amx3-cm3-pm-firmware/ #git checkout origin/ti-v4.1.y-next -b tmp #commit ee4acf427055d7e87d9d1d82296cbd05e388642e #Author: Dave Gerlach <d-gerlach@ti.com> #Date: Tue Sep 6 14:33:11 2016 -0500 # # CM3: Firmware release 0x192 # # This version, 0x192, includes the following changes: # - Fix DDR IO CTRL handling during suspend so both am335x and am437x # use optimal low power state and restore the exact previous # configuration. # - Explicitly configure PER state in standby, even though it is # configured to ON state to ensure proper state. # - Add new 'halt' flag in IPC_REG4 bit 11 to allow HLOS to configure # the suspend path to wait immediately before suspending the system # entirely to allow JTAG visiblity for debug. # - Fix board voltage scaling binaries i2c speed configuration in # order to properly configure 100khz operation. # # Signed-off-by: Dave Gerlach <d-gerlach@ti.com> #cp -v bin/am* /opt/github/bb.org/ti-4.4/normal/KERNEL/firmware/ #git add -f ./firmware/am* ${git} "${DIR}/patches/drivers/ti/firmware/0001-add-am33x-firmware.patch" if [ "x${regenerate}" = "xenable" ] ; then wdir="drivers/ti/firmware" number=1 cleanup fi dir 'drivers/ti/cpsw' dir 'drivers/ti/etnaviv' dir 'drivers/ti/eqep' dir 'drivers/ti/mcasp' dir 'drivers/ti/rpmsg' dir 'drivers/ti/serial' dir 'drivers/ti/uio' dir 'drivers/ti/gpio' } soc () { # dir 'soc/exynos' # dir 'soc/imx/udoo' # dir 'soc/imx/wandboard' # dir 'soc/imx' dir 'soc/ti' dir 'soc/ti/bone_common' dir 'soc/ti/uboot' dir 'soc/ti/blue' dir 'soc/ti/sancloud' dir 'soc/ti/abbbi' dir 'soc/ti/am335x_olimex_som' dir 'soc/ti/beaglebone_capes' dir 'soc/ti/pocketbeagle' } dtb_makefile_append () { sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device' \\:g' arch/arm/boot/dts/Makefile } beaglebone () { #This has to be last... echo "dir: beaglebone/dtbs" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then patch -p1 < "${DIR}/patches/beaglebone/dtbs/0001-sync-am335x-peripheral-pinmux.patch" exit 2 fi #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then start_cleanup fi ${git} "${DIR}/patches/beaglebone/dtbs/0001-sync-am335x-peripheral-pinmux.patch" if [ "x${regenerate}" = "xenable" ] ; then number=1 cleanup fi #### #dtb makefile echo "dir: beaglebone/generated" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then device="am335x-boneblack-uboot.dtb" ; dtb_makefile_append # device="am335x-boneblack-roboticscape.dtb" ; dtb_makefile_append # device="am335x-boneblack-wireless-roboticscape.dtb" ; dtb_makefile_append device="am335x-sancloud-bbe.dtb" ; dtb_makefile_append device="am335x-abbbi.dtb" ; dtb_makefile_append device="am335x-olimex-som.dtb" ; dtb_makefile_append device="am335x-boneblack-wl1835mod.dtb" ; dtb_makefile_append device="am335x-boneblack-bbbmini.dtb" ; dtb_makefile_append device="am335x-boneblack-bbb-exp-c.dtb" ; dtb_makefile_append device="am335x-boneblack-bbb-exp-r.dtb" ; dtb_makefile_append device="am335x-boneblack-audio.dtb" ; dtb_makefile_append device="am335x-pocketbeagle.dtb" ; dtb_makefile_append git commit -a -m 'auto generated: capes: add dtbs to makefile' -s git format-patch -1 -o ../patches/beaglebone/generated/ exit 2 else ${git} "${DIR}/patches/beaglebone/generated/0001-auto-generated-capes-add-dtbs-to-makefile.patch" fi } sgx () { echo "dir: sgx" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then start_cleanup fi ${git} "${DIR}/patches/sgx/0001-HACK-drm-fb_helper-enable-panning-support.patch" ${git} "${DIR}/patches/sgx/0002-HACK-drm-tilcdc-add-vsync-callback-for-use-in-omaplf.patch" ${git} "${DIR}/patches/sgx/0003-ARM-OMAP2-Use-pdata-quirks-for-sgx-deassert_hardrese.patch" ${git} "${DIR}/patches/sgx/0004-ARM-dts-am33xx-add-DT-node-for-gpu.patch" ${git} "${DIR}/patches/sgx/0005-Revert-ARM-reduce-visibility-of-dmac_-functions.patch" ${git} "${DIR}/patches/sgx/0006-arm-Export-cache-flush-management-symbols-when-MULTI.patch" if [ "x${regenerate}" = "xenable" ] ; then wdir="sgx" number=6 cleanup fi } ### #backports reverts drivers soc beaglebone dir 'build/gcc' sgx packaging () { echo "dir: packaging" #regenerate="enable" if [ "x${regenerate}" = "xenable" ] ; then cp -v "${DIR}/3rdparty/packaging/builddeb" "${DIR}/KERNEL/scripts/package" #Needed for v4.11.x and less #patch -p1 < "${DIR}/patches/packaging/0002-Revert-deb-pkg-Remove-the-KBUILD_IMAGE-workaround.patch" ${git_bin} commit -a -m 'packaging: sync builddeb changes' -s ${git_bin} format-patch -1 -o "${DIR}/patches/packaging" exit 2 else ${git} "${DIR}/patches/packaging/0001-packaging-sync-builddeb-changes.patch" fi } packaging echo "patch.sh ran successfully"