summaryrefslogtreecommitdiff
path: root/functions/packageslists.sh
blob: 443caad66a4117d57cd90c666d12b5fc6cc03622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh

# packagelists.sh - expands package list includes
# Copyright (C) 2006-2008 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.

set -e

Expand_packagelist ()
{
	_LH_EXPAND_QUEUE="$(basename "${1}")"

	shift

	while [ -n "${_LH_EXPAND_QUEUE}" ]
	do
		_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
}