2013-07-13 17:19:22 +01:00
|
|
|
version=\
|
|
|
|
(
|
2017-06-02 14:43:34 +01:00
|
|
|
'4.4.66'
|
2013-07-13 17:19:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
url=\
|
|
|
|
(
|
2017-06-02 14:43:34 +01:00
|
|
|
"https://www.kernel.org/pub/linux/kernel/v4.x/linux-$version.tar.xz"
|
2013-07-13 17:19:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
md5=\
|
|
|
|
(
|
2017-06-02 14:43:34 +01:00
|
|
|
'5353de56bf4621a35afc4384c7e51f30'
|
2013-07-13 17:19:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
maintainer=\
|
|
|
|
(
|
|
|
|
'Ricardo Martins <rasm@fe.up.pt>'
|
|
|
|
)
|
|
|
|
|
|
|
|
requires=\
|
|
|
|
(
|
2014-06-11 19:33:27 +01:00
|
|
|
'bc/host'
|
2013-07-13 17:19:22 +01:00
|
|
|
'kmod/host'
|
2014-01-21 00:37:37 +00:00
|
|
|
'lz4/host'
|
2013-07-13 17:19:22 +01:00
|
|
|
)
|
2014-08-19 18:26:49 +01:00
|
|
|
|
2016-05-17 19:08:51 +01:00
|
|
|
# This variable is updated by find_patches().
|
|
|
|
patches=()
|
|
|
|
|
2016-03-24 15:26:00 +00:00
|
|
|
# Major/Minor version.
|
|
|
|
linux_mm_version()
|
|
|
|
{
|
|
|
|
echo "$version" | cut -f1-2 -d.
|
|
|
|
}
|
|
|
|
|
|
|
|
# Major/Minor/Patch version.
|
|
|
|
linux_mmp_version()
|
|
|
|
{
|
|
|
|
echo "$version" | cut -f1 -d-
|
|
|
|
}
|
|
|
|
|
2016-05-17 19:08:51 +01:00
|
|
|
find_patches()
|
|
|
|
{
|
|
|
|
patches=(\
|
|
|
|
$(ls -1 \
|
|
|
|
"$pkg_dir/patches/$version/"*.patch \
|
|
|
|
"$pkg_dir/patches/$(linux_mmp_version)/"*.patch \
|
|
|
|
"$pkg_dir/patches/$(linux_mm_version)/"*.patch \
|
|
|
|
"$cfg_dir_system/patches/linux/$version/"*.patch \
|
|
|
|
"$cfg_dir_system/patches/linux/$(linux_mmp_version)/"*.patch \
|
|
|
|
"$cfg_dir_system/patches/linux/$(linux_mm_version)/"*.patch \
|
|
|
|
2> /dev/null | awk '!a[$0]++')
|
|
|
|
)
|
|
|
|
}
|
2016-03-24 15:26:00 +00:00
|
|
|
|
2016-05-17 19:08:51 +01:00
|
|
|
find_patches
|
2016-03-24 15:26:00 +00:00
|
|
|
|
|
|
|
# Get configuration file.
|
|
|
|
linux_cfg_file()
|
|
|
|
{
|
|
|
|
for f in "$version" "$(linux_mmp_version)" "$(linux_mm_version)"; do
|
|
|
|
f="$cfg_dir_system/cfg/linux-$f.cfg"
|
|
|
|
if [ -f "$f" ]; then
|
|
|
|
echo "$f"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Candidate kernel configuration file '$f' doesn't exist." 1>&2
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "ERROR: failed to find a valid kernel configuration file." 1>&2
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2014-08-19 18:26:49 +01:00
|
|
|
post_unpack()
|
|
|
|
{
|
2016-03-24 15:26:00 +00:00
|
|
|
n=0; while [ -n "${patches[$n]}" ]; do
|
|
|
|
patch="${patches[$n]}"
|
|
|
|
echo "* Applying $patch..."
|
|
|
|
(ucat "$patch" | patch -p1) || return 1
|
|
|
|
let n++
|
|
|
|
done
|
2014-08-19 18:26:49 +01:00
|
|
|
|
|
|
|
if [ -d "$cfg_dir_toolchain/firmware" ]; then
|
|
|
|
tar -C "$cfg_dir_toolchain/firmware" -c -v -f - . | tar -C firmware -x -v -f -
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh()
|
|
|
|
{
|
|
|
|
for rule in configure build target_install; do
|
2016-03-24 15:26:00 +00:00
|
|
|
if [ "$(linux_cfg_file)" -nt "$cfg_dir_builds/linux/$pkg_var/.$rule" ]; then
|
2014-08-19 18:26:49 +01:00
|
|
|
rm "$cfg_dir_builds/linux/$pkg_var/.$rule"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
configure()
|
|
|
|
{
|
|
|
|
$cmd_make \
|
|
|
|
ARCH=${cfg_target_linux} \
|
2016-03-24 15:26:00 +00:00
|
|
|
mrproper || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
|
2016-03-24 15:26:00 +00:00
|
|
|
cfg="$(linux_cfg_file)"
|
|
|
|
[ -n "$cfg" ] || return 1
|
|
|
|
$cmd_cp "$cfg" .config || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
|
2015-06-29 17:23:00 +01:00
|
|
|
if [ -f "$cfg_dir_system/files/initramfs_init.sh" ]; then
|
2015-02-08 18:41:17 +00:00
|
|
|
$cmd_mkdir initramfs &&
|
|
|
|
$cmd_cp "$pkg_dir/files/initramfs.conf" . &&
|
|
|
|
$cmd_cp "$cfg_dir_system/files/initramfs_init.sh" initramfs/init.sh &&
|
|
|
|
$cmd_cp "$cfg_dir_rootfs/bin/busybox" initramfs/busybox
|
|
|
|
fi
|
|
|
|
|
2014-08-19 18:26:49 +01:00
|
|
|
yes '' | $cmd_make \
|
|
|
|
CROSS_COMPILE=${cfg_target_canonical}- \
|
|
|
|
ARCH=${cfg_target_linux} \
|
|
|
|
oldconfig
|
|
|
|
}
|
|
|
|
|
|
|
|
build()
|
|
|
|
{
|
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE=$cfg_target_canonical- \
|
2016-04-06 15:59:33 +01:00
|
|
|
ARCH=$cfg_target_linux || return 1
|
|
|
|
|
2014-08-19 18:26:49 +01:00
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE=$cfg_target_canonical- \
|
|
|
|
ARCH=$cfg_target_linux \
|
2016-04-06 15:59:33 +01:00
|
|
|
modules || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
|
|
|
|
if [ "$(basename $cfg_target_linux_kernel)" = 'uImage' ]; then
|
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE=$cfg_target_canonical- \
|
|
|
|
ARCH=$cfg_target_linux \
|
2016-04-06 15:59:33 +01:00
|
|
|
uImage || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Compressed image.
|
|
|
|
if [ "$(basename $cfg_target_linux_kernel)" = 'zImage' ]; then
|
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE=$cfg_target_canonical- \
|
|
|
|
ARCH=$cfg_target_linux \
|
2016-04-06 15:59:33 +01:00
|
|
|
zImage || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Device tree blob.
|
|
|
|
if [ -n "$cfg_target_linux_dtb" ]; then
|
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE=$cfg_target_canonical- \
|
|
|
|
ARCH=$cfg_target_linux \
|
2016-04-06 15:59:33 +01:00
|
|
|
dtbs || return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${cfg_target_linux_size}" ]; then
|
|
|
|
dd if="$cfg_target_linux_kernel" of="${cfg_target_linux_kernel}.padded" \
|
|
|
|
ibs="${cfg_target_linux_size}" conv=sync &&
|
|
|
|
mv "${cfg_target_linux_kernel}.padded" "${cfg_target_linux_kernel}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
target_install()
|
|
|
|
{
|
|
|
|
if [ -n "$(file "$cfg_target_linux_kernel" | grep ELF)" ]; then
|
|
|
|
strip="$(echo $cfg_dir_toolchain/bin/*-strip)"
|
|
|
|
$strip -s -R .comment "$cfg_target_linux_kernel"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Kernel image.
|
|
|
|
if [ -n "$cfg_target_linux_kernel" ]; then
|
|
|
|
cp -v "$cfg_target_linux_kernel" "$cfg_dir_rootfs/boot/kernel"
|
2015-12-17 13:52:44 +00:00
|
|
|
else
|
|
|
|
echo "ERROR: failed to find kernel image at '$cfg_target_linux_kernel'"
|
|
|
|
return 1
|
2014-08-19 18:26:49 +01:00
|
|
|
fi
|
|
|
|
|
2016-05-18 12:44:52 +01:00
|
|
|
# Device tree blobs.
|
|
|
|
dts="arch/$cfg_target_linux/boot/dts"
|
|
|
|
if [ -d "$dts" ]; then
|
|
|
|
$cmd_mkdir "$cfg_dir_rootfs/boot" &&
|
|
|
|
cp -v "$dts/"*.dtb "$cfg_dir_rootfs/boot"
|
|
|
|
fi
|
|
|
|
|
2016-05-17 19:08:51 +01:00
|
|
|
# Device tree overlays.
|
|
|
|
overlays_dir="arch/$cfg_target_linux/boot/dts/overlays"
|
|
|
|
if [ -d "$overlays_dir" ]; then
|
|
|
|
$cmd_mkdir "$cfg_dir_rootfs/boot/overlays" || return 1
|
|
|
|
$cmd_cp "$overlays_dir"/*.dtbo "$cfg_dir_rootfs/boot/overlays" || return 1
|
|
|
|
fi
|
|
|
|
|
2014-08-19 18:26:49 +01:00
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE="$cfg_target_canonical-" \
|
|
|
|
ARCH="$cfg_target_linux" \
|
|
|
|
INSTALL_MOD_PATH="$cfg_dir_rootfs/usr" \
|
2016-06-14 19:30:56 +01:00
|
|
|
KBUILD_VERBOSE=1 \
|
2014-08-19 18:26:49 +01:00
|
|
|
modules_install
|
|
|
|
|
2018-12-12 14:28:41 +00:00
|
|
|
echo $cfg_sys_family
|
|
|
|
if [[ $cfg_sys_family == *rpi* ]]; then
|
|
|
|
echo "RPI family, no need of firmware_install"
|
|
|
|
sleep 2
|
|
|
|
else
|
|
|
|
sleep 2
|
|
|
|
$cmd_make \
|
|
|
|
CROSS_COMPILE="$cfg_target_canonical-" \
|
|
|
|
ARCH="$cfg_target_linux" \
|
|
|
|
INSTALL_MOD_PATH="$cfg_dir_rootfs/usr" \
|
|
|
|
KBUILD_VERBOSE=1 \
|
|
|
|
DEPMOD="$cfg_dir_toolchain/sbin/depmod" \
|
|
|
|
firmware_install
|
|
|
|
fi
|
2014-08-19 18:26:49 +01:00
|
|
|
}
|