]>
jfr.im git - irc/quakenet/snircd.git/blob - tools/mkchroot
3 # IRC - Internet Relay Chat, tools/mkchroot
4 # Copyright (C) 2001 Kevin L. Mitchell <klmitch@mit.edu>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 1, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # $Id: mkchroot,v 1.1 2001/06/21 15:48:16 kev Exp $
22 if test $# -lt 2; then
23 echo "Usage: $0 <destdir> <executable> [<executable> [...]]" >&2
30 # Use ldd to formulate a newline-separated list of libraries
34 # Interpret ldd output
35 libs
=`ldd $arg | sed -e 's/ / /g' -e 's/ */ /g' -e 's/^ //g' | \
36 awk 'BEGIN { RS = " "; } { print; }' | grep '^/'`
38 # add it to the list so far
39 if test x
"$liblist" = x
; then
46 # Sort the list and remove duplicates
47 liblist
=`echo "$liblist" | sort -u`
49 # Now figure out all the subdirectories we're interested in
50 # Must create the top level, if need be
52 # Break down the library list into directories and remove duplicates
53 dirs=`echo "$liblist" | sed -e 's@/[^/]*$@@' | sort -u`
54 # Go through each directory to break it down into its components
55 for headdir
in $dirs; do
58 # Start at the top level
60 for subdir
in $headdir; do
61 # update dir so we know where we are
62 if test x
"$dir" = x
; then
68 # add (absolute) entry to directory list
74 # Sort for ordering and remove duplicates
75 dirlist
=`echo "$dirlist" | sort -u`
77 # Create the directories
78 echo "Creating directories:"
79 for dir
in $dirlist; do
80 # add destination directory name, remove trailing /, if any, for test
81 dir
=`echo "$destdir$dir" | sed -e 's@//*$@@'`
83 # sanity-check directory...
84 if test -f "$dir" -o -h "$dir"; then
85 echo "ERROR: A non-directory \"$dir\" already exists; bailing out" >&2
87 elif test ! -d "$dir"; then
88 # Create the directory world-readable
93 # Now copy over the libraries
94 echo "Copying libraries:"
95 for lib
in $liblist; do
96 echo " $lib -> $destdir$lib"
97 # Preserve permissions
98 cp -p $lib $destdir$lib