Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## `genkernel all` wrapper
- ## altracer1337@gmail.com
- #ARCH=x86_64
- KV=4.19.57
- #FLAV=gentoo
- #VERSTR="genkernel-${ARCH}-${KV}-${FLAV}"
- # Storage dir
- STORE="/home/altracer/linux-${KV}-genkernel-all"
- #STORE="$HOME/linux-${KV}-genkernel-all"
- emerge_sources(){
- # Get the sources and unpack them, possibly using a tbz2
- # Might not actually be required here especially since that's the only step with root permissions
- sudo emerge -v =sys-kernel/gentoo-sources-${KV}
- }
- genkernel_all(){
- # Build a generic Linux kernel with default Gentoo configuration non-interactively
- # TODO: record the CPU time and RAM taken via `time -v`
- # /usr/bin/time -v genkernel --install kernel initramfs
- sudo genkernel all
- }
- copy_installed(){
- mv -v "$STORE" "$STORE-$(date -Iminutes)"
- # Create a package of the results
- # TODO: package artifacts from /usr/src/linux-${KV} without depending on `sudo genkernel --install`
- env XZ_OPT="-T0" tar -cJvf \
- $STORE/linux-modules-${KV}-gentoo-genkernel-all.tar.xz \
- ./lib/modules/${KV}-gentoo
- cp -v \ #config?
- /boot/kernel-genkernel-x86_64-${KV}-gentoo \
- /boot/initramfs-genkernel-x86_64-${KV}-gentoo \
- /boot/System.map-genkernel-x86_64-${KV}-gentoo \
- $STORE/
- }
- copy_usrsrc(){
- TMPDIR=/tmp/linux-modules-${KV}-genkernel-all
- mv -v "$STORE" "$STORE-$(date -Iminutes)"
- mkdir -p $TMPDIR
- cd /usr/src/linux-${KV} || exit 1
- env INSTALL_MOD_PATH=$TMPDIR make modules_install
- env XZ_OPT="-T0" tar -cJvf \
- $STORE/linux-modules-${KV}-gentoo-genkernel-all.tar.xz \
- -C $TMPDIR ./lib/modules/${KV}-gentoo
- cp -v arch/x86/boot/bzImage $STORE/kernel-genkernel-x86_64-${KV}-gentoo
- cp -v System.map $STORE/System.map-genkernel-x86_64-${KV}-gentoo
- cp -v /var/tmp/genkernel/initramfs-${KV}-gentoo $STORE/initramfs-genkernel-x86_64-${KV}-gentoo
- }
- concat_package(){
- tar cvf $STORE/../linux-${KV}-genkernel-all.tar $STORE/linux-${KV}-genkernel-all
- 7z a -tzip -mx=0 $STORE/../linux-${KV}-genkernel-all.zip $STORE/linux-${KV}-genkernel-all
- }
- doroot(){
- emerge_sources
- genkernel_all_root
- copy_installed
- concat_package
- }
- douser(){
- # emerge_sources && chown -R users:portage /usr/src/linux-${KV}
- genkernel_all_user
- copy_usrsrc
- concat_package
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement