From: Kevin L. Mitchell Date: Thu, 21 Jun 2001 15:48:16 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=7027d90d598450fac166d842f8585aee880cfdc4 Author: Kev Log message: Add a shell script that can be used to prepare a new root by copying all necessary libraries to the appropriate places. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@509 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 71d4497..768b9c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-06-21 Kevin L. Mitchell + + * tools/mkchroot: shell-script to prepare the chroot area by + copying over all the necessary libraries so they can be found + 2001-06-20 Kevin L. Mitchell * INSTALL: partial update of INSTALL for u2.10.11 release... diff --git a/tools/mkchroot b/tools/mkchroot new file mode 100755 index 0000000..f7e2828 --- /dev/null +++ b/tools/mkchroot @@ -0,0 +1,99 @@ +#!/bin/sh +# +# IRC - Internet Relay Chat, tools/mkchroot +# Copyright (C) 2001 Kevin L. Mitchell +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id: mkchroot,v 1.1 2001-06-21 15:48:16 kev Exp $ + +if test $# -lt 2; then + echo "Usage: $0 [ [...]]" >&2 + exit 2 +fi + +destdir=$1 +shift + +# Use ldd to formulate a newline-separated list of libraries +liblist= +for arg +do + # Interpret ldd output + libs=`ldd $arg | sed -e 's/ / /g' -e 's/ */ /g' -e 's/^ //g' | \ + awk 'BEGIN { RS = " "; } { print; }' | grep '^/'` + + # add it to the list so far + if test x"$liblist" = x; then + liblist=$libs + else + liblist="$liblist +$libs" + fi +done +# Sort the list and remove duplicates +liblist=`echo "$liblist" | sort -u` + +# Now figure out all the subdirectories we're interested in +# Must create the top level, if need be +dirlist=/ +# Break down the library list into directories and remove duplicates +dirs=`echo "$liblist" | sed -e 's@/[^/]*$@@' | sort -u` +# Go through each directory to break it down into its components +for headdir in $dirs; do + tIFS=$IFS + IFS=/$IFS + # Start at the top level + dir= + for subdir in $headdir; do + # update dir so we know where we are + if test x"$dir" = x; then + dir=$subdir + else + dir=$dir/$subdir + fi + + # add (absolute) entry to directory list + dirlist="$dirlist +/$dir" + done + IFS=$tIFS +done +# Sort for ordering and remove duplicates +dirlist=`echo "$dirlist" | sort -u` + +# Create the directories +echo "Creating directories:" +for dir in $dirlist; do + # add destination directory name, remove trailing /, if any, for test + dir=`echo "$destdir$dir" | sed -e 's@//*$@@'` + echo " $dir" + # sanity-check directory... + if test -f "$dir" -o -h "$dir"; then + echo "ERROR: A non-directory \"$dir\" already exists; bailing out" >&2 + exit 2 + elif test ! -d "$dir"; then + # Create the directory world-readable + mkdir -m 755 $dir + fi +done + +# Now copy over the libraries +echo "Copying libraries:" +for lib in $liblist; do + echo " $lib -> $destdir$lib" + # Preserve permissions + cp -p $lib $destdir$lib +done