Newer
Older
Robert Nelson
committed
#!/bin/bash -e
# Copyright (c) 2009-2019 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..
Robert Nelson
committed
. ${DIR}/version.sh
Robert Nelson
committed
git_bin=$(which git)
#git hard requirements:
#git: --no-edit
Robert Nelson
committed
git="${git_bin} am"
Robert Nelson
committed
#git_patchset=""
#git_opts
Robert Nelson
committed
git="${git_bin} apply"
Robert Nelson
committed
${git_bin} add .
${git_bin} commit -a -m 'testing patchset'
Robert Nelson
committed
git="${git_bin} am --whitespace=fix"
Robert Nelson
committed
if [ "x${wdir}" = "x" ] ; then
Robert Nelson
committed
${git_bin} format-patch -${number} -o ${DIR}/patches/
Robert Nelson
committed
else
if [ ! -d ${DIR}/patches/${wdir}/ ] ; then
mkdir -p ${DIR}/patches/${wdir}/
fi
Robert Nelson
committed
${git_bin} format-patch -${number} -o ${DIR}/patches/${wdir}/
Robert Nelson
committed
unset wdir
fi
Robert Nelson
committed
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}
Robert Nelson
committed
fi
Robert Nelson
committed
${git_bin} format-patch -1 ${SHA} --start-number ${num} -o ../patches/${cherrypick_dir}
Robert Nelson
committed
num=$(($num+1))
}
Robert Nelson
committed
external_git () {
git_tag=""
echo "pulling: ${git_tag}"
Robert Nelson
committed
${git_bin} pull --no-edit ${git_patchset} ${git_tag}
Robert Nelson
committed
${git_bin} describe
Robert Nelson
committed
}
aufs () {
echo "dir: aufs"
aufs_prefix="aufs5-"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}kbuild.patch
patch -p1 < ${aufs_prefix}kbuild.patch || aufs_fail
rm -rf ${aufs_prefix}kbuild.patch
Robert Nelson
committed
${git_bin} add .
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}base.patch
patch -p1 < ${aufs_prefix}base.patch || aufs_fail
rm -rf ${aufs_prefix}base.patch
Robert Nelson
committed
${git_bin} add .
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}mmap.patch
patch -p1 < ${aufs_prefix}mmap.patch || aufs_fail
rm -rf ${aufs_prefix}mmap.patch
Robert Nelson
committed
${git_bin} add .
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}standalone.patch
patch -p1 < ${aufs_prefix}standalone.patch || aufs_fail
rm -rf ${aufs_prefix}standalone.patch
Robert Nelson
committed
${git_bin} add .
Robert Nelson
committed
cd ../
if [ ! -d ./${aufs_prefix}standalone ] ; then
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/${aufs_prefix}standalone --depth=1
rm -rf ./${aufs_prefix}standalone || true
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/${aufs_prefix}standalone --depth=1
Robert Nelson
committed
fi
cd ./KERNEL/
cp -v ../${aufs_prefix}standalone/Documentation/ABI/testing/*aufs ./Documentation/ABI/testing/
Robert Nelson
committed
mkdir -p ./Documentation/filesystems/aufs/
cp -rv ../${aufs_prefix}standalone/Documentation/filesystems/aufs/* ./Documentation/filesystems/aufs/
Robert Nelson
committed
mkdir -p ./fs/aufs/
cp -v ../${aufs_prefix}standalone/fs/aufs/* ./fs/aufs/
cp -v ../${aufs_prefix}standalone/include/uapi/linux/aufs_type.h ./include/uapi/linux/
Robert Nelson
committed
Robert Nelson
committed
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs' -s
${git_bin} format-patch -5 -o ../patches/aufs/
Robert Nelson
committed
Robert Nelson
committed
start_cleanup
${git} "${DIR}/patches/aufs/0001-merge-aufs-kbuild.patch"
${git} "${DIR}/patches/aufs/0002-merge-aufs-base.patch"
${git} "${DIR}/patches/aufs/0003-merge-aufs-mmap.patch"
${git} "${DIR}/patches/aufs/0004-merge-aufs-standalone.patch"
${git} "${DIR}/patches/aufs/0005-merge-aufs.patch"
Robert Nelson
committed
fi
${git} "${DIR}/patches/aufs/0001-merge-aufs-kbuild.patch"
${git} "${DIR}/patches/aufs/0002-merge-aufs-base.patch"
${git} "${DIR}/patches/aufs/0003-merge-aufs-mmap.patch"
${git} "${DIR}/patches/aufs/0004-merge-aufs-standalone.patch"
${git} "${DIR}/patches/aufs/0005-merge-aufs.patch"
Robert Nelson
committed
rt_cleanup () {
echo "rt: needs fixup"
exit 2
}
rt () {
echo "dir: rt"
rt_patch="${KERNEL_REL}${kernel_rt}"
Robert Nelson
committed
#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
Robert Nelson
committed
${git_bin} add .
${git_bin} commit -a -m 'merge: CONFIG_PREEMPT_RT Patch Set' -s
${git_bin} format-patch -1 -o ../patches/rt/
Robert Nelson
committed
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
${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
start_cleanup
${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch"
wdir="WireGuard"
number=1
cleanup
fi
${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch"
}
#http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=shortlog;h=refs/heads/ti-v4.1.y-next
echo "dir: drivers/ti/firmware"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./ti-amx3-cm3-pm-firmware ] ; then
${git_bin} clone -b ti-v4.1.y-next git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
else
rm -rf ./ti-amx3-cm3-pm-firmware || true
${git_bin} clone -b ti-v4.1.y-next git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
fi
cd ./KERNEL/
cp -v ../ti-amx3-cm3-pm-firmware/bin/am* ./firmware/
${git_bin} add -f ./firmware/am*
${git_bin} commit -a -m 'Add AM335x CM3 Power Managment Firmware' -s
${git_bin} format-patch -1 -o ../patches/drivers/ti/firmware/
rm -rf ../ti-amx3-cm3-pm-firmware/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/drivers/ti/firmware/0001-Add-AM335x-CM3-Power-Managment-Firmware.patch"
wdir="drivers/ti/firmware"
number=1
cleanup
fi
${git} "${DIR}/patches/drivers/ti/firmware/0001-Add-AM335x-CM3-Power-Managment-Firmware.patch"
Robert Nelson
committed
local_patch () {
echo "dir: dir"
${git} "${DIR}/patches/dir/0001-patch.patch"
}
Robert Nelson
committed
#external_git
Robert Nelson
committed
#local_patch
Robert Nelson
committed
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
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 () {
Robert Nelson
committed
Robert Nelson
committed
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
Robert Nelson
committed
post_backports
Robert Nelson
committed
exit 2
else
patch_backports
Robert Nelson
committed
fi
}
reverts () {
echo "dir: reverts"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
start_cleanup
fi
#${git} "${DIR}/patches/reverts/0001-Revert-xyz.patch"
Robert Nelson
committed
number=1
dir 'drivers/ti/eqep'
dir 'drivers/ti/rpmsg'
# dir 'soc/imx/udoo'
# dir 'soc/imx/wandboard'
dir 'soc/ti/omap3'
dir 'soc/ti/omap4'
dir 'soc/ti/am335x'
dtb_makefile_append () {
sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device' \\:g' arch/arm/boot/dts/Makefile
}
beaglebone () {
if [ "x${regenerate}" = "xenable" ] ; then
device="am335x-abbbi.dtb" ; dtb_makefile_append
device="am335x-boneblack-uboot.dtb" ; dtb_makefile_append
device="am335x-bone-uboot-univ.dtb" ; dtb_makefile_append
device="am335x-boneblack-uboot-univ.dtb" ; dtb_makefile_append
device="am335x-bonegreen-wireless-uboot-univ.dtb" ; dtb_makefile_append
git commit -a -m 'auto generated: capes: add dtbs to makefile' -s
git format-patch -1 -o ../patches/beaglebone/generated/
else
${git} "${DIR}/patches/beaglebone/generated/0001-auto-generated-capes-add-dtbs-to-makefile.patch"
Robert Nelson
committed
###
#backports
Robert Nelson
committed
drivers
soc
beaglebone
Robert Nelson
committed
packaging () {
echo "dir: packaging"
Robert Nelson
committed
if [ "x${regenerate}" = "xenable" ] ; then
Robert Nelson
committed
cp -v "${DIR}/3rdparty/packaging/Makefile" "${DIR}/KERNEL/scripts/package"
Robert Nelson
committed
cp -v "${DIR}/3rdparty/packaging/builddeb" "${DIR}/KERNEL/scripts/package"
cp -v "${DIR}/3rdparty/packaging/mkdebian" "${DIR}/KERNEL/scripts/package"
Robert Nelson
committed
${git_bin} commit -a -m 'packaging: sync builddeb changes' -s
${git_bin} format-patch -1 -o "${DIR}/patches/packaging"
Robert Nelson
committed
exit 2
Robert Nelson
committed
else
${git} "${DIR}/patches/packaging/0001-packaging-sync-builddeb-changes.patch"
fi
Robert Nelson
committed
}
Robert Nelson
committed
echo "patch.sh ran successfully"