* [gentoo-user] A pair of bash scripts to rebuild pkgs after a kernel upgrade.
@ 2016-01-15 17:16 Gregory Woodbury
0 siblings, 0 replies; only message in thread
From: Gregory Woodbury @ 2016-01-15 17:16 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]
After upgrading the gentoo-sources kernel or linux-headers, there are
some packages that are dependent on the kernel config or on specific
kernel modules. The ebuild "inherit" for eclasses will have the classes
linux-info or linux-mod referenced for these packages. These scripts do
the work of finding these references and rebuild/reinstall them after a
kernel or linux-headers upgrade.
I am attaching them to this email. They are fairly robust bash scripts
and they have comments and explanations in them. They should be
used after "eselect kernel set N" so the rebuilds get the correct sources
and .configs to look at. There are some status update displays since
they should be run from a text console or terminal window.
The "rebuild-kern-set" is the main script that checks the setup and
runs the emerge
The "make-kern-set" does the work of scanning the pkg db to make a set
based on the "inherit"s of the ebuilds. It scans the db directly for speed and
efficiency rather than digging into the ebuilds with standard tools.
Comments welcome. Enjoy.
--
G.Wolfe Woodbury
redwolfe@gmail.com
[-- Attachment #2: rebuild-kern-set --]
[-- Type: application/octet-stream, Size: 1316 bytes --]
#!/bin/bash
# Rebuild the kern-rebuild set of packages when a new kernel is in place
# 2014-10-30 ggw new, based on older "rebuild-for-kernel" script
# 2014-11-01 ggw modify to always rebuild the set, placed in /usr/local/sbin/
# 2014-11-25 ggw remove package set so normal updates can work properly
# 2015-05-17 ggw ask if the kernel links are set up correctly
#
# ask if the correct kernel is eselected before building
echo -n "Current kernel version running is "
echo `uname -r`
echo -n "Kernel build link is "
ls -l /usr/src/linux
echo "Is the new version properly setup ? (Hit [crtl-c] if not)"
echo -n "(hit enter/return to continue.)"
read junk
# always re-scan the installed package ebuilds for linux-info or linux-mod use
rm -f /etc/portage/sets/kern-rebuild #get rid of the old set
make-kern-set #rebuild the set
# display the packages found
echo "the packages found are:"
cat /etc/portage/sets/kern-rebuild
# confirm the set, ask for continue
echo "press enter to do the build: "
read junk
# rebuild the packages dependent on the kernel - force interaction
echo "emerging kern-rebuild set -- you will be asked to confirm the rebuilds"
emerge --ask --ask-enter-invalid --oneshot @kern-rebuild
# when done, remove the kern-set so normal updates can work
rm -f /etc/portage/sets/kern-rebuild
[-- Attachment #3: make-kern-set --]
[-- Type: application/octet-stream, Size: 2245 bytes --]
#!/bin/bash
#
# make-kern-set
# script to find installed packages that depend on linux-info or linux-mod eclass information
#
# 2014-10-30 ggw scan directly in /var/db/pkg for installed pkgs
# 2014-11-01 ggw placed in /usr/local/sbin for root access
# 2014-11-25 ggw use full name with versions for setlist
# 2015-12-19 ggw revert to package names without versions
#
KERN_REBUILD="/etc/portage/sets/kern-rebuild" #the name of the set to build
TMPNAME0=`mktemp --tmpdir` # a temporary file to use
declare -i nfound=0 # an integer variable
declare -i npkgs=0 # an integer variable
pushd /var/db/pkg >/dev/null # temporary chdir
# if interrupted/killed - remove temp file
save_traps=$(trap) # save current traps
trap 'rm -f $TMPNAME0; popd >/dev/null 2>&1; eval "$save_traps" ; exit 1' SIGINT
echo "Please wait -- scanning installed packages..."
find . -name '*INHERITED' -print | while read pkgname
do
# locate eclasses used by ebuild for installed pkgs
#debug: echo $pkgname
npkgs+=1 # count each pkg
grep -E -q -e 'linux-info|linux-mod' $pkgname
rc=$?
#check for kernel related ebuilds
if [ $rc -eq 0 ]
then
#cgname=`echo $pkgname | sed -e 's;^./;;' | sed -e 's;^\([^/]*\)/.*$;\1;'`
#pgname=`echo $pkgname | sed -e 's;^./;;' | sed -s 's;^[^/]*/\([^/]*\)/.*$;\1;'`
#set `qatom $pgname`
pkgname2=`echo "$pkgname" | sed -e 's;^./;;' | sed -e 's;/INHERITED$;;'`
set `qatom $pkgname2`
catg=$1 ; base=$2 ; version="$3 $4"
# echo "pkgname: $pkgname2 catg: $catg base: $base ver: $version"
# echo "=$cgname/$pgname" >>$TMPNAME0
echo "$catg/$base" >>$TMPNAME0
nfound+=1
fi
echo -n -e "$nfound / $npkgs kernel-dependent / installed pkgs found\r"
done
echo
# the popd isn't technically necessary -- unless we sourced this script
popd >/dev/null # go back to where we were
#debug: cat $TMPNAME0
#debug: read rc
#sort -u -o $KERN_REBUILD $TMPNAME0 # make list of packages
cp $TMPNAME0 $KERN_REBUILD # make list of packages with versioins
rm $TMPNAME0 # remove temp file
chmod +r $KERN_REBUILD # anyone may read it
eval "$save_traps" # restore interrupt condition to saved
unset save_traps TMPNAME0 KERN_REBUILD rc nfound npkgs
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-15 17:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-15 17:16 [gentoo-user] A pair of bash scripts to rebuild pkgs after a kernel upgrade Gregory Woodbury
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox