[PC-BSD Commits] r4145 - pbibuild/pbibuilder/pbicreator/PBIfiles
svn at pcbsd.org
svn at pcbsd.org
Thu Jun 25 12:40:17 PDT 2009
Author: kris
Date: 2009-06-25 12:40:16 -0700 (Thu, 25 Jun 2009)
New Revision: 4145
Modified:
pbibuild/pbibuilder/pbicreator/PBIfiles/copylibs.sh
Log:
Large update of the copylibs.sh script, which auto-populates the library files for a PBI.
Fixes some bugs, but also now preserves file directory structure, so a lib in qt4/ will also be in qt4/ in the PBI,
this helps save space from libs being duplicated in lib/ and lib/qt4 in a PBI
Modified: pbibuild/pbibuilder/pbicreator/PBIfiles/copylibs.sh
===================================================================
--- pbibuild/pbibuilder/pbicreator/PBIfiles/copylibs.sh 2009-06-25 14:56:23 UTC (rev 4144)
+++ pbibuild/pbibuilder/pbicreator/PBIfiles/copylibs.sh 2009-06-25 19:40:16 UTC (rev 4145)
@@ -4,9 +4,104 @@
# ${2} - The directory to copy the libs into - Will be created
#
# Author: Kris Moore
-# Copyright 2005 PC-BSD Software
+# Copyright 2009 PC-BSD Software
###################################################################
+# Function which copies the specified lib into the destdir
+copy_reg_lib()
+{
+ # Get our supplied values
+ FILE="$1"
+ COPYDIR="$2"
+
+ # This library is not a sym-link, lets figure out where it is and copy it
+ # Lets see if this lib exists in some sub-dir and we need to preserve the structure
+ BASEFILE="`basename ${FILE}`"
+ echo ${FILE} | grep "/lib/" >/dev/null 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ # Its not in a /lib/ folder, just copy it now
+ echo "Copy Lib ${FILE} -> ${COPYDIR}"
+ cp ${FILE} ${COPYDIR}/
+ else
+ echo ${FILE} | grep "/lib/${BASEFILE}" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Its in a /lib/ folder, go ahead and just copy it over
+ echo "Copy Lib ${FILE} -> ${COPYDIR}"
+ cp ${FILE} ${COPYDIR}/
+ else
+ # Looks like this library is in a /lib/FOO/ subdirectory, lets preserve this structure
+ DESTCOPY="`echo ${FILE} | sed -e 's|/lib/|\&|' | cut -d '&' -f 2`"
+ DESTDIR="`dirname ${DESTCOPY}`"
+ echo "Copy Lib ${FILE} -> ${COPYDIR}/${DESTCOPY}"
+ mkdir -p ${COPYDIR}/$DESTDIR >/dev/null 2>/dev/null
+ cp ${FILE} ${COPYDIR}/${DESTCOPY}
+ fi
+ fi
+};
+
+# Function which copies the specified sym-linked library into the destdir
+copy_sym_lib()
+{
+ # Get our supplied values
+ FILE="$1"
+ COPYDIR="$2"
+
+ # REALFILE=`echo ${FILE} | cut -d ">" -f 2 | sed -e "s| ||"`
+ # cp ${FILE} ${COPYDIR}/${REALFILE}
+ # cp -R ${FILE} ${COPYDIR}/
+
+ # This library is a sym-link, lets figure out where it is and copy it keeping the link intact
+ REALPATH="`realpath ${FILE}`"
+ REALFILE="`basename ${REALPATH}`"
+ BASEFILE="`basename ${FILE}`"
+
+ # First lets check if this sym-link just points to the same directory
+ ls -al ${FILE} | cut -d ">" -f 2 | tr -d " " | grep ^/ >/dev/null 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ # This link points to a lib in the same directory, figure out if we have a sub-dir and copy it
+ echo ${FILE} | grep "/lib/" >/dev/null 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ # Its not in a /lib/ folder, just copy it now
+ echo "Copy Lib ${REALPATH} -> ${COPYDIR}/${REALFILE}"
+ cp ${REALPATH} ${COPYDIR}/${REALFILE}
+ echo "Link ${REALFILE} -> ${BASEFILE}"
+ cd ${COPYDIR}
+ ln -fs ${REALFILE} ${BASEFILE}
+ else
+ echo ${FILE} | grep "/lib/${BASEFILE}" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Its in a /lib/ folder, go ahead and just copy it over
+ echo "Copy Lib ${REALPATH} -> ${COPYDIR}/${REALFILE}"
+ cp ${REALPATH} ${COPYDIR}/${REALFILE}
+ echo "Link ${REALFILE} -> ${BASEFILE}"
+ cd ${COPYDIR}
+ ln -fs ${REALFILE} ${BASEFILE}
+ else
+ # Looks like this library is in a /lib/FOO/ subdirectory, lets preserve this structure
+ DESTCOPY="`echo ${FILE} | sed -e 's|/lib/|\&|' | cut -d '&' -f 2`"
+ DESTDIR="`dirname ${DESTCOPY}`"
+
+ mkdir -p ${COPYDIR}/$DESTDIR >/dev/null 2>/dev/null
+
+ echo "Copy Lib ${REALPATH} -> ${COPYDIR}/${DESTDIR}/${REALFILE}"
+ cp ${REALPATH} ${COPYDIR}/${DESTDIR}/${REALFILE}
+ echo "Link ${DESTDIR}/${REALFILE} -> ${DESTDIR}/${BASEFILE}"
+ cd ${COPYDIR}/${DESTDIR}
+ ln -fs ${REALFILE} ${BASEFILE}
+ fi
+ fi
+ else
+ # This sym-link isn't pointing to a file in the same directory, lets just copy it instead
+ cp ${REALPATH} ${COPYDIR}/`basename ${FILE}`
+ fi
+
+};
+
LDDFILE="${1}"
COPYDIR="${2}"
PROGDIR="${3}"
@@ -34,19 +129,23 @@
echo $line | grep '=>' >/dev/null 2>/dev/null
if [ "${?}" = "0" ]
then
+
+ # Check if we have a subdir this lib could be in
FILE="`echo $line | cut -d '>' -f 2 | cut -d ' ' -f 2`"
- if [ ! -e "${COPYDIR}/`basename ${FILE}`" ]
+ DESTCOPY="`echo ${FILE} | sed -e 's|/lib/|\&|' | cut -d '&' -f 2`"
+ DESTDIR="`dirname ${DESTCOPY}`"
+
+ if [ ! -e "${COPYDIR}/`basename ${FILE}`" -a ! -e "${COPYDIR}/${DESTDIR}/`basename ${FILE}`" ]
then
- echo "Copy Lib ${FILE} -> ${COPYDIR}"
# Check if we have a symlink here and copy the real file
if [ -h "${FILE}" ]
then
- REALFILE=`echo ${FILE} | cut -d ">" -f 2 | sed -e "s| ||"`
- cp ${FILE} ${COPYDIR}/${REALFILE}
- cp -R ${FILE} ${COPYDIR}/
+ # This is a sym-linked file, lets copy it now
+ copy_sym_lib ${FILE} ${COPYDIR}
else
- cp ${FILE} ${COPYDIR}/
+ # This is a regular file, lets copy it now
+ copy_reg_lib ${FILE} ${COPYDIR}
fi
# If we have found a new library, do a recursive call on copylibs, to ensure its depends are copied also
More information about the Commits
mailing list