summaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2009-12-28 00:51:00 +0000
committerluigi <luigi@FreeBSD.org>2009-12-28 00:51:00 +0000
commitf46d0fc3edd2481e1770d2cb28396d5585508eea (patch)
treeb0557fc1620ad7cb85be775a87cace6131acba45 /release
parent062dad0f33e6104af9f6dd4414e39c1c2cf9e594 (diff)
downloadFreeBSD-src-f46d0fc3edd2481e1770d2cb28396d5585508eea.zip
FreeBSD-src-f46d0fc3edd2481e1770d2cb28396d5585508eea.tar.gz
more support to import files and libraries from the host.
Diffstat (limited to 'release')
-rwxr-xr-xrelease/picobsd/build/picobsd58
1 files changed, 42 insertions, 16 deletions
diff --git a/release/picobsd/build/picobsd b/release/picobsd/build/picobsd
index 02a4206..f635c1e 100755
--- a/release/picobsd/build/picobsd
+++ b/release/picobsd/build/picobsd
@@ -568,10 +568,17 @@ do_links() { # rootdir varname
# find_progs is a helper function to locate the named programs
# or libraries in ${o_objdir} or ${_SHLIBDIRPREFIX},
# and return the full pathnames.
-# Sets ${u_progs} to the list of programs, and ${u_libs}
+# Called as "find_progs [-L libpath] [-P binpath] prog1 prog2 ... "
+# On return it sets ${u_progs} to the list of programs, and ${u_libs}
# to the list of shared libraries used.
+#
+# '-L path' can be used to specify a search path for libraries
+# (which searches in $path/lib:$path/usr/lib:$path/usr/local/lib
+# '-P binpath' can be used to specify a search path for programs
+# (which searches in a lot of places in the subtree)
+# -L must be the first, followed by -P
#
-# You can use it e.g. in a local configuration file by writing
+# You can use it e.g. in a local confign file by writing
#
# do_copyfiles_user() {
# local dst=$1
@@ -580,41 +587,60 @@ do_links() { # rootdir varname
# cp -p ${u_libs} ${dst}/lib
# mkdir -p ${dst}/libexec
# find_progs ld-elf.so.1
-# cp -p ${u_progs} ${dst}/libexec
+# cp -p ${u_progs} ${dst}/libexec # ignore errors
# }
find_progs() { # programs
local i
+ local oo=${o_objdir:-${_SHLIBDIRPREFIX}} # default objdir
+ local lp=$oo/lib # default lib.prefix
+ local o="" # additional objdir
+ if [ x"$1" = "x-L" -a -d "$2" ] ; then # set lib search path
+ o=$2; shift; shift
+ lp="$lp:$o/lib:$o/usr/lib:$o/usr/local/lib"
+ o="-P $o"
+ fi
u_progs="`find_progs_helper $*`"
- local o=${o_objdir:-${_SHLIBDIRPREFIX}}
- log "looking for libs for $u_progs in $_SHLIBDIRPREFIX"
+ log "looking for libs for <$u_progs> in $lp"
[ -z "${u_progs}" ] && return 1 # not found, error
- i="`LD_LIBRARY_PATH=$o/lib ldd ${u_progs} | grep -v '^/' | awk '{print $1}' | sort | uniq`"
- u_libs="`find_progs_helper $i`"
+ i="`( LD_LIBRARY_PATH=$lp ldd ${u_progs} ) | \
+ grep -v '^/' | awk '{print $1}' | sort | uniq`"
+ u_libs="`find_progs_helper $o $i`"
return 0
}
find_progs_helper() { # programs
+ local dir=${o_objdir:-${_SHLIBDIRPREFIX}/..}
+ local ldir=""
+ if [ x"$1" = "x-P" -a -d "$2" ] ; then # set path
+ ldir=$2; shift; shift
+ fi
local progs="$*"
- local i o places names
- local subdirs="bin sbin usr.bin usr.sbin libexec lib \
+ local subdirs=". local/bin local/sbin local/lib local/libexec \
+ 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=""
+ local names="" # files to search
+ local o=""
+ local i
for i in $progs ; do
- # plain programs come out verbatim
+ # full pathnames are just listed
[ -f "$i" ] && echo $i && continue
names="${names} ${o} -name $i"
o="-o"
done
[ -z "${names}" ] && return 0
- places="" # places to search
- o=${o_objdir:-${_SHLIBDIRPREFIX}/..}
+ local places="" # places to search
for i in $subdirs ; do
- [ -d "${o}/${i}" ] && places="${places} ${o}/${i}"
+ [ -d "${dir}/${i}" ] && places="${places} ${dir}/${i}"
done
- find ${places} -type f \( ${names} \)
+ if [ -n "${ldir}" ] ; then
+ for i in $subdirs ; do
+ [ -d "${ldir}/${i}" ] && places="${places} ${ldir}/${i}"
+ done
+ fi
+ # use maxdepth 3 because some libs are way down
+ find ${places} -maxdepth 3 -type f \( ${names} \)
}
# Populate the memory filesystem with binaries and non-variable
OpenPOWER on IntegriCloud