From owner-freebsd-small@FreeBSD.ORG Thu Oct 26 13:37:15 2006 Return-Path: X-Original-To: freebsd-small@FreeBSD.org Delivered-To: freebsd-small@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBFE216A412; Thu, 26 Oct 2006 13:37:15 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A58243D8F; Thu, 26 Oct 2006 13:36:57 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp5-g19.free.fr (Postfix) with ESMTP id 932FF27ABD; Thu, 26 Oct 2006 15:36:56 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id 22B199E6C5; Thu, 26 Oct 2006 13:37:42 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 17732405D; Thu, 26 Oct 2006 15:37:42 +0200 (CEST) Date: Thu, 26 Oct 2006 15:37:42 +0200 From: Jeremie Le Hen To: Jean Milanez Melo Message-ID: <20061026133742.GK20405@obiwan.tataz.chchile.org> References: <20061024100641.GB20405@obiwan.tataz.chchile.org> <453DE863.7070305@freebsdbrasil.com.br> <20061024115727.GD20405@obiwan.tataz.chchile.org> <453E1FBC.5060700@freebsdbrasil.com.br> <20061025104306.GI20405@obiwan.tataz.chchile.org> <453F5271.70309@freebsdbrasil.com.br> <20061026133637.GJ20405@obiwan.tataz.chchile.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MnLPg7ZWsaic7Fhd" Content-Disposition: inline In-Reply-To: <20061026133637.GJ20405@obiwan.tataz.chchile.org> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-small@FreeBSD.org, freebsd-current@FreeBSD.org, Julian Elischer Subject: Re: Handling non-standard directories in tinybsd X-BeenThere: freebsd-small@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2006 13:37:15 -0000 --MnLPg7ZWsaic7Fhd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline And the patch... On Thu, Oct 26, 2006 at 03:36:37PM +0200, Jeremie Le Hen wrote: > Hi Jean, > > On Wed, Oct 25, 2006 at 10:02:57AM -0200, Jean Milanez Melo wrote: > > >My feeling is that TinyBSD has used the KISS principle so far. The code > > >as well as the configuration is somewhat raw (no offence here), but it is > > >thereby easy to use, debug and modify at needs. I am going to code this > > >in my source tree this afternoon and I will be glad to provide you the > > >patch. > > > > That's right, make tinybsd simpler is really our idea :) > > > > Send to me your patch and i'll take a look. > > The patch is attached and works pretty well for me. > In addition to tinybsd.localfiles, I've made a few improvements: > - I've moved the configuration filenames in a variable ; > - When computing "sub-dependencies", use a temporary alternate file > and then merge it back to the main dependency file ; > - "chflags 0" files that are to be turned into symlinks before unlinking > them ; > - Handle /boot.config correctly in the configuration directory. > > Thank you. > Regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > --MnLPg7ZWsaic7Fhd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="tinybsd_localfiles.patch" Index: README =================================================================== RCS file: /home/ncvs/src/tools/tools/tinybsd/README,v retrieving revision 1.1 diff -u -p -r1.1 README --- README 20 Sep 2006 22:24:17 -0000 1.1 +++ README 26 Oct 2006 13:32:02 -0000 @@ -69,6 +69,10 @@ usr/sbin/pw usr/sbin/pwd_mkdb usr/sbin/setkey +tinybsd.localfiles: Similar to tinybsd.basefiles but for /usr/local/. The +difference is that directories will have to be created by TinyBSD because +they are not handle by mtree(1). + etc/: This is the directory where you can put your custom /etc configuration. # ls /usr/src/tools/tools/tinybsd/tinybsd Index: tinybsd =================================================================== RCS file: /home/ncvs/src/tools/tools/tinybsd/tinybsd,v retrieving revision 1.4 diff -u -p -r1.4 tinybsd --- tinybsd 11 Oct 2006 21:46:53 -0000 1.4 +++ tinybsd 26 Oct 2006 13:32:02 -0000 @@ -14,6 +14,8 @@ else fi WORKDIR=/usr/obj/tinybsdbuild KERNCONF=TINYBSD +BASEFILE="tinybsd.basefiles" +LOCALFILE="tinybsd.localfiles" DEFINSTARGS="-o 0 -g 0 -m 555" TS="=====>" @@ -262,10 +264,26 @@ create_tree() { mtree -deU -f /etc/mtree/BSD.var.dist -p ${WORKDIR}/var } +create_missingdirs() { + local LISTFILE DIR + LISTFILE=$1 + + for file in `cat $LISTFILE | grep -v "#" | cut -f1 -d":" | sort | uniq`; do + DIR=`dirname ${file}` + if [ ! -d ${WORKDIR}/${DIR} ]; then + echo "Non-standard directory created manually: ${DIR}." + mkdir -p ${WORKDIR}/${DIR} + fi + done +} + copy_binaries() { #set -xv - for file in `cat ${CURRENTDIR}/conf/${CONF}/tinybsd.basefiles | grep -v "#" | \ + cd ${CURRENTDIR}/conf/${CONF} + create_missingdirs ${LOCALFILE} + + for file in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | \ cut -f1 -d":" | sort | uniq` ; do echo "${TS} Copying "/${file}" to "${WORKDIR}/${file} cp -fp /${file} ${WORKDIR}/${file} ; @@ -289,24 +307,31 @@ make_kernel() { copy_libraries() { #set -xv - TDEPFILE="`mktemp -t deps`" - TDEPFILES="`mktemp -t depsymlnk`" + TDEPFILE="`mktemp -t deps.XXX`" + TDEPFILE2="`mktemp -t deps.XXX`" + TDEPFILES="`mktemp -t depsymlnk.XXX`" cd ${CURRENTDIR}/conf/${CONF} - for file in `cat tinybsd.basefiles | grep -v "#" | cut -f1 -d":"`; do + for file in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | cut -f1 -d":"`; do ldd -f "%p\n" /${file} >> ${TDEPFILE} ; # don't worry on progs been "not dynamic" done for libdeplib in `cat ${TDEPFILE} | sort | uniq`; do - ldd -f "%p\n" /${libdeplib} >> ${TDEPFILE} ; + ldd -f "%p\n" /${libdeplib} >> ${TDEPFILE2} ; done + cat ${TDEPFILE2} >> ${TDEPFILE} for pamdep in `ls -1 /usr/lib/pam*`; do echo $pamdep >> ${TDEPFILE} ; ldd -f "%p\n" /${pamdep} >> ${TDEPFILE} ; done + + cat ${TDEPFILE} | sort | uniq > ${TDEPFILE2} + mv -f ${TDEPFILE2} ${TDEPFILE} + + create_missingdirs ${TDEPFILE} - for lib in `cat ${TDEPFILE} | sort | uniq`; do + for lib in `cat ${TDEPFILE}`; do echo "${TS} Copying "${lib}" to "${WORKDIR}${lib} cp -fp ${lib} ${WORKDIR}${lib} ; done @@ -321,6 +346,7 @@ copy_libraries() { TARGET_FILE=`echo $i | awk -F ":" '{print $2}'` echo "${TS} Unlinking ${WORKDIR}${TARGET_FILE}" + chroot ${WORKDIR} /bin/chflags 0 ${TARGET_FILE} chroot ${WORKDIR} /bin/rm -f ${TARGET_FILE} echo "${TS} Symlinking ${SOURCE_FILE} to ${TARGET_FILE}" @@ -349,16 +375,20 @@ create_ssh_keys() { ssh-keygen -t rsa -f ${WORKDIR}/etc/ssh/ssh_host_rsa_key -N '' } -personal_directories() { +personal_conf() { echo "${TS} Copying your custom configuration on conf/ ..." - for custom in `find ${CURRENTDIR}/conf/${CONF}/ -type d -depth 1`; do + for custom in `find ${CURRENTDIR}/conf/${CONF}/ -type d -depth 1 \! -name CVS`; do cp -Rp ${custom}/* ${WORKDIR}/${custom#${CURRENTDIR}/conf/${CONF}/}/ done + + if [ -f ${CURRENTDIR}/conf/${CONF}/boot.config ]; then + cp ${CURRENTDIR}/conf/${CONF}/boot.config ${WORKDIR}/boot.config + fi } symlinks() { #set -xv - for i in `cat tinybsd.basefiles | grep -v "#" | grep ":"`; do + for i in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | grep ":"`; do SOURCE_FILE=`echo $i | awk -F ":" {'print $1'}` TARGET_FILE=`echo $i | awk -F ":" {'print $2'}` chroot ${WORKDIR} /bin/ln -vs /${SOURCE_FILE} ${TARGET_FILE} @@ -460,7 +502,7 @@ saveconfig symlinks create_etc create_ssh_keys - personal_directories + personal_conf create_image #set +xv ) 2>&1 |tee -a ${HOME}/tinybsd.log --MnLPg7ZWsaic7Fhd--