Newer
Older
Robert Nelson
committed
#!/bin/bash -e
# Copyright (c) 2009-2022 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_fail () {
echo "aufs failed"
exit 2
}
aufs () {
#https://github.com/sfjro/aufs-standalone/tree/aufs6.0
aufs_prefix="aufs6-"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
KERNEL_REL=6.0
wget https://raw.githubusercontent.com/sfjro/aufs-standalone/aufs${KERNEL_REL}/${aufs_prefix}kbuild.patch
patch -p1 < ${aufs_prefix}kbuild.patch || aufs_fail
rm -rf ${aufs_prefix}kbuild.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-kbuild' -s
wget https://raw.githubusercontent.com/sfjro/aufs-standalone/aufs${KERNEL_REL}/${aufs_prefix}base.patch
patch -p1 < ${aufs_prefix}base.patch || aufs_fail
rm -rf ${aufs_prefix}base.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-base' -s
wget https://raw.githubusercontent.com/sfjro/aufs-standalone/aufs${KERNEL_REL}/${aufs_prefix}mmap.patch
patch -p1 < ${aufs_prefix}mmap.patch || aufs_fail
rm -rf ${aufs_prefix}mmap.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-mmap' -s
wget https://raw.githubusercontent.com/sfjro/aufs-standalone/aufs${KERNEL_REL}/${aufs_prefix}standalone.patch
patch -p1 < ${aufs_prefix}standalone.patch || aufs_fail
rm -rf ${aufs_prefix}standalone.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-standalone' -s
${git_bin} format-patch -4 -o ../patches/aufs/
cd ../
if [ ! -d ./aufs-standalone ] ; then
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/aufs-standalone --depth=1
cd ./aufs-standalone/
aufs_hash=$(git rev-parse HEAD)
cd -
else
rm -rf ./aufs-standalone || true
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/aufs-standalone --depth=1
cd ./aufs-standalone/
aufs_hash=$(git rev-parse HEAD)
cd -
fi
cd ./KERNEL/
cp -v ../aufs-standalone/Documentation/ABI/testing/*aufs ./Documentation/ABI/testing/
cp -rv ../aufs-standalone/Documentation/filesystems/aufs/* ./Documentation/filesystems/aufs/
cp -v ../aufs-standalone/fs/aufs/* ./fs/aufs/
cp -v ../aufs-standalone/include/uapi/linux/aufs_type.h ./include/uapi/linux/
${git_bin} commit -a -m 'merge: aufs' -m "https://github.com/sfjro/aufs-standalone/commit/${aufs_hash}" -s
${git_bin} format-patch -5 -o ../patches/aufs/
echo "AUFS: https://github.com/sfjro/aufs-standalone/commit/${aufs_hash}" > ../patches/git/AUFS
rm -rf ../aufs-standalone/ || true
${git_bin} reset --hard HEAD~5
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"
wdir="aufs"
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
wpanusb () {
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./wpanusb ] ; then
${git_bin} clone https://github.com/statropy/wpanusb --depth=1
cd ./wpanusb
wpanusb_hash=$(git rev-parse HEAD)
cd -
else
rm -rf ./wpanusb || true
${git_bin} clone https://github.com/statropy/wpanusb --depth=1
cd ./wpanusb
wpanusb_hash=$(git rev-parse HEAD)
cd -
fi
cd ./KERNEL/
cp -v ../wpanusb/wpanusb.h drivers/net/ieee802154/
cp -v ../wpanusb/wpanusb.c drivers/net/ieee802154/
${git_bin} add .
${git_bin} commit -a -m 'merge: wpanusb: https://github.com/statropy/wpanusb' -m "https://github.com/statropy/wpanusb/commit/${wpanusb_hash}" -s
${git_bin} format-patch -1 -o ../patches/wpanusb/
echo "WPANUSB: https://github.com/statropy/wpanusb/commit/${wpanusb_hash}" > ../patches/git/WPANUSB
rm -rf ../wpanusb/ || true
${git_bin} reset --hard HEAD~1
start_cleanup
${git} "${DIR}/patches/wpanusb/0001-merge-wpanusb-https-github.com-statropy-wpanusb.patch"
wdir="wpanusb"
number=1
cleanup
exit 2
fi
dir 'wpanusb'
}
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
bcfserial () {
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./bcfserial ] ; then
${git_bin} clone https://github.com/statropy/bcfserial --depth=1
cd ./bcfserial
bcfserial_hash=$(git rev-parse HEAD)
cd -
else
rm -rf ./bcfserial || true
${git_bin} clone https://github.com/statropy/bcfserial --depth=1
cd ./wpanusb
bcfserial_hash=$(git rev-parse HEAD)
cd -
fi
cd ./KERNEL/
cp -v ../bcfserial/bcfserial.c drivers/net/ieee802154/
${git_bin} add .
${git_bin} commit -a -m 'merge: bcfserial: https://github.com/statropy/bcfserial' -m "https://github.com/statropy/bcfserial/commit/${bcfserial_hash}" -s
${git_bin} format-patch -1 -o ../patches/bcfserial/
echo "BCFSERIAL: https://github.com/statropy/bcfserial/commit/${bcfserial_hash}" > ../patches/git/BCFSERIAL
rm -rf ../bcfserial/ || true
${git_bin} reset --hard HEAD~1
start_cleanup
${git} "${DIR}/patches/bcfserial/0001-merge-bcfserial-https-github.com-statropy-bcfserial.patch"
wdir="bcfserial"
number=1
cleanup
exit 2
fi
dir 'bcfserial'
}
Robert Nelson
committed
rt_cleanup () {
echo "rt: needs fixup"
exit 2
}
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 .
Robert Nelson
committed
${git_bin} commit -a -m 'merge: CONFIG_PREEMPT_RT Patch Set' -m "patch-${rt_patch}.patch.xz" -s
Robert Nelson
committed
${git_bin} format-patch -1 -o ../patches/rt/
Robert Nelson
committed
echo "RT: patch-${rt_patch}.patch.xz" > ../patches/git/RT
Robert Nelson
committed
exit 2
fi
Robert Nelson
committed
}
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
wireless_regdb () {
#https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./wireless-regdb ] ; then
${git_bin} clone git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git --depth=1
cd ./wireless-regdb
wireless_regdb_hash=$(git rev-parse HEAD)
cd -
else
rm -rf ./wireless-regdb || true
${git_bin} clone git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git --depth=1
cd ./wireless-regdb
wireless_regdb_hash=$(git rev-parse HEAD)
cd -
fi
cd ./KERNEL/
mkdir -p ./firmware/ || true
cp -v ../wireless-regdb/regulatory.db ./firmware/
cp -v ../wireless-regdb/regulatory.db.p7s ./firmware/
${git_bin} add -f ./firmware/regulatory.*
${git_bin} commit -a -m 'Add wireless-regdb regulatory database file' -m "https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/commit/?id=${wireless_regdb_hash}" -s
${git_bin} format-patch -1 -o ../patches/wireless_regdb/
echo "WIRELESS_REGDB: https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/commit/?id=${wireless_regdb_hash}" > ../patches/git/WIRELESS_REGDB
rm -rf ../wireless-regdb/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch"
wdir="wireless_regdb"
number=1
cleanup
fi
dir 'wireless_regdb'
}
#https://git.ti.com/gitweb?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=shortlog;h=refs/heads/ti-v4.1.y
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./ti-amx3-cm3-pm-firmware ] ; then
${git_bin} clone -b ti-v4.1.y git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
Robert Nelson
committed
cd ./ti-amx3-cm3-pm-firmware
ti_amx3_cm3_hash=$(git rev-parse HEAD)
cd -
${git_bin} clone -b ti-v4.1.y git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
Robert Nelson
committed
cd ./ti-amx3-cm3-pm-firmware
ti_amx3_cm3_hash=$(git rev-parse HEAD)
cd -
cp -v ../ti-amx3-cm3-pm-firmware/bin/am* ./firmware/
${git_bin} add -f ./firmware/am*
Robert Nelson
committed
${git_bin} commit -a -m 'Add AM335x CM3 Power Managment Firmware' -m "http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=commit;h=${ti_amx3_cm3_hash}" -s
Robert Nelson
committed
echo "TI_AMX3_CM3: http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=commit;h=${ti_amx3_cm3_hash}" > ../patches/git/TI_AMX3_CM3
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
rm -rf arch/arm/boot/dts/modules.order || true
rm -rf arch/arm/boot/dts/.*cmd || true
rm -rf arch/arm/boot/dts/.*tmp || true
rm -rf arch/arm/boot/dts/*dtb || true
}
dtb_makefile_append () {
sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device' \\:g' arch/arm/boot/dts/Makefile
}
beagleboard_dtbs () {
https_repo="https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees.git"
work_dir="BeagleBoard-DeviceTrees"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./${work_dir} ] ; then
${git_bin} clone -b ${branch} ${https_repo} --depth=1
cd ./${work_dir}
git_hash=$(git rev-parse HEAD)
Robert Nelson
committed
cd -
rm -rf ./${work_dir} || true
${git_bin} clone -b ${branch} ${https_repo} --depth=1
cd ./${work_dir}
git_hash=$(git rev-parse HEAD)
Robert Nelson
committed
cd -
cleanup_dts_builds
rm -rf arch/arm/boot/dts/overlays/ || true
mkdir -p arch/arm/boot/dts/overlays/
cp -vr ../${work_dir}/src/arm/* arch/arm/boot/dts/
cp -vr ../${work_dir}/include/dt-bindings/* ./include/dt-bindings/
device="am335x-bonegreen-gateway.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_bin} add -f arch/arm/boot/dts/
${git_bin} add -f include/dt-bindings/
${git_bin} commit -a -m "Add BeagleBoard.org Device Tree Changes" -m "https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/tree/${branch}" -m "https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/${git_hash}" -s
${git_bin} format-patch -1 -o ../patches/soc/ti/beagleboard_dtbs/
echo "BBDTBS: https://git.beagleboard.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/${git_hash}" > ../patches/git/BBDTBS
rm -rf ../${work_dir}/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/soc/ti/beagleboard_dtbs/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch"
wdir="soc/ti/beagleboard_dtbs"
number=1
cleanup
fi
dir 'soc/ti/beagleboard_dtbs'
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
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
rm -f arch/arm/boot/dts/overlays/*.dtbo || true
Robert Nelson
committed
${git_bin} add .
Robert Nelson
committed
${git_bin} commit -a -m "backports: ${subsystem}: from: linux.git" -m "Reference: ${backport_tag}" -s
Robert Nelson
committed
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 () {
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
cp -v ~/linux-src/drivers/uio/uio_pruss.c ./drivers/uio/
post_backports
exit 2
Robert Nelson
committed
}
reverts () {
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
start_cleanup
fi
Robert Nelson
committed
number=1
#https://github.com/raspberrypi/linux/branches
dir 'drivers/ti/gpio'
dir 'drivers/fb_ssd1306'
dir 'bootup_hacks'
Robert Nelson
committed
###
Robert Nelson
committed
drivers
Robert Nelson
committed
Robert Nelson
committed
packaging () {
#do_backport="enable"
if [ "x${do_backport}" = "xenable" ] ; then
subsystem="bindeb-pkg"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
cp -v ~/linux-src/scripts/package/* ./scripts/package/
post_backports
exit 2
else
patch_backports
fi
Robert Nelson
committed
fi
${git} "${DIR}/patches/backports/bindeb-pkg/0002-builddeb-Install-our-dtbs-under-boot-dtbs-version.patch"
Robert Nelson
committed
}
Robert Nelson
committed
echo "patch.sh ran successfully"