From owner-svn-src-head@FreeBSD.ORG Wed Mar 18 18:43:31 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B6F91065670; Wed, 18 Mar 2009 18:43:31 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B55A8FC0A; Wed, 18 Mar 2009 18:43:31 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2IIhVmV034405; Wed, 18 Mar 2009 18:43:31 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2IIhVmp034404; Wed, 18 Mar 2009 18:43:31 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200903181843.n2IIhVmp034404@svn.freebsd.org> From: Luigi Rizzo Date: Wed, 18 Mar 2009 18:43:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189978 - head/release/picobsd/build X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2009 18:43:32 -0000 Author: luigi Date: Wed Mar 18 18:43:31 2009 New Revision: 189978 URL: http://svn.freebsd.org/changeset/base/189978 Log: add the option to picobsd to copy files from the host filesystem without root privs. This is done, among other things, replacing the absolute paths in the symlinks with relative paths, so we do not need to do a chroot to follow them. Still need to update the manpage. MFC after: 3 days Modified: head/release/picobsd/build/picobsd Modified: head/release/picobsd/build/picobsd ============================================================================== --- head/release/picobsd/build/picobsd Wed Mar 18 18:42:58 2009 (r189977) +++ head/release/picobsd/build/picobsd Wed Mar 18 18:43:31 2009 (r189978) @@ -284,6 +284,9 @@ build_image() { if [ -f ${MY_TREE}/config ] ; then . ${MY_TREE}/config fi + if [ -f ${o_additional_config} ] ; then + . ${o_additional_config} + fi # location of the object directory PICO_OBJ=${l_objtree}/picobsd/${THETYPE} @@ -529,6 +532,32 @@ populate_floppy_fs() { # OK ) || true } +# Copy the specified files to the destination filesystem. +# Each file is specified as a pair "src dst", dst is assumed to be +# a directory (and created with mkdir -p) if it has a trailing / +# Be careful to escape metacharacters. +# You can use ${CROSS} to point to the root of the cross build +# (remember that it might be incomplete) + +do_copyfiles() { # rootdir varname + log Copy files to $1 + local root=$1 + local srcs dst + local CROSS=${_SHLIBDIRPREFIX} + eval set "\${${2}}" + srcs="" + for dst in $* ; do + [ x"$srcs" = x ] && srcs=$dst && continue + eval srcs="$srcs" # expand wildcard and vars + case x"$dst" in + */ ) mkdir -p ${root}/${dst} ;; + # * ) mkdir -p `dirname ${root}/${dst}` ;; + esac + cp -p ${srcs} ${root}/${dst} || true + srcs="" + done +} + # Populate the memory filesystem with binaries and non-variable # configuration files. # First do an mtree pass, then create directory links and device entries, @@ -537,7 +566,7 @@ populate_floppy_fs() { # OK # Finally, if required, make a copy of the floppy.tree onto /fd populate_mfs_tree() { - local a dst MFS_TREE + local i j a dst MFS_TREE log "populate_mfs_tree()" dst=${BUILDDIR}/mfs.tree @@ -552,12 +581,15 @@ populate_mfs_tree() { log "Running mtree using $a..." mtree -deU -f $a -p ${dst} > /dev/null || fail $? mtree - # XXX create links + # Create symlinks using relative pathnames, so it is possible + # to follow them also when building the image. + # Note that names in STAND_LINKS should not have a leading / for i in ${STAND_LINKS}; do - ln -s /stand ${dst}/$i + j=`echo $i | sed -E 's:^[^/]+::;s:/[^/]+:../:g'` + ln -s ${j}stand ${dst}/$i done - ln -s /dev/null ${dst}/var/run/log - ln -s /etc/termcap ${dst}/usr/share/misc/termcap + ln -s ../../dev/null ${dst}/var/run/log + ln -s ../../../etc/termcap ${dst}/usr/share/misc/termcap ### now build the crunched binaries ### ( @@ -629,6 +661,13 @@ populate_mfs_tree() { (cd ${dst}; chown -R root . ) fi + if [ -n "${copy_files}" ] ; then + do_copyfiles ${dst} copy_files + fi + + # The 'import_files' mechanism is deprecated, as it requires + # root permissions to follow the symlinks, and also does + # not let you rename the entries. if [ -n "${import_files}" ] ; then log "importing ${import_files} into mfs" # We do it in a chroot environment on the target so @@ -641,6 +680,7 @@ populate_mfs_tree() { rm -rf ${dst}/rescue fi + # final step -- build the mfs image (cd ${BUILDDIR} # override the owner echo "/set uid=0 gid=0" > mtree.out @@ -916,6 +956,11 @@ while [ true ]; do generate_iso="YES" ;; + --cfg) # read additional config from this file + o_additional_config=`realpath $2` + shift + ;; + *) break ;;