From owner-svn-src-head@FreeBSD.ORG Tue Mar 24 17:47:50 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 D13C61065837; Tue, 24 Mar 2009 17:47:50 +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 BCB788FC29; Tue, 24 Mar 2009 17:47:50 +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 n2OHloFq052541; Tue, 24 Mar 2009 17:47:50 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2OHloFV052540; Tue, 24 Mar 2009 17:47:50 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200903241747.n2OHloFV052540@svn.freebsd.org> From: Luigi Rizzo Date: Tue, 24 Mar 2009 17:47:50 +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: r190383 - 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: Tue, 24 Mar 2009 17:47:53 -0000 Author: luigi Date: Tue Mar 24 17:47:50 2009 New Revision: 190383 URL: http://svn.freebsd.org/changeset/base/190383 Log: add a function to help copying shared binaries from the output of a buildworld. Modified: head/release/picobsd/build/picobsd Modified: head/release/picobsd/build/picobsd ============================================================================== --- head/release/picobsd/build/picobsd Tue Mar 24 17:47:24 2009 (r190382) +++ head/release/picobsd/build/picobsd Tue Mar 24 17:47:50 2009 (r190383) @@ -548,6 +548,52 @@ do_copyfiles() { # rootdir varname done } +# find_progs is a helper function to locate the named programs +# or libraries in ${o_objdir} and return the full pathnames. +# Sets ${u_progs} to the list of programs, and ${u_libs} +# to the list of shared libraries used. +# If the first argument is - does not set u_libs +# +# You can use it e.g. in a local configuration file by writing +# +# do_copyfiles_user() { +# local dst=$1 +# find_progs nvi sed less grep +# cp -p ${u_progs} ${dst}/bin +# cp -p ${u_libs} ${dst}/lib +# mkdir -p ${dst}/libexec +# find_progs ld-elf.so.1 +# cp -p ${u_progs} ${dst}/libexec +# } + +find_progs() { # programs + local i + u_progs="`find_progs_helper $*`" + [ -z "${u_progs}" ] && return 1 # not found, error + i="`ldd ${u_progs} | grep -v '^/' | awk '{print $1}' | sort | uniq`" + u_libs="`find_progs_helper $i`" + return 0 +} + +find_progs_helper() { # programs + local progs="$*" + local i o places names + local subdirs="bin sbin usr.bin usr.sbin libexec lib \ + gnu/usr.bin gnu/lib \ + secure/usr.bin secure/usr.sbin secure/libexec secure/lib" + names="" # files to search + o="" + for i in $progs ; do + names="${names} ${o} -name $i" + o="-o" + done + places="" # places to search + for i in $subdirs ; do + places="${places} ${o_objdir}/${i}" + done + find ${places} -type f \( ${names} \) +} + # Populate the memory filesystem with binaries and non-variable # configuration files. # First do an mtree pass, then create directory links and device entries, @@ -863,7 +909,6 @@ fill_floppy_image() { # needs to be done once). set_build_parameters() { - log "set_build_parameters() SRC is ${SRC}" if [ "${SRC}" = "/usr/src" ] ; then l_usrtree=${USR:-/usr} else @@ -890,6 +935,19 @@ set_build_parameters() { CONFIG=${l_usrtree}/sbin/config export CONFIG fi + + # if we have o_objdir, find where bin/ is + if [ ! -z "${o_objdir}" ] ; then + if [ -d ${o_objdir}/bin ] ; then + # fine + elif [ -d "${o_objdir}${SRC}/bin" ] ; then + o_objdir="${o_objdir}${SRC}" + log "Changing objdir to ${o_objdir}" + else + log "Cannot find objdir in ${o_objdir}, sorry" + o_objdir="" + fi + fi } #------------------------------------------------------------------- @@ -898,9 +956,10 @@ set_build_parameters() { set_defaults while [ true ]; do + log "Parsing $1" case $1 in --src) # set the source path instead of /usr/src - SRC=`(cd $2; pwd)` + SRC=`realpath $2` shift ;; --init) @@ -952,6 +1011,12 @@ while [ true ]; do shift ;; + --objdir) # Place with results of a previous buildworld + # useful if you want to copy shared binaries and libs + o_objdir=`realpath $2` + shift + ;; + *) break ;;