Mariusz Pękala wrote:
> Additionally emerge unmerge leaves the remnants of compilation
> process, so you still have to do rm -r on the sources.
I've always liked to keep /usr as read-only as possible. I set a few
variables in /etc/make.conf that (I find) make everything a little more
maintainable:
------- from /etc/make.conf ----------
PORTAGE_TMPDIR="/var/portage"
DISTDIR="${PORTAGE_TMPDIR}/distfiles"
PKGDIR="${PORTAGE_TMPDIR}/portage-pkg"
DISTCC_DIR="${PORTAGE_TMPDIR}/distcc"
KBUILD_OUTPUT="${PORTAGE_TMPDIR}/kernel"
------------ end --------------
then I have a script that builds the kernel, setting the 'O' (oh, not
zero) parameter so that build output goes into the ${KBUILD_OUTPUT}
directory, and leaves /usr/src/<kernel version> pristine:
------- excerpt from makekernel script -----
sourceDir=/usr/src/linux
workDir=${KBUILD_OUTPUT}
binDir=/boot
target=kernel.<hostname>.<version>.<date>
(cd "${sourceDir}" && sudo -u portage make O="${workDir}" menuconfig)
(cd "${workDir}/include" && sudo -u portage lndir "${sourceDir}/include")
(cd "${sourceDir}" && sudo -u portage make O="${workDir}")
(cd "${sourceDir}" && make O="${workDir}" modules_install)
cp "${workDir}/arch/${arch}/boot/bzImage" "${binDir}/${target}"
-------------- end -----------
I've been using this script (full script inlined below) for more than a
year without problems. The lndir line is there to appease packages that
build kernel modules, and expect to find ${KBUILD_OUTPUT}/include
populated with header files. make is run as user 'portage' since some
packages like to run make O="${KBUILD_OUTPUT}" mrproper, so user portage
needs write access.
--myk
-------------- makekernel script ------------
#!/bin/sh
#
# makekernel
#
# written by Myk Taylor, 2004
# 'makekernel' without parameters will build and install the custom
kernel for
# the local machine (that is, it will use the config file named
<HOSTNAME>.config
# where HOSTNAME is the hostname of the local host in caps) For example,
# TUX.config would be the config file for host 'tux'.
# 'makekernel <CONF_ID>' will build and install only that specific
kernel, that is,
# it will used the file named <CONF_ID>.config
# 'makekernel all' will build and install all kernel confs in the current
# directory (a kernel conf is identified as a file with an all-caps
stem and a
# '.config' extension)
[ -f /etc/make.conf ] && source /etc/make.conf
# script parameters
sourceDir="/usr/src/linux"
workDir="${KBUILD_OUTPUT:-/tmp/kernel}"
binDir="/boot"
# get a list of config stems
configNames="$*"
# if 'all' is one of the config names, set configNames to be all the
# config files in the current directory
# elif no parameters specified, use local kernel config
if [ ! -z "`echo ${configNames} | grep -w 'all'`" ]; then
configNames=`ls | grep '^[A-Z0-9 _-]*\.config$' | sed
's/\.config//'`
elif [ -z "${configNames}" ]; then
configNames="`hostname | sed 's/\..*//' | tr a-z A-Z`"
fi
# do some sanity checking
versionFile="${sourceDir}/Makefile"
if [ ! -f "${versionFile}" ]; then
echo "${versionFile} not found"
exit 1
fi
if [ "`echo ${configNames} | grep '[^A-Z0-9 _-]'`" ]; then
echo "config file name stems should be in all caps"
exit 1
fi
echo "Making kernel(s): `echo -n ${configNames}`"
osvString="^VERSION = "
osplString="^PATCHLEVEL = "
osslString="^SUBLEVEL = "
osevString="^EXTRAVERSION = "
osv=`grep "${osvString}" "${versionFile}" | sed "s/${osvString}//"`
ospl=`grep "${osplString}" "${versionFile}" | sed "s/${osplString}//"`
ossl=`grep "${osslString}" "${versionFile}" | sed "s/${osslString}//"`
osev=`grep "${osevString}" "${versionFile}" | sed "s/${osevString}//"`
if [ ! -z "${osv}" -a ! -z "${ospl}" -a ! -z "${ossl}" -a ! -z "${osev}"
]; then
osr="${osv}.${ospl}.${ossl}${osev}"
else
osr="${osr:-'Unknown'}"
fi
kerPrefix="kernel."
dateStr="`date +%Y%m%d`"
kerSuffix=-"${osr}.${dateStr}"
for configName in ${configNames}; do
configFileName="${configName}.config"
# add more architectures as required
if [ ! -z "`grep '^CONFIG_X86_64=y' \"${configFileName}\"`" ]; then
arch="x86_64"
elif [ ! -z "`grep '^CONFIG_X86=y' \"${configFileName}\"`" ]; then
arch="i386"
else
echo "cannot determine target architecture in
${configFileName}"
echo "the script probably needs to be updated"
exit 1
fi
target="${kerPrefix}${configName}${kerSuffix}"
echo "==> building ${binDir}/${target} from ${configFileName}"
mkdir -p "${workDir}" && chown portage:portage "${workDir}"
cp "${configFileName}" "${workDir}/.config" && chown
portage:portage "${workDir}/.config" || exit 1
(cd "${sourceDir}" && sudo -u portage make O="${workDir}"
menuconfig) || exit 1
(cd "${workDir}/include" && sudo -u portage lndir
"${sourceDir}/include" > /dev/null) || exit 1
(cd "${sourceDir}" && sudo -u portage make O="${workDir}") ||
exit 1
(cd "${sourceDir}" && make O="${workDir}" modules_install) ||
exit 1
mkdir -p "${binDir}" || exit 1
cp "${workDir}/arch/${arch}/boot/bzImage" "${binDir}/${target}"
|| exit 1
(cd "${binDir}" && ln -fs "${target}"
"${kerPrefix}${configName}") || exit 1
done
echo; echo
moduleList="`cd /lib/modules && find . -path './*/kernel' -prune -o
-print | grep \.ko$ | sed 's|^\./[^/]*/||' | sort | uniq`"
outOfDateModules="`equery -q -C belongs -e ${moduleList} | grep -v '^\['`"
if [ -z "${outOfDateModules}" ]; then
echo "no modules need to be updated"
else
echo "don't forget to re-emerge packages that build kernel
modules:"
echo
echo -n "emerge --oneshot" && for pkg in ${outOfDateModules};
do echo -n " =$pkg"; done && echo
fi
------------------ end ------------------
--
gentoo-user@gentoo.org mailing list