4 # This file requires sysutils/makefs to run
6 # The new PicoBSD build script. Invoked as
8 # picobsd [options] floppy_type site_name
10 # Where floppy_type is a directory where the picobsd config info
11 # is held, and ${floppy_type}/floppy.tree.${site_name} contains
12 # optional site-specific configuration.
14 # For Options, see the bottom of the file where the processing is
15 # done. The picobsd(8) manpage might be of some help, but code and docs
16 # tend to lose sync over time...
18 # This script depends on the following files:
21 # Makefile.conf Makefile used to build the kernel
22 # config shell variables, sourced here.
23 # mfs.mtree mtree config file
25 # floppy.tree/ files which go on the floppy
26 # mfs_tree/ files which go onto the mfs
29 # PICOBSD kernel config file
30 # config shell variables, sourced here.
31 # crunch.conf crunchgen configuration
32 # floppy.tree.exclude files from floppy.tree/ which we do not need here.
33 # floppy.tree/ local additions to the floppy.tree
34 # floppy.tree.${site}/ same as above, site specific.
35 # mfs_tree/ local additions to the mfs_free
38 #--- The main entry point is at the end.
41 # There are two set of initialization. The first one (set_defaults)
42 # is done on entry to the script, and is used to set default values
43 # for all variables which do not depend on floppy type and source tree.
45 # The second set is done after command line parsing, e.g.
46 # to resolve dependencies on the source tree.
49 # + variables that control operation (e.g. verbosity) and are generally
50 # set from the command line have o_ ("option") as a name prefix
52 # + variables which contain pathnames and values that should not change
53 # have c_ ("constant") as a name prefix
55 # + variables exported to Makefiles and subshells are CAPITAL
57 # + variables local to the script are lowercase, possibly with
58 # an l_ ("local") prefix
60 # SRC points to your FreeBSD source tree.
61 # l_usrtree points to the /usr subdir for the source tree.
62 # Normally /usr or ${SRC}/../usr
63 # l_objtree points to the obj tree. Normally ${l_usrtree}/obj-pico
64 # PICO_TREE is where standard picobsd stuff resides.
65 # Normally ${SRC}/release/picobsd
66 # You can set SRC with --src <directory>
67 # It is not recommended to override the other variables.
69 # MY_TREE (set later) is where this floppy type resides.
70 # BUILDDIR is the build directory
72 # set some default values for variables.
73 # needs to be done as the first thing in the script.
75 # log something on stdout if verbose.
76 o_verbose=0 # this needs to be here!
78 if [ ${o_verbose} -gt 0 ] ; then
79 printf "\n*** %s\n" "$*"
80 if [ ${o_verbose} -gt 1 ] ; then
81 read -p "=== Press enter to continue" foo
89 printf "\n*** %s\n" "$*"
90 read -p "=== Press enter to continue" foo
94 # no way to use logging in this function, variable not set yet.
96 # EDITOR is the editor you use
97 # fd_size floppy size in KB (default to 1440). You can use 1480,
98 # 1720, 2880, etc. but beware that only 1440 and 1480 will boot
99 # from 1.44M floppy drives (1480 will not work on vmware).
101 fd_size=${fd_size:-1440}
103 o_all_in_mfs="yes" # put all files in mfs so you can boot and run
104 # the image via diskless boot.
105 o_clean="" # do not clean
106 o_interactive="" # default is interactive
107 o_verbose=0 # verbose level, 0 is silent
108 o_tarv="" # tar verbose flag, "" or "v"
109 o_init_src="" # non "" if we need to init libs and includes.
110 o_makeopts=${MAKEOPTS:--s} # make options, be silent by default
111 o_no_devfs=yes # we do not want devfs
112 o_do_modules="" # do not build modules
114 SRC="/usr/src" # default location for sources
115 c_startdir=`pwd` # directory where we start
116 # used to lookup config and create BUILDDIR
118 # XXX 6.x/7.x have a single /boot/boot block, which is the concatenation
119 # of the old two. For the time being, we keep these, but this should
120 # be fixed at some point.
123 c_boot1=/boot/boot1 # boot blocks (in case you want custom ones)
126 c_reply=${c_reply:-`mktemp "/tmp/reply.XXXXXXXXXX"`}
127 # file where User replies will be put
128 c_mnt=`mktemp -d "/tmp/picobsd.XXXXXXXXXX"`
129 # mountpoint used to build memory filesystems
130 c_fs=fs.PICOBSD # filename used for the memory filesystem
131 c_img=picobsd.bin # filename used for the picobsd image
133 # select the right memory disk name
151 create_includes_and_libraries2() {
153 log "create_includes_and_libraries2() for ${SRC}"
154 if [ ${OSVERSION} -ge 600000 ] ; then
155 no="-DNO_CLEAN -DNO_PROFILE -DNO_GAMES -DNO_LIBC_R"
157 no="-DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R"
159 MAKEOBJDIRPREFIX=${l_objtree}
160 export MAKEOBJDIRPREFIX
162 # make -DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R -DPICOBSD buildworld
163 make _+_= $no toolchain
167 create_includes_and_libraries() {
170 log "create_includes_and_libraries() for ${SRC}"
171 # Optionally creates include directory and libraries.
172 mkdir -p ${l_usrtree}/include # the include directory...
173 mkdir -p ${l_usrtree}/share/misc # a few things go here
174 mkdir -p ${l_usrtree}/lib # libraries
175 mkdir -p ${l_usrtree}/sbin # some binaries
176 # override variables for ownershiip and destinations
177 # BINOWN:BINGRP are also used for include files
179 BINOWN=`id -un` BINGRP=`id -gn` \
180 DESTDIR=${l_usrtree}/.. \
181 make -m ${SRC}/share/mk includes ) || fail $? includes
182 # Pick up the correct headers for libraries.
183 CFLAGS="-nostdinc -I${l_usrtree}/include" ; export CFLAGS
186 # $e is the invocation of make with correct environment
187 # XXX check the NO* options below, maybe system dependent.
188 e="MAKEOBJDIRPREFIX=${l_objtree}/picobsd/libraries \
189 BINOWN=`id -un` BINGRP=`id -gn` \
190 DESTDIR=${l_usrtree}/.. \
191 make -m ${SRC}/share/mk \
192 -DNOHTML -DNOINFO -DNOMAN -DNOSHARE -DNOFSCHG "
193 log "do a 'make obj' in a few places."
194 # This is very version-specific... The following works for 5.0
195 for i in lib secure/lib gnu/lib \
196 gnu/usr.bin/perl usr.bin/lex usr.sbin/config ; do
197 (cd ${i}; eval $e obj)
199 log "now make the static libraries"
200 eval $e -DNOPROFILE -DNOPIC libraries
201 (cd ${SRC}/usr.sbin/config
202 eval $e # build binary
203 eval $e install # install it
205 ) || fail $? "libraries"
209 # set_type <type> looks in user or system directories for the floppy type
210 # specified as first argument, and sets variables according to the config.
211 # file. Also sets MY_TREE and BUILDDIR and SITE
220 for i in ${c_startdir}/${a} ${PICO_TREE}/${a} ; do
221 log "set_type: checking $i"
222 if [ -d $i -a -f $i/PICOBSD -a -f $i/crunch.conf ] ; then
223 set -- `cat $i/PICOBSD | \
224 awk '/^#PicoBSD/ {print $2, $3, $4, $5, $6}'`
225 if [ "$1" != "" ]; then
226 MFS_SIZE=$1 ; init_name=$2
227 mfs_inodes=$3 ; fd_inodes=$4
228 name=`(cd $i ; pwd) `
229 name=`basename $name`
231 BUILDDIR=${c_startdir}/build_dir-${name}
232 log "Matching file $name in $i"
237 echo "Type $a NOT FOUND"
242 if [ "${name}" = "" ] ; then
243 echo "---> Wrong floppy type"
249 # prepare a message to be printed in the dialog menus.
253 MSG1="Type: ${THETYPE} name $name"
255 MSG="PicoBSD build -- Current parameters:\n\n\t1. ${MSG1}\n\
256 \t2. MFS size: ${MFS_SIZE} kB\n\
257 \t3. Site-info: ${SITE}\n\t4. Full-path: ${MY_TREE}\n"
261 # Main build procedure.
263 log "build_image() <${name}>"
264 [ "${name}" != "" ] || fail $? bad_type
267 printf "${MSG}---> We'll use the sources living in ${SRC}\n\n"
269 # read config variables from a global and then a type-specific file
270 # basically STAND_LINKS and MY_DEVS, but can also override other
273 . ${PICO_TREE}/build/config
274 if [ -f ${MY_TREE}/config ] ; then
278 # location of the object directory
279 PICO_OBJ=${l_objtree}/picobsd/${THETYPE}
280 log "PICO_OBJ is ${PICO_OBJ}"
282 if [ ${OSVERSION} -ge 500035 ] ; then
283 MAKEOBJDIRPREFIX=${l_objtree}
284 export MAKEOBJDIRPREFIX
285 log `cd ${SRC}; make -f Makefile.inc1 -V WMAKEENV`
286 eval export `cd ${SRC}; make -f Makefile.inc1 -V WMAKEENV`
288 # create build directory and subtree
289 mkdir -p ${BUILDDIR}/crunch
290 # remove any old stuff
291 rm -f ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
292 # invoke commands to build a kernel
294 # fill a subdirectory with things that go into the floppy
295 # (mostly /etc and similar stuff)
297 # populate it and produce a file with the MFS image
298 populate_mfs_tree # things which go into mfs
299 # create, mount and fill a filesystem with floppy image
300 fill_floppy_image # copies everything into the floppy
306 log "build_package()"
308 echo "##############################################" >>build.status
309 echo "## `date` ">>build.status
310 echo "##############################################" >>build.status
311 for z in bridge dial router net isp ; do
313 echo "---------------------------------------------">>build.status
314 echo "Building TYPE=${z}, SIZE=${MFS_SIZE}" >>build.status
315 msg="(ok)" # error message
316 build_image || msg="** FAILED! **"
317 echo " ${msg}">>build.status
318 # where do i put things ?
324 # Set build parameters interactively
333 dialog --menu "PicoBSD build menu -- (29 sep 2001)" 19 70 12 \
334 N "--> READY, build it <---" \
336 K "edit Kernel config file" \
337 E "Edit crunch.conf file" \
338 S "MFS Size: ${MFS_SIZE}kB" \
339 I "Init type: ${init_name}" \
340 F "Floppy size: ${fd_size}kB" \
341 M "MFS bytes per inode: ${mfs_inodes}" \
342 U "UFS bytes per inode: ${fd_inodes}" \
343 $ "Site-info: ${SITE}" \
351 for i in ${c_startdir} ${c_startdir}/* ${PICO_TREE}/* ; do
352 if [ -d $i -a -f $i/PICOBSD -a -f $i/crunch.conf ]; then
353 l="$l `basename $i` `basename $i`"
357 { dialog --menu "Setup the type of configuration" 12 70 5 $l \
358 2> ${c_reply} && set_type "`cat ${c_reply}`" ${SITE} ; } || true
361 { dialog --menu "Choose your init(8) program" \
362 10 70 2 init "Standard init (requires getty)" \
363 oinit "small init from TinyWare" 2> ${c_reply} \
364 && init_name=`cat ${c_reply}` ; } || true
367 K) ${EDITOR} ${MY_TREE}/PICOBSD ;;
369 E) ${EDITOR} ${MY_TREE}/crunch.conf ;;
372 { dialog --title "MFS Size setup" --inputbox \
373 "MFS size depends on what you need to put on the MFS image. Typically \
374 ranges between 820kB (for very small bridge/router images) to \
375 as much as 2500kB kB for a densely packed image. \
376 Keep in mind that this memory is \
377 totally lost to other programs. Usually you want to keep \
378 this as small as possible. " 10 70 2> ${c_reply} \
379 && MFS_SIZE=`cat ${c_reply}` ; } || true
383 { dialog --title "Site info setup" --inputbox \
384 "Please enter the full path to the directory \
385 containing site-specific setup. \
386 This directory tree must contain files that replace \
387 standard ones in floppy.tree/ and mfs.tree/ . " \
388 10 70 2> ${c_reply} && SITE=`cat ${c_reply}` ; } || true
392 { dialog --menu "Set floppy size" 15 70 4 \
393 1440 "1.44MB" 1720 "1.72MB" 2880 "2.88MB" 4096 "4MB" \
394 2> ${c_reply} && fd_size=`cat ${c_reply}` ; } || true
398 { dialog --title "MFS bytes per inode:" --inputbox \
399 "Enter MFS bytes per inode (typically 4096..65536). \
400 A larger value means fewer inodes but more space on MFS" \
401 10 70 2> ${c_reply} && mfs_inodes=`cat ${c_reply}` ; } || true
405 { dialog --title "Floppy bytes per inode:" --inputbox \
406 "Enter floppy bytes per inode (typically 3072..65536). \
407 A larger value means fewer inodes but more space on the floppy." \
408 10 70 2> ${c_reply} && fd_inodes=`cat ${c_reply}` ; } || true
416 *) echo "
\aUnknown option \"${ans}\". Try again."
424 # Call the build procedure
429 if [ "${o_interactive}" = "NO" ] ; then
430 echo "+++ Build completed +++"
431 cat .build.reply || true
434 dialog --title "Build ${THETYPE} completed" --inputbox \
435 "\nThe build process was completed successfuly.\n\
436 `cat .build.reply` \n\n\
437 Now we are going to install the image on the floppy.\n\
438 Please insert a blank floppy in /dev/fd0.\\n
439 WARNING: the contents of the floppy will be permanently erased!\n\
442 * ^C or [Cancel] to abort,\n\
443 * Enter to install ${c_img},\n\
444 " 20 80 2> ${c_reply}
445 if [ "$?" = "0" ]; then
446 echo "Writing ${c_img}..."
447 dd if=${BUILDDIR}/${c_img} of=/dev/fd0.${fd_size}
449 echo "Ok, the image is in ${c_img}"
455 #-------------------------------------------------------------------
457 # invoke the Makefile to compile the kernel.
459 log "do_kernel() Preparing kernel \"$name\" in $MY_TREE"
460 (cd $MY_TREE; export name SRC BUILDDIR # used in this makefile ;
462 if [ "${o_do_modules}" = "yes" ] ; then
466 make -m ${SRC}/share/mk -v -f ${PICO_TREE}/build/Makefile.conf ) || \
467 fail $? missing_kernel
470 # Populate the variable part of the floppy filesystem. Must be done before
471 # the MFS because its content might need to be copied there as well.
473 # This involves fetching files from three subtrees, in this order:
475 # 1. a standard one, from which type-specific files are excluded;
476 # 2. a type-specific one;
477 # 3. a site-specific one.
479 # Files are first copied to a local tree and then compressed.
481 populate_floppy_fs() { # OK
482 local dst excl srcdir
484 log "populate_floppy_fs()"
485 dst=${BUILDDIR}/floppy.tree
486 log "pwd=`pwd` Populating floppy filesystem..."
488 # clean relics from old compilations.
489 rm -rf ${dst} || true
492 excl=${MY_TREE}/floppy.tree.exclude
493 if [ -f ${excl} ] ; then
494 excl="--exclude-from ${excl}"
495 log "Files excluded from generic tree: `echo;cat ${excl}`"
499 (cd ${PICO_TREE}/floppy.tree ; tar -cf - --exclude CVS ${excl} . ) | \
500 (cd ${dst} ; tar x${o_tarv}f - )
501 log "Copied from generic floppy-tree `echo; ls -laR ${dst}`"
503 srcdir=${MY_TREE}/floppy.tree
504 if [ -d ${srcdir} ] ; then
505 log "update with type-specific files:"
506 (cd ${srcdir} ; tar -cf - --exclude CVS . ) | \
507 (cd ${dst} ; tar x${o_tarv}f - )
508 log "Copied from type floppy-tree `echo; ls -laR ${dst}`"
510 log "No type-specific floppy-tree"
512 if [ -d ${srcdir}.${SITE} ] ; then
513 log "Update with site-specific (${SITE}) files:"
514 (cd ${srcdir}.${SITE} ; tar -cf - --exclude CVS . ) | \
515 (cd ${dst} ; tar x${o_tarv}f - )
516 log "Copied from site floppy-tree `echo; ls -laR ${dst}`"
518 log "No site-specific floppy-tree"
521 # gzip returns an error if it fails to compress some file
522 (cd $dst ; gzip -9 etc/*
523 log "Compressed files in etc/ `echo; ls -l etc`"
527 # Populate the memory filesystem with binaries and non-variable
528 # configuration files.
529 # First do an mtree pass, then create directory links and device entries,
530 # then run crunchgen etc. to build the binary and create links.
531 # Then copy the specific/generic mfs_tree.
532 # Finally, if required, make a copy of the floppy.tree onto /fd
534 populate_mfs_tree() {
537 log "populate_mfs_tree()"
538 dst=${BUILDDIR}/mfs.tree
539 # clean relics from old compilations.
540 rm -rf ${dst} || true
543 log "pwd=`pwd`, Populating MFS tree..."
545 # use type-specific mfs.mtree, default to generic one.
546 a=${MY_TREE}/mfs.mtree
547 [ -f ${a} ] || a=${PICO_TREE}/build/mfs.mtree
548 log "Running mtree using $a..."
549 mtree -deU -f $a -p ${dst} > /dev/null || fail $? mtree
552 for i in ${STAND_LINKS}; do
553 ln -s /stand ${dst}/$i
555 ln -s /dev/null ${dst}/var/run/log
556 ln -s /etc/termcap ${dst}/usr/share/misc/termcap
560 cd ${BUILDDIR}/crunch
561 log "Making and installing crunch1 from `pwd` src ${SRC}..."
562 a=${BUILDDIR}/crunch1.conf
563 ( export BUILDDIR SRC MY_TREE PICO_OBJ ;
564 make -m ${SRC}/share/mk \
565 -v -f ${PICO_TREE}/build/Makefile.conf ${BUILDDIR}/crunch.mk )
566 log "Libs are ${LIBS} "
567 export SRC # used by crunch.mk
569 log "Now make -f crunch.mk"
570 make -m ${SRC}/share/mk ${o_makeopts} -f ${BUILDDIR}/crunch.mk
571 strip --remove-section=.note --remove-section=.comment crunch1
572 mv crunch1 ${dst}/stand/crunch
573 chmod 555 ${dst}/stand/crunch
574 log "Making links for binaries..."
575 for i in `crunchgen -l $a` ; do
576 ln ${dst}/stand/crunch ${dst}/stand/${i};
578 # rm $a # do not remove!
581 if [ -f ${dst}/stand/sshd ] ; then
582 log "Setting up host key for sshd:"
583 if [ -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key.gz ] ; then
584 log "Using existing host key"
586 log "Generating new host key"
587 ssh-keygen -t rsa1 -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key \
588 -N "" -C "root@picobsd"
589 gzip -9 ${BUILDDIR}/floppy.tree/etc/ssh_host_key* || true
593 log "Copy generic and site-specific MFS tree..."
594 for MFS_TREE in ${PICO_TREE}/mfs_tree ${MY_TREE}/mfs_tree ; do
595 if [ -d ${MFS_TREE} ] ; then
596 log "Copy ${MFS_TREE} ..."
597 (cd ${MFS_TREE} ; tar -cf - --exclude CVS . ) | \
598 (cd ${dst} ; tar x${o_tarv}f - )
602 if [ "${o_all_in_mfs}" = "yes" ]; then
603 log "Copy generic floppy_tree into MFS..."
604 # this may fail in case the floppy is empty
605 cp -Rp ${BUILDDIR}/floppy.tree/* ${dst}/fd || true
608 if [ "${o_no_devfs}" != "" ] ; then
609 # create device entries using MAKEDEV
611 ln -s ${SRC}/etc/MAKEDEV ; chmod 555 MAKEDEV
613 sh ./MAKEDEV ${MY_DEVS}
617 if [ "`id -u`" = "0" ] ; then
618 log "Fixing permissions"
619 (cd ${dst}; chown -R root . )
622 if [ -n "${import_files}" ] ; then
623 log "importing ${import_files} into mfs"
624 # We do it in a chroot environment on the target so
625 # symlinks are followed correctly.
626 cp `which tar` ${dst}/my_copy_of_tar
627 (cd ${l_usrtree}/.. ; tar cf - ${import_files} ) | \
628 (chroot ${dst} /my_copy_of_tar xf - )
629 rm ${dst}/my_copy_of_tar
634 echo "/set uid=0 gid=0" > mtree.out
635 mtree -c -p ${dst} -k "" >> mtree.out
636 log "mtre.out at ${BUILDDIR}/mtree.out"
637 makefs -t ffs -o bsize=4096 -o fsize=512 \
638 -s ${MFS_SIZE}k -f 100 -F mtree.out ${c_fs} ${dst}
644 log "final_cleanup()"
645 rm -rf ${c_mnt} ${c_reply} 2> /dev/null || true
650 # This function is used to trap errors and print msgs
653 local errno errocode where
658 echo "---> fail: Error <${errno}> error code <${errcode}> in <${where}>"
661 echo "Error while making hierarchy in ${c_mnt}"
664 echo "Error while building ${name}."
667 echo "Error: you must build PICOBSD${suffix} kernel first"
670 echo "Error: failed while making includes"
673 echo "Error: failed while making libraries"
676 echo "Error: unknown floppy type ${name}"
679 echo "Error: no space left on device (${where})"
682 echo "Error: while writing MFS into the kernel."
689 echo "unknown error, maybe user break: $errno $errcode"
692 echo "---> Aborting $0"
693 # try to cleanup the vnode.
698 fill_floppy_image() {
699 local blocks dst mfs_start mfs_end mfs_size img_size
701 log "fill_floppy_image()"
702 dst=${c_mnt} # where to create the image
704 log "Preparing ${fd_size}kB floppy filesystem..."
706 # correct blocks according to size.
708 if [ "${blocks}" = "1720" ]; then
710 elif [ "${blocks}" = "1480" ]; then
714 log "Labeling floppy image"
715 log "patch ${c_boot2} to boot /kernel right away"
716 b2=${BUILDDIR}/boot2 # modified boot2
717 cp -f ${c_boot2} ${b2}
720 set `strings -at d ${b2} | grep "/boot/loader"`
721 echo -e "/kernel\0\0\0\0\0" | \
722 dd of=${b2} obs=$1 oseek=1 conv=notrunc 2>/dev/null
725 dst=${BUILDDIR}/image.tree
730 set 0 0 # reset variables
731 # $1 takes the offset of the MFS filesystem
732 set `strings -at d kernel | grep "MFS Filesystem goes here"`
734 set 0 0 # reset variables
735 set `strings -at d kernel | grep "MFS Filesystem had better"`
737 mfs_size="$((${mfs_end} - ${mfs_start}))"
738 set -- `ls -l ${c_fs}`; imgsize="$5"
739 if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then
740 mfs_ofs=$((${mfs_start} + 8192))
741 log "Preload kernel with file ${c_fs} at ${mfs_ofs}"
742 dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \
743 oseek=1 conv=notrunc 2> /dev/null
745 log "not loading mfs, size ${mfs_size} img ${imgsize}"
747 log "Compress with kgzip and copy to floppy image"
748 kgzip -o kernel.gz kernel
749 cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel"
751 log "Now transfer floppy tree if not already in MFS image"
752 # now transfer the floppy tree. If it is already in mfs, dont bother.
753 if [ "${o_all_in_mfs}" != "yes" ] ; then
754 cp -Rp floppy.tree/* ${dst} || \
755 fail $? no_space "copying floppy tree"
759 makefs -t ffs -o bsize=4096 -o fsize=512 \
760 -s ${blocks}k -f 50 ${c_img} ${dst}
761 # ${l_label} -f `pwd`/${c_img}
762 ${l_label} -w -f `pwd`/${c_img} auto # write in a label
763 # copy partition c: into a: with some sed magic
764 ${l_label} -f `pwd`/${c_img} | sed -e '/ c:/{p;s/c:/a:/;}' | \
765 ${l_label} -R -f `pwd`/${c_img} /dev/stdin
766 ${l_label} -f `pwd`/${c_img}
768 logverbose "after disklabel"
770 # dump the primary and secondary boot
771 # XXX primary is 512 bytes
772 dd if=${c_boot1} of=${BUILDDIR}/${c_img} conv=notrunc 2>/dev/null
773 # XXX secondary starts after the 0x114 = dec 276 bytes of the label
774 # so we skip 276 from the source, and 276+512=788 from dst
775 # the old style blocks used 512 and 1024 respectively
777 dd if=${b2} iseek=1 ibs=276 2> /dev/null | \
778 dd of=${BUILDDIR}/${c_img} oseek=1 obs=788 conv=notrunc 2>/dev/null
779 logverbose "done floppy image"
780 # XXX (log "Fixing permissions"; cd ${dst}; chown -R root *)
781 rm -rf ${BUILDDIR}/floppy.tree || true # cleanup
782 # df -ik ${dst} | colrm 70 > .build.reply
784 rm ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
787 # This function creates variables which depend on the source tree in use:
788 # SRC, l_usrtree, l_objtree
789 # Optionally creates libraries, includes and the like (for cross compiles,
790 # needs to be done once).
792 set_build_parameters() {
793 log "set_build_parameters() SRC is ${SRC}"
794 if [ "${SRC}" = "/usr/src" ] ; then
795 l_usrtree=${USR:-/usr}
797 l_usrtree=${USR:-${SRC}/../usr}
799 l_objtree=${l_usrtree}/obj-pico
800 PICO_TREE=${PICO_TREE:-${SRC}/release/picobsd}
801 set `grep "#define[\t ]__FreeBSD_version" ${SRC}/sys/sys/param.h`
803 log "OSVERSION is ${OSVERSION}"
804 if [ "${o_init_src}" != "" ] ; then
805 if [ ${OSVERSION} -lt 500035 ] ; then
806 create_includes_and_libraries
808 create_includes_and_libraries2
811 if [ ${OSVERSION} -lt 500035 ] ; then
812 # Create the right LIBS and CFLAGS for further builds.
813 # and build the config program
814 LIBS="-L${l_usrtree}/lib"
815 CFLAGS="-nostdinc -I${l_usrtree}/include"
817 CONFIG=${l_usrtree}/sbin/config
822 #-------------------------------------------------------------------
823 # Main entry of the script. Initialize variables, parse command line
829 --src) # set the source path instead of /usr/src
850 --modules) # also build kernel modules
857 -clear|-clean|-c) # clean
862 -v) # need -v -v to wait for user input
863 o_verbose=$((${o_verbose}+1)) # verbose level
864 o_tarv="v" # tar verbose flag
865 o_makeopts="-d l" # be verbose
874 set_build_parameters # things that depend on ${SRC}
875 set_type $1 $2 # type and site, respectively
877 # If $1="package", it creates a neat set of floppies
879 if [ "$1" = "package" ] ; then
882 if [ "${o_interactive}" != "NO" ] ; then
885 if [ "${o_clean}" = "YES" ] ; then