package cache: initialise with a function

This commit is contained in:
MilhouseVH 2017-12-21 13:41:30 +00:00
parent bf71ef864b
commit 64156ea8c8
3 changed files with 94 additions and 87 deletions

View File

@ -515,6 +515,28 @@ enable_service () {
done done
} }
init_package_cache() {
local _ANCHOR="@?+?@" DIR
# If the package caches are unset, then populate them
if [ -z "${_CACHE_PACKAGE_LOCAL+x}" -o -z "${_CACHE_PACKAGE_GLOBAL+x}" ]; then
_CACHE_PACKAGE_LOCAL=""
_CACHE_PACKAGE_GLOBAL=""
# cache project folder for a package
for DIR in $(find $ROOT/projects/$PROJECT/packages -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_LOCAL+="${DIR}${_ANCHOR}\n"
done
# cache packages folder
for DIR in $(find $ROOT/$PACKAGES -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_GLOBAL+="${DIR}${_ANCHOR}\n"
done
export _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
fi
}
check_path() { check_path() {
dashes="===========================" dashes="==========================="
if [ "${PWD##/usr}" != "${PWD}" ]; then if [ "${PWD##/usr}" != "${PWD}" ]; then

View File

@ -53,34 +53,19 @@ SED="sed -i"
unset LD_LIBRARY_PATH unset LD_LIBRARY_PATH
# set package metadata # If the package caches are unset, then populate them
reset_pkg_vars "$1" init_package_cache
if [ -n "$1" ]; then # set package metadata
reset_pkg_vars "$1"
if [ -n "$1" ]; then
_PKG_ROOT_NAME=${1%:*} _PKG_ROOT_NAME=${1%:*}
_ALL_DIRS="" _ALL_DIRS=""
_FOUND=0 _FOUND=0
_ANCHOR="@?+?@" _ANCHOR="@?+?@"
PKG_DIR="" PKG_DIR=""
# If the package caches are unset, then populate them
if [ -z "${_CACHE_PACKAGE_LOCAL+x}" -o -z "${_CACHE_PACKAGE_GLOBAL+x}" ]; then
_CACHE_PACKAGE_LOCAL=""
_CACHE_PACKAGE_GLOBAL=""
# cache project folder for a package
for DIR in $(find $ROOT/projects/$PROJECT/packages -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_LOCAL+="${DIR}${_ANCHOR}\n"
done
# cache packages folder
for DIR in $(find $ROOT/$PACKAGES -type d 2>/dev/null); do
[ -r "$DIR/package.mk" ] && _CACHE_PACKAGE_GLOBAL+="${DIR}${_ANCHOR}\n"
done
export _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
fi
# Check for any available local package in preference to a global package # Check for any available local package in preference to a global package
for DIR in $(echo -e "${_CACHE_PACKAGE_LOCAL}" | grep -F "/${_PKG_ROOT_NAME}${_ANCHOR}"); do for DIR in $(echo -e "${_CACHE_PACKAGE_LOCAL}" | grep -F "/${_PKG_ROOT_NAME}${_ANCHOR}"); do
DIR="${DIR%${_ANCHOR}}" DIR="${DIR%${_ANCHOR}}"
@ -109,27 +94,27 @@ unset LD_LIBRARY_PATH
echo -e "$_ALL_DIRS" echo -e "$_ALL_DIRS"
exit 1 exit 1
fi fi
fi fi
if [ -n "$PKG_DIR" -a -r $PKG_DIR/package.mk ]; then if [ -n "$PKG_DIR" -a -r $PKG_DIR/package.mk ]; then
unset -f configure_package unset -f configure_package
. $PKG_DIR/package.mk . $PKG_DIR/package.mk
[ -z "$PKG_SHORTDESC" ] && PKG_SHORTDESC="$PKG_NAME (autogenerated)" [ -z "$PKG_SHORTDESC" ] && PKG_SHORTDESC="$PKG_NAME (autogenerated)"
[ -z "$PKG_LONGDESC" ] && PKG_LONGDESC="$PKG_NAME (autogenerated)" [ -z "$PKG_LONGDESC" ] && PKG_LONGDESC="$PKG_NAME (autogenerated)"
fi fi
if [ "$PKG_IS_ADDON" = "yes" ] ; then if [ "$PKG_IS_ADDON" = "yes" ] ; then
[ -z $PKG_SECTION ] && PKG_ADDON_ID="$PKG_NAME" || PKG_ADDON_ID="${PKG_SECTION//\//.}.$PKG_NAME" [ -z $PKG_SECTION ] && PKG_ADDON_ID="$PKG_NAME" || PKG_ADDON_ID="${PKG_SECTION//\//.}.$PKG_NAME"
[ "$PKG_ADDON_IS_STANDALONE" != "yes" ] && PKG_NEED_UNPACK="${PKG_NEED_UNPACK} $(get_pkg_directory $MEDIACENTER)" [ "$PKG_ADDON_IS_STANDALONE" != "yes" ] && PKG_NEED_UNPACK="${PKG_NEED_UNPACK} $(get_pkg_directory $MEDIACENTER)"
fi fi
# Automatically set PKG_SOURCE_NAME unless it is already defined. # Automatically set PKG_SOURCE_NAME unless it is already defined.
# PKG_SOURCE_NAME will be automatically set to a name based on # PKG_SOURCE_NAME will be automatically set to a name based on
# the $PKG_NAME-$PKG_VERSION convention. # the $PKG_NAME-$PKG_VERSION convention.
# #
# Any $PKG_URL that references more than a single url will abort # Any $PKG_URL that references more than a single url will abort
# the build as these are no longer supported - use mkpkg instead. # the build as these are no longer supported - use mkpkg instead.
if [ -n "$PKG_URL" -a -z "$PKG_SOURCE_NAME" ]; then if [ -n "$PKG_URL" -a -z "$PKG_SOURCE_NAME" ]; then
if [[ $PKG_URL =~ .*\ .* ]]; then if [[ $PKG_URL =~ .*\ .* ]]; then
echo "Error - packages with multiple urls are no longer supported, use mkpkg:" echo "Error - packages with multiple urls are no longer supported, use mkpkg:"
echo "$PKG_URL" echo "$PKG_URL"
@ -153,9 +138,9 @@ unset LD_LIBRARY_PATH
PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.${PKG_SOURCE_NAME##*\.} PKG_SOURCE_NAME=${PKG_NAME}-${PKG_VERSION}.${PKG_SOURCE_NAME##*\.}
;; ;;
esac esac
fi fi
PKG_BUILD="$BUILD/${PKG_NAME}-${PKG_VERSION}" PKG_BUILD="$BUILD/${PKG_NAME}-${PKG_VERSION}"
XORG_PATH_DRI=/usr/lib/dri XORG_PATH_DRI=/usr/lib/dri
XORG_PATH_XKB=/usr/share/X11/xkb XORG_PATH_XKB=/usr/share/X11/xkb

View File

@ -20,7 +20,7 @@
unset _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL unset _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
. config/options TRIGGER_POPULATION_OF_CACHE_PACKAGE . config/options ""
. config/show_config . config/show_config
show_config show_config