From bc2038d21004c29e349fadee053d4d604b5bb3b9 Mon Sep 17 00:00:00 2001 From: Muhammed Uluyol Date: Sun, 16 May 2010 20:27:45 -0500 Subject: [PATCH] makepkg: Implement libs system --- scripts/makepkg.sh.in | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index e8aaa8b..64c2296 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -40,6 +40,7 @@ export COMMAND_MODE='legacy' myver='@PACKAGE_VERSION@' confdir='@sysconfdir@' BUILDSCRIPT='@BUILDSCRIPT@' +LIBDIR='@LIBDIR@' startdir="$PWD" srcdir="$startdir/src" pkgdir="$startdir/pkg" @@ -193,6 +194,33 @@ get_url() { echo "${1#*::}" } +# load libraries from a string of libs +load_libs() +{ + # Check if the library has been sourced, if not, source it + for lib in $@; do + if ! (($(eval echo \$${lib//-/_}_loaded))); then +# msg "$(gettext "Loading %s")" "$lib" + unset libs + if [[ ! -f "$LIBDIR/$lib" ]]; then + error "$(gettext "%s does not exist.")" "$LIBDIR/$lib" + return 1 + fi + source "libs/$lib" + if [[ $? != 0 ]]; then + error "$(gettext "%s could not be sourced.")" "$LIBDIR/$lib" + return 1 + fi + # Set up a variable so we know the lib has been loaded + eval ${lib//-/_}_loaded=1 + if [[ -n ${libs[@]} ]]; then + # Recurse for any new libs needed + load_libs ${libs[@]} || return 1 + fi + fi + done +} + ## # Checks to see if options are present in makepkg.conf or PKGBUILD; # PKGBUILD options always take precedence. @@ -1775,6 +1803,11 @@ else source "$BUILDFILE" fi +# Load libraries +if [[ -n ${libs[@]} ]]; then + load_libs ${libs[@]} || exit 1 +fi + if (( GENINTEG )); then mkdir -p "$srcdir" chmod a-s "$srcdir" -- 1.7.1