# vim: ft=zsh noet
if [[ $1 == info ]]; then
FSB_INFO_DEPEND=gentoo_buildpkg
FSB_INFO_BASE=%s
FSB_INFO_DIR=%s-genkernel
return
elif [[ $1 != build ]]; then
die "unimplemented action: $*"
fi
echo 'sys-kernel/genkernel' >>$build_dir/etc/portage/package.keywords/fsb_genkernel
echo 'app-misc/pax-utils' >>$build_dir/etc/portage/package.keywords/fsb_genkernel
echo 'sys-apps/util-linux static-libs' >>$build_dir/etc/portage/package.use/fsb_genkernel
fsb_chroot_bash emerge -n genkernel
sed --in-place=.orig -f $FSB_SCRIPTS_DIR/genkernel_conf.sed $build_dir/etc/genkernel.conf || \
die "failed to configure genkernel"
$build_dir/chroot.sh /bin/bash --login -c 'genkernel bzImage --no-mountboot --kernel-cc=/bin/false' && \
fsb_warn "genkernel reported success even when it should fail"
local conf
conf=$build_dir/usr/src/linux/.config
[[ -f $conf ]] || die "Kernel .config is not a plain file"
# ed -s $build_dir/usr/src/linux/.config <$FSB_SCRIPTS_DIR/kernel_conf.ed || die '.config ed script failed'
fsb_cond_ed $conf '^CONFIG_NF_NAT=[ym]' '$a
CONFIG_NF_NAT=m
CONFIG_NF_NAT_NEEDED=y
CONFIG_NF_NAT_PROTO_UDPLITE=m
CONFIG_NF_NAT_PROTO_SCTP=m
CONFIG_NF_NAT_AMANDA=m
CONFIG_NF_NAT_FTP=m
CONFIG_NF_NAT_IRC=m
CONFIG_NF_NAT_SIP=m
CONFIG_NF_NAT_TFTP=m
.'
fsb_cond_ed $conf '^CONFIG_NETFILTER_XT_NAT=[ym]' '$a
CONFIG_NETFILTER_XT_NAT=m
CONFIG_NETFILTER_XT_TARGET_NETMAP=m
CONFIG_NETFILTER_XT_TARGET_REDIRECT=m
.'
fsb_cond_ed $conf '^CONFIG_NF_NAT_IPV4=[ym]' '/^# CONFIG_NF_NAT_IPV4 is not set$/c
CONFIG_NF_NAT_IPV4=m
CONFIG_NF_NAT_MASQUERADE_IPV4=m
CONFIG_NF_NAT_PROTO_GRE=m
CONFIG_NF_NAT_PPTP=m
CONFIG_NF_NAT_H323=m
.'
fsb_cond_ed $conf '^CONFIG_IP_NF_NAT=[ym]' '/^# CONFIG_IP_NF_NAT is not set$/c
CONFIG_IP_NF_NAT=m
CONFIG_IP_NF_TARGET_MASQUERADE=m
CONFIG_IP_NF_TARGET_NETMAP=m
CONFIG_IP_NF_TARGET_REDIRECT=m
.'
fsb_cond_ed $conf '^CONFIG_DUMMY=m' '/^# CONFIG_DUMMY is not set$/c
CONFIG_DUMMY=m
.'
fsb_cond_ed $conf \! '^CONFIG_USB_XHCI_HCD=' '/^CONFIG_USB_XHCI_HCD=m$/c
# CONFIG_USB_XHCI_HCD is not set
.
/^CONFIG_USB_XHCI_PCI=m$/d
'
fsb_cond_ed $conf \! '^CONFIG_BUILD_DOCSRC' '/^CONFIG_BUILD_DOCSRC=/c
# CONFIG_BUILD_DOCSRC is not set
.'
fsb_cond_ed $conf '^CONFIG_F2FS_FS=[ym]' '/^# CONFIG_F2FS_FS is not set$/c
CONFIG_F2FS_FS=y
CONFIG_F2FS_STAT_FS=y
CONFIG_F2FS_FS_XATTR=y
CONFIG_F2FS_FS_POSIX_ACL=y
.'
fsb_chroot_bash genkernel --lvm --mdadm --e2fsprogs --disklabel \
--no-mountboot --symlink --real-root=/dev/mapper/vg-root \
all