summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lamb <chris@chris-lamb.co.uk>2008-04-17 21:08:58 +0100
committerDaniel Baumann <daniel@debian.org>2011-03-09 19:03:32 +0100
commit3cd834e69cf4fdc710d9b28565b201d1db4344af (patch)
tree7d45c0ae55d68dc46f26c3e5362987d3d9171c73
parent3d1f73e4da4675adfb81f2d6d95dde23ca9b00ae (diff)
downloadvyos-live-build-3cd834e69cf4fdc710d9b28565b201d1db4344af.tar.gz
vyos-live-build-3cd834e69cf4fdc710d9b28565b201d1db4344af.zip
Rewrite Expand_packagelist to not be recursive
-rwxr-xr-xfunctions/packageslists.sh55
1 files changed, 32 insertions, 23 deletions
diff --git a/functions/packageslists.sh b/functions/packageslists.sh
index f29f134e9..443caad66 100755
--- a/functions/packageslists.sh
+++ b/functions/packageslists.sh
@@ -11,32 +11,41 @@ set -e
Expand_packagelist ()
{
- # ${1} List name
- # ${2} Default path to search
- # ${3} Fallback path to search (optional)
-
- # Does list exist in default path?
- if [ -e "${2}/${1}" ];
- then
- Expand_packagelist_file "${2}/${1}" "${@}"
- else
- # If list exists in fallback, include it.
- if [ -n "${3}" ] && [ -e "${3}/${1}" ]
- then
- Expand_packagelist_file "${3}/${1}" "${@}"
- fi
- fi
-}
+ _LH_EXPAND_QUEUE="$(basename "${1}")"
-Expand_packagelist_file ()
-{
- local FILE="${1}"
- shift
shift
- for INCLUDE in $(sed -ne 's|^#<include> \(.*\)|\1|gp' -e 's|^#include <\(.*\)>|\1|gp' "${FILE}")
+ while [ -n "${_LH_EXPAND_QUEUE}" ]
do
- Expand_packagelist "${INCLUDE}" "${@}"
+ _LH_LIST_NAME="$(echo ${_LH_EXPAND_QUEUE} | cut -d" " -f1)"
+ _LH_EXPAND_QUEUE="$(echo ${_LH_EXPAND_QUEUE} | cut -s -d" " -f2-)"
+ _LH_LIST_LOCATION=""
+
+ for _LH_SEARCH_PATH in ${@} "${LH_BASE:-/usr/share/live-helper}/lists"
+ do
+ if [ -e "${_LH_SEARCH_PATH}/${_LH_LIST_NAME}" ]
+ then
+ _LH_LIST_LOCATION="${_LH_SEARCH_PATH}/${_LH_LIST_NAME}"
+ fi
+ done
+
+ if [ -z "${_LH_LIST_LOCATION}" ]
+ then
+ echo "W: Unknown package list '${_LH_LIST_NAME}'" >&2
+ continue
+ fi
+
+ # Output packages
+ grep -v "^#" ${_LH_LIST_LOCATION} | grep .
+
+ # Find includes
+ _LH_INCLUDES="$(sed -n \
+ -e 's|^#<include> \([^ ]*\)|\1|gp' \
+ -e 's|^#include <\([^ ]*\)>|\1|gp' \
+ "${_LH_LIST_LOCATION}")"
+
+ # Add to queue
+ _LH_EXPAND_QUEUE="$(echo ${_LH_EXPAND_QUEUE} ${_LH_INCLUDES} | \
+ sed -e 's|[ ]*$||' -e 's|^[ ]*||')"
done
- sed -ne 's|^\([^#].*\)|\1\n|gp' "${FILE}"
}