Date: Wed, 5 Dec 2012 21:05:00 +0000 (UTC) From: Mark Linimon <linimon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r243908 - projects/portbuild/pxedust Message-ID: <201212052105.qB5L50uB035553@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: linimon (doc,ports committer) Date: Wed Dec 5 21:05:00 2012 New Revision: 243908 URL: http://svnweb.freebsd.org/changeset/base/243908 Log: Scripts to aid in building PXEbootable images for portbuild client nodes. Added: projects/portbuild/pxedust/ projects/portbuild/pxedust/pxedust (contents, props changed) projects/portbuild/pxedust/pxepackages (contents, props changed) Added: projects/portbuild/pxedust/pxedust ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/portbuild/pxedust/pxedust Wed Dec 5 21:05:00 2012 (r243908) @@ -0,0 +1,170 @@ +#!/bin/sh +# +# script to generate a PXE-bootable image for package building nodes, complete +# with merged customization. MCL 20121123 +# +# note: must be run as root. +# + +# +# ------------- you should not need to do anything after this ------------- +# +# (at least, once the script is completed) + +if [ -z "${BRANCH}" \ + -o -z "${INSTALLDIR}" \ + -o -z "${PXEFILES}" \ + -o -z "${SITE}" \ + -o -z "${SRCDIR}" \ + -o -z "${TARGET}" ]; then + echo "$0: the following must all be set: BRANCH INSTALLDIR PXEFILES SITE SRCDIR TARGET" + echo "$0: you may optionally set: N_TASKS" + exit 1 +fi + +if [ -z ${N_TASKS} ]; then + N_TASKS=8 +fi + +DESTDIR="${INSTALLDIR}/${TARGET}-${BRANCH}" + +ARCH_PACKAGES="${PXEFILES}/ARCH_PACKAGES" +ARCH_SPECIFIC="${PXEFILES}/ARCH_SPECIFIC" +NODE_GENERIC="${PXEFILES}/NODE_GENERIC" +SITE_SPECIFIC="${PXEFILES}/SITE_SPECIFIC" + +TARGET_ARCH="${TARGET}" + +COMMON_ENV="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} DESTDIR=${DESTDIR}" + +KERNCONF="PACKAGE_NODE_${TARGET}" + +LOGFILE="diff.out" + +# using a src directory, populate a dst directory, or note differences +setup () { + srcdir=$1 + dstdir=$2 + logfile=$3 + + echo "setting up files in ${dstdir} ..." + + dirs=`cd ${srcdir} && find . -type d -print` + for dir in $dirs; do + echo "src dir is ${srcdir}/$dir" + if [ ! -d ${dstdir}/$dir ]; then + echo "create and populate dst dir ${dstdir}/$dir" + echo "(cd ${srcdir}/$dir; find -dx . | cpio -dump ${dstdir}/$dir)" + (cd ${srcdir}/$dir; find -dx . | cpio -dump ${dstdir}/$dir) + else + echo "dst dir ${dstdir}/$dir exists" + files=`cd ${srcdir}/$dir && find . -type f -maxdepth 1 -print` + for file in $files; do + echo "thinking about file ${srcdir}/$dir/$file" # XXX DEBUG + if [ -e ${dstdir}/$dir/$file ]; then + echo "cmp ${srcdir}/$dir/$file ${dstdir}/$dir/$file > /dev/null 2> /dev/null" # XXX DEBUG + cmp ${srcdir}/$dir/$file ${dstdir}/$dir/$file > /dev/null 2> /dev/null + if [ $? != 0 ]; then + echo "diff ${srcdir}/$dir/$file ${dstdir}/$dir/$file" >> ${logfile} + diff -ruN ${srcdir}/$dir/$file ${dstdir}/$dir/$file >> ${logfile} + echo >> ${logfile} + else + echo "same files: ${srcdir}/$dir/$file ${dstdir}/$dir/$file" + fi + else + echo "cp -p ${srcdir}/$dir/$file ${dstdir}/$dir/$file" + cp -p ${srcdir}/$dir/$file ${dstdir}/$dir/$file + fi + done + fi + done +} + +id=$(id -u) +if [ ${id} -ne 0 ]; then + echo "you need to run this script as root." + exit 1 +fi + +kernconfdir="${SRCDIR}/sys/${TARGET}/conf" +kernconf="${kernconfdir}/${KERNCONF}" +if [ ! -f ${kernconf} ]; then + standard_kernconfdir="${PXEFILES}/ARCH_SPECIFIC/${TARGET}/kernconf" + standard_kernconf="${standard_kernconfdir}/${KERNCONF}" + if [ ! -f ${standard_kernconf} ]; then + echo "missing standard kernel config file: ${standard_kernconf}" + exit 1 + else + cp -p ${standard_kernconf} ${kernconfdir}/ || exit 1 + fi +fi + +mkdir -p ${DESTDIR} + +cd ${SRCDIR} || exit 1 +echo "make ${COMMON_ENV} -j${N_TASKS} buildworld" +#make ${COMMON_ENV} -j${N_TASKS} buildworld || exit 1 +echo "make ${COMMON_ENV} buildkernel KERNCONF=${KERNCONF}" +#make ${COMMON_ENV} buildkernel KERNCONF=${KERNCONF} || exit 1 +echo "make ${COMMON_ENV} installkernel KERNCONF=${KERNCONF}" +#make ${COMMON_ENV} installkernel KERNCONF=${KERNCONF} || exit 1 +echo "make ${COMMON_ENV} installworld" +#make ${COMMON_ENV} installworld || exit 1 +echo "make ${COMMON_ENV} distribution" +#make ${COMMON_ENV} distribution || exit 1 +echo "make distribution: finished." +echo + +#mkdir -p ${DESTDIR}/usr2 || exit 1 +#mkdir -p ${DESTDIR}/usr3 || exit 1 + +cp /dev/null ${LOGFILE} + +# create a jail. needed for packages. +jname=${TARGET}-${BRANCH}-`basename $0` +jail -c persist name=${jname} ip4.addr=127.0.0.1 ip6=disable path=${DESTDIR} \ + host.hostname=${jname} +portsdir="/usr/ports" +packagedir="${portsdir}/packages/All" + +# copy over packages for that arch/branch. +# note the intentionally ommitted /. +setup ${ARCH_PACKAGES}/${TARGET}/${BRANCH} ${DESTDIR}${packagedir} ${LOGFILE} +echo + +# install the packages +jexec -U root ${jname} /bin/ls -al /usr/ports/packages/All +packages=`jexec -U root ${jname} /usr/bin/find ${packagedir} -type f -maxdepth 1` +for package in ${packages}; do + echo "adding ${package} in ${jname}" + # pre-pkgng + jexec -U root ${jname} /usr/sbin/pkg_add -f ${package} + # pkgng + # jexec -U root ${jname} /usr/sbin/pkg add ${package} +done +echo + +jail -r ${jname} + +# create files in conf/default/etc. Some will be overridden below. +#setup ${DESTDIR}/etc ${DESTDIR}/conf/default/etc ${LOGFILE} +echo + +# override (or create) files that are specific to an architecture +# (including overrides of package configs) +#setup ${ARCH_SPECIFIC}/${TARGET} ${DESTDIR} ${LOGFILE} +echo + +# override (or create) files that are generic to all nodes +#setup ${NODE_GENERIC} ${DESTDIR} ${LOGFILE} +echo + +# override (or create) files that are specific to a site +#setup ${SITE_SPECIFIC}/${SITE} ${DESTDIR} ${LOGFILE} +echo + +echo "finished." +echo " be sure to check ${LOGFILE} for things that have to be adjusted manually:" +ls -al ${LOGFILE} + +exit 0 Added: projects/portbuild/pxedust/pxepackages ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/portbuild/pxedust/pxepackages Wed Dec 5 21:05:00 2012 (r243908) @@ -0,0 +1,78 @@ +#!/bin/sh +# +# script to generate packages to be install in pxe-bootable images. +# MCL 20121123 +# +# note: must be run as root. +# + +REQUIRED_PORTS="ports-mgmt/pkg" +REQUIRED_PORTS="${REQUIRED_PORTS} net/rsync" +# dependencies for sudo. I'm getting tired of fighting tonight. +REQUIRED_PORTS="${REQUIRED_PORTS} devel/gettext" +REQUIRED_PORTS="${REQUIRED_PORTS} devel/libtool" +REQUIRED_PORTS="${REQUIRED_PORTS} converters/libiconv" +REQUIRED_PORTS="${REQUIRED_PORTS} security/sudo" +# XXX +#REQUIRED_PORTS="${REQUIRED_PORTS} XXX" + +# +# ------------- you should not need to do anything after this ------------- +# +# (at least, once the script is completed) + +if [ -z "${BRANCH}" \ + -o -z "${BUILDID}" \ + -o -z "${INSTALLDIR}" \ + -o -z "${PORTSDIR}" \ + -o -z "${PXEFILES}" \ + -o -z "${TARGET}" ]; then + echo "$0: the following must all be set: BRANCH BUILDID INSTALLDIR PORTSDIR PXEFILES TARGET" + exit 1 +fi + +DESTDIR="${INSTALLDIR}/${TARGET}-${BRANCH}" + +ARCH_PACKAGES="${PXEFILES}/ARCH_PACKAGES" + +id=$(id -u) +if [ ${id} -ne 0 ]; then + echo "you need to run this script as root." + exit 1 +fi + +# XXX MCL turn off due to 9.0R not having kickstart. ARGH! +#export WITH_PKGNG=yes + +WHERETO=${ARCH_PACKAGES}/${TARGET}/${BRANCH} + +mkdir -p ${WHERETO} || exit 1 +chown ports-${TARGET}:portmgr ${WHERETO} || exit 1 +cd ${WHERETO} || exit 1 + +# XXX MCL FRUSTRATED +export PORTSDIR="/var/portbuild/${ARCH}/${BRANCH}/builds/${BUILDID}/ports" + +# make the packages +for port in ${REQUIRED_PORTS}; do + pkgname=`cd ${PORTSDIR}/${port} && make -V PKGNAME` + pkg_sufx=`cd ${PORTSDIR}/${port} && make -V PKG_SUFX` + if [ -z "${pkgname}" ]; then + echo "could not figure out PKGNAME for $port!" + else + package="${WHERETO}/${pkgname}${pkg_sufx}" + if [ -e ${package} ]; then + echo "skipping ${package} since it already exists" + else + echo "making ${package}" + dir=`cd ${PORTSDIR}/${port} && make -V PACKAGES` + mkdir -p ${dir} + cd ${PORTSDIR}/${port} && make -DFORCE_PKG_REGISTER package + fi + fi +done + +echo "copying `ls -l ${PORTSDIR}/packages/All/`" +cp -p ${PORTSDIR}/packages/All/* ${WHERETO} || exit 1 + +exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212052105.qB5L50uB035553>