1
1
Fork 0

Add precompile

Add kernbuild
This commit is contained in:
root 2020-09-29 22:50:16 +02:00
commit ecfc1992d3
4 changed files with 183 additions and 0 deletions

View File

@ -0,0 +1,13 @@
Based on idea/code from Sven Vermeulen of Gentoo.
Run in nightly crontab to update packages and precompile them to binary
ebuilds to save time on install.
To use them in emerge use parameter `-k`, e.g. like `emerge -DNvuak --with-bdeps=yes world`
Stuff that makes no sense is exluded like modules and virtual packages.
Requires
- bash
- logger

View File

@ -0,0 +1,58 @@
#!/bin/sh
# VERSION=2018-01-28.2
# TODO: Register failed packes to /var/eos/precompile.failed
# and skip on rerun
#
# script based on idea of
# sven vermeulen http://blog.siphos.be/2013/04/gentoo-protip-using-buildpkgonly/
echo "Start w/ eix-sync" | logger -t precompile
eix-sync -q
LIST=$(mktemp);
#emerge -puDN --with-bdeps=y --color=n --columns --quiet=y world | grep "^.*[a-z][a-z][a-z]-.*/[a-z0-9].*" | awk '{print $2}' > ${LIST};
# New: Skip already compiled packages, by excluding result starting with [binary
# New: Include --binpkg-respect-use=y, should be default in this case, but just to be sure.
# New: Set PORTAGE_ELOG_SYSTEM-env-var so we won't get per-package-mails from ebuild on systems having sending mails enabled in make.conf
PORTAGE_ELOG_SYSTEM="save" emerge -puDNk --with-bdeps=y --changed-deps=y --binpkg-respect-use=y --color=n --quiet=y world | grep "^\[ebuild " | sed -nr 's/^\[.+\]\ ([^\ ]+)(\ .*|$)/\1/p' > ${LIST};
for PACKAGE in $(cat ${LIST});
do
skip=0
if [ -f /etc/eos/precompile.exclude ]; then
for i in `cat /etc/eos/precompile.exclude | grep -v "^#"`; do
if [ "`echo ${PACKAGE} | grep "^${i}" | wc -l`" == "1" ]; then
skip=1
break;
fi
done
fi
if [ "$skip" == "1" ]; then
echo "Skipping ${PACKAGE} due to /etc/eos/precompile.exclude"
echo "Skipping ${PACKAGE} due to /etc/eos/precompile.exclude" | logger -t precompile
else
printf "Building binary package for ${PACKAGE}... "
emerge -1uN --quiet-build --quiet=y --changed-deps=y --buildpkgonly =${PACKAGE};
if [[ $? -eq 0 ]];
then
echo "ok";
echo "OK: ${PACKAGE} " | logger -t precompile
else
echo "failed";
echo "FAILED: ${PACKAGE} " | logger -t precompile
fi
fi
done
echo "Cleaning distfiles + packages" | logger -t precompile
eclean packages
eclean distfiles
rm $LIST
echo "Ending" | logger -t precompile

View File

@ -0,0 +1,22 @@
## kernbuild_w_zfs
Builds an prepares a kernel together with an initramfs.
Includes ZFS-modules. Also builds a shiftfs-module (for LXD, not for use with overlayfs!)
Requires:
- genkernel
- linux-source
Parameters:
- Suffix for your kernel e.g. turing1 (adds -turing1 to final kernel version instead of x86_64)
Howto:
- emerge gentoo-source
- check link /usr/src/linux to new source is OK
- make menuconfig
- Run script
- In boot check existances of new kernels
- Add to bootloader

View File

@ -0,0 +1,90 @@
#!/bin/sh
LOCALVERSION="-x86_64"
if [ "$1" != "" ]; then
LOCALVERSION="-eo${1}"
fi
echo "Going after kernel with localversion ${LOCALVERSION}"
sleep 2
PARAM="--no-clean --no-save-config --no-clean --mountboot \
--no-lvm \
--busybox \
--mdadm \
--no-iscsi \
--e2fsprogs \
--disklabel \
--hyperv \
--virtio \
--zfs \
--install \
--microcode \
--kernel-localversion=${LOCALVERSION}
"
genkernel $PARAM all || exit 1
emerge @module-rebuild || exit 1
genkernel $PARAM initramfs || exit 1
########### ShiftFS
echo "Now rebuilding shiftfs"
S=`dirname $0`
T="/usr/src/shiftfs"
mkdir -p $T
echo "LOCALVERSION=${LOCALVERSION}" > $T/Makefile
cat >>$T/Makefile <<'EOF'
modname := shiftfs
obj-m := $(modname).o
KVERSION := $(shell readlink /usr/src/linux | tr -d '/' | cut -b 7- )
KDIR := /lib/modules/$(KVERSION)$(LOCALVERSION)
PWD := "$$(pwd)"
ifdef DEBUG
CFLAGS_$(obj-m) := -DDEBUG
endif
EXTRA_CFLAGS := -DSHIFTFS_MAGIC=0x6a656a62
default:
$(MAKE) -C $(KDIR)/build M=$(PWD) EXTRA_CFLAGS="${EXTRA_CFLAGS}" modules
clean:
$(MAKE) O=$(PWD) -C $(KDIR)/build M=$(PWD) clean
load:
-rmmod $(modname)
insmod $(modname).ko
install:
install -m 0755 -o root -g root -d $(KDIR)/extra/fs
install -m 0755 -o root -g root $(modname).ko $(KDIR)/extra/fs/
depmod -a $(KVERSION)$(LOCALVERSION)
uninstall:
rm $(KDIR)/extra/fs/$(modname).ko
depmod -a $(KVERSION)$(LOCALVERSION)
EOF
#cp ${S}/Makefile.shiftfs $T/Makefile || exit 1
mv -f $T/shiftfs.c $T/shiftfs.c.bak 2> /dev/null
wget -O $T/shiftfs.c https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/fs/shiftfs.c
make -C $T clean && make -C $T && make -C $T install || exit 1
echo Complete with success