19bc1301b5227e54348c28bc31cb824689a9e37a
1 # Lots of reusable functions. This file is sourced, not run.
3 # libraries are configured with --prefix=/usr to run on
4 # the final system but they are then installed with
5 # make DESTDIR="..." install or similar to temporary
6 # staging directory where other libs can be cross compiled
9 # This doesn't work because libtool will hardwire paths
10 # to /usr/lib in it's *.la files and this leds the cross
11 # compiler to link against libraries from the host system
12 # which of course doesn't work.
14 # We therefore prefix every path in the *.la files with our
15 # temporary staging dir.
17 # This was mostly taken from OpenWRT's autotools.mk
19 function libtool_fixup_libdir
() {
20 cd "$STAGING_DIR/usr/lib"
21 find .
-name $1\
*.la
-o -name lib
$1\
*.la
-o -path .
/$1/\
*.la |
xargs \
22 sed -i "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$STAGING_DIR/usr/lib,g"
26 function install_shared_library
() {
27 cp -P $STAGING_DIR/usr
/lib
/lib
$1*.so
* $ROOT_DIR/usr
/lib || dienow
28 if [ -d "$STAGING_DIR/usr/lib/$1" ]
30 cd $STAGING_DIR/usr
/lib
31 find $1 -name '*.so' |
xargs tar -cf - |
tar -xf - -C $ROOT_DIR/usr
/lib
36 function create_rootfs_tarball
()
38 echo -n creating rootfs.
tar.gz
39 { tar -C "$ROOT_DIR" -czvf rootfs.
tar.gz . || dienow
43 # Try to download a given revision from a svn repository
45 function download_svn
()
48 # In a first step get a tarball filename for the requested revison
50 [ -z "$SVN_REV" ] && SVN_REV
="HEAD"
52 PACKAGE
=`echo "$URL" | sed 's .*/ '`
53 DIRNAME
=$PACKAGE-r$SVN_REV
54 FILENAME
=$PACKAGE-r$SVN_REV.
tar.bz2
56 # Update timestamp so cleanup_oldfiles doesn't delete it
57 touch -c "$SRCDIR/$FILENAME" 2>/dev
/null
59 # Return success if we have a valid copy of the file
60 try_checksum
&& return 0
62 echo Checking out
$PACKAGE revision
$SVN_REV from svn repository
63 # Checkout files from source repository if no revison was
64 # requested find out which revison current HEAD is and
65 # package everything into a tarball.
66 svn co
--non-interactive -r$SVN_REV "$URL" "$SRCDIR/$PACKAGE" | dotprogress ||
return 1
68 if [ "x$SVN_REV" = "xHEAD" ]; then
69 cd "$SRCDIR/$PACKAGE" &&
70 DIRNAME
="$PACKAGE-r$(svn info | grep Revision: | sed 's/Revision: //')" &&
74 mv "$SRCDIR/$PACKAGE" "$SRCDIR/$DIRNAME" &&
75 find "$SRCDIR/$DIRNAME" -name .svn |
xargs rm -rf &&
76 tar -C "$SRCDIR" -cjf "$SRCDIR/$DIRNAME.tar.bz2" "$DIRNAME" &&
77 rm -rf "$SRCDIR/$DIRNAME" && return 0
82 # Note that this sources the file, rather than calling it as a separate
83 # process. That way it can set environment variables if it wants to.
85 function build_package
()
87 [ ! -f "$SOURCES"/sections
/"$1".sh
] && echo "Unknown package: $1" && exit 1
88 .
"$SOURCES"/sections
/"$1".sh