Re: Handling non-standard directories in tinybsd

From: Jean Milanez Melo <jmelo_at_freebsdbrasil.com.br>
Date: Sat, 28 Oct 2006 20:32:07 -0200
Jeremie Le Hen wrote:
> 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,
> 
> 

Hi Jeremie,

Your patch was good, but i've made some changes.

Here the patch. Take a look and tell me what do you think, if it's ok 
for you i'll ask Julian to commit.

Thanks.
Jean

Index: README
===================================================================
RCS file: /home/ncvs/src/tools/tools/tinybsd/README,v
retrieving revision 1.1
diff -u -r1.1 README
--- README	20 Sep 2006 22:24:17 -0000	1.1
+++ README	28 Oct 2006 23:22:41 -0000
_at__at_ -69,6 +69,10 _at__at_
 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 -r1.4 tinybsd
--- tinybsd	11 Oct 2006 21:46:53 -0000	1.4
+++ tinybsd	28 Oct 2006 23:22:41 -0000
_at__at_ -14,6 +14,8 _at__at_
 fi
 WORKDIR=/usr/obj/tinybsdbuild
 KERNCONF=TINYBSD
+BASEFILE="tinybsd.basefiles"
+LOCALFILE="tinybsd.localfiles"
 DEFINSTARGS="-o 0 -g 0 -m 555"
 TS="=====>"
 
_at__at_ -239,6 +241,10 _at__at_
 	fi
 }
 
+rotate_buidlog() {
+	mv -f ${HOME}/tinybsd.log ${HOME}/tinybsd.log.old
+}
+
 remove_workdir() {
 	chflags -R noschg ${WORKDIR}
 	echo "${TS} Removing "${WORKDIR}
_at__at_ -250,7 +256,7 _at__at_
 
 
 prework() {
-	remove_workdir	
+	remove_workdir
 	mkdir -p ${WORKDIR}
 }
 
_at__at_ -259,18 +265,18 _at__at_
 	echo "${TS} Creating directory hierarchy... "
 	mtree -deU -f /etc/mtree/BSD.root.dist -p ${WORKDIR}
 	mtree -deU -f /etc/mtree/BSD.usr.dist -p ${WORKDIR}/usr
+	mtree -deU -f /etc/mtree/BSD.local.dist -p ${WORKDIR}/usr/local
 	mtree -deU -f /etc/mtree/BSD.var.dist -p ${WORKDIR}/var
 }
 
-
 copy_binaries() {
-#set -xv
-	for file in `cat ${CURRENTDIR}/conf/${CONF}/tinybsd.basefiles | grep -v "#" | \
+	cd ${CURRENTDIR}/conf/${CONF}
+
+	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} ;
 	done
-#set +xv
 }
 
 make_kernel() {
_at__at_ -293,7 +299,7 _at__at_
 	TDEPFILES="`mktemp -t depsymlnk`"
 
 	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
 
_at__at_ -305,7 +311,7 _at__at_
 		echo $pamdep >> ${TDEPFILE} ;
 		ldd -f "%p\n" /${pamdep} >> ${TDEPFILE} ;
 	done	
-	
+
 	for lib in `cat ${TDEPFILE} | sort | uniq`; do
 		echo "${TS} Copying "${lib}" to "${WORKDIR}${lib}
 		cp -fp ${lib} ${WORKDIR}${lib} ;
_at__at_ -321,6 +327,7 _at__at_
                 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}"
_at__at_ -349,27 +356,29 _at__at_
 	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
+set -xv
+	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}
 	done
-#set +xv
+set +xv
 }
 
 
 create_image() {
-	#set -ex
-
 	VNODEFILE=`mktemp -t tinybsd`
 	IMGMNT=`mktemp -d -t tinybsd`
 
_at__at_ -448,6 +457,9 _at__at_
 loadconfig
 saveconfig
 
+# Rotate build log
+rotate_buidlog
+
 # Now start logging.
 (
   # Do the build
_at__at_ -460,7 +472,7 _at__at_
   symlinks
   create_etc
   create_ssh_keys
-  personal_directories
+  personal_conf
   create_image
 #set +xv
 ) 2>&1 |tee -a  ${HOME}/tinybsd.log
Index: conf/bridge/tinybsd.localfiles
===================================================================
RCS file: conf/bridge/tinybsd.localfiles
diff -N conf/bridge/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/bridge/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/default/tinybsd.localfiles
===================================================================
RCS file: conf/default/tinybsd.localfiles
diff -N conf/default/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/default/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/firewall/tinybsd.localfiles
===================================================================
RCS file: conf/firewall/tinybsd.localfiles
diff -N conf/firewall/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/firewall/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/minimal/tinybsd.localfiles
===================================================================
RCS file: conf/minimal/tinybsd.localfiles
diff -N conf/minimal/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/minimal/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/vpn/tinybsd.localfiles
===================================================================
RCS file: conf/vpn/tinybsd.localfiles
diff -N conf/vpn/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/vpn/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/wireless/tinybsd.localfiles
===================================================================
RCS file: conf/wireless/tinybsd.localfiles
diff -N conf/wireless/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/wireless/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Index: conf/wrap/tinybsd.localfiles
===================================================================
RCS file: conf/wrap/tinybsd.localfiles
diff -N conf/wrap/tinybsd.localfiles
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ conf/wrap/tinybsd.localfiles	28 Oct 2006 23:22:41 -0000
_at__at_ -0,0 +1,6 _at__at_
+# $FreeBSD$
+# Add here your third-party applications that are already installed on /usr/local
+# Make sure you have enough space to add it.
+# Example:
+# usr/local/sbin/httpd
+
Received on Sat Oct 28 2006 - 21:32:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:01 UTC