2007-09-23 08:05:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2020-03-11 09:07:21 -01:00
|
|
|
## Copyright (C) 2016-2020 The Debian Live team
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:05:12 +00:00
|
|
|
|
|
|
|
Expand_packagelist ()
|
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_EXPAND_QUEUE
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_EXPAND_QUEUE="$(basename "${1}")"
|
2007-09-23 08:05:12 +00:00
|
|
|
|
|
|
|
shift
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
while [ -n "${_LB_EXPAND_QUEUE}" ]
|
2007-09-23 08:05:12 +00:00
|
|
|
do
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_LIST_NAME
|
|
|
|
local _LB_EXPAND_QUEUE
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_LIST_NAME="$(echo ${_LB_EXPAND_QUEUE} | cut -d" " -f1)"
|
|
|
|
_LB_EXPAND_QUEUE="$(echo ${_LB_EXPAND_QUEUE} | cut -s -d" " -f2-)"
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_LIST_LOCATION=""
|
|
|
|
local _LB_NESTED=0
|
|
|
|
local _LB_ENABLED=1
|
2008-04-17 20:08:58 +00:00
|
|
|
|
2020-04-01 08:29:52 +00:00
|
|
|
for _LB_SEARCH_PATH in "${@}"; do
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -e "${_LB_SEARCH_PATH}/${_LB_LIST_NAME}" ]
|
2008-04-17 20:08:58 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_LIST_LOCATION="${_LB_SEARCH_PATH}/${_LB_LIST_NAME}"
|
2008-09-21 10:54:47 +00:00
|
|
|
break
|
2008-04-17 20:08:58 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -z "${_LB_LIST_LOCATION}" ]
|
2008-04-17 20:08:58 +00:00
|
|
|
then
|
2015-01-06 02:10:43 -01:00
|
|
|
Echo_warning "Unknown package list '${_LB_LIST_NAME}'"
|
2008-04-17 20:08:58 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2013-06-24 13:06:53 +00:00
|
|
|
printf "$(cat ${_LB_LIST_LOCATION})\n" | while read _LB_LINE
|
2008-04-26 22:43:01 +00:00
|
|
|
do
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${_LB_LINE}" in
|
2012-07-28 19:57:03 +00:00
|
|
|
\!*)
|
2020-02-20 05:58:11 -01:00
|
|
|
local _EXEC
|
2012-07-28 19:57:03 +00:00
|
|
|
_EXEC="$(echo ${_LB_LINE} | sed -e 's|^!||')"
|
|
|
|
|
2012-09-30 07:33:06 +00:00
|
|
|
case "${LB_BUILD_WITH_CHROOT}" in
|
|
|
|
true)
|
|
|
|
chroot chroot sh -c "${_EXEC}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
false)
|
|
|
|
eval ${_EXEC}
|
|
|
|
;;
|
|
|
|
esac
|
2012-07-28 19:57:03 +00:00
|
|
|
;;
|
|
|
|
|
2008-04-26 22:43:01 +00:00
|
|
|
\#if\ *)
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ ${_LB_NESTED} -eq 1 ]
|
2008-04-26 22:43:01 +00:00
|
|
|
then
|
2015-01-06 02:10:43 -01:00
|
|
|
Echo_error "Nesting conditionals is not supported"
|
2008-04-26 22:43:01 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_NESTED=1
|
2008-04-26 22:43:01 +00:00
|
|
|
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_NEEDLE
|
|
|
|
local _LB_HAYSTACK
|
|
|
|
local _LB_NEEDLE_PART
|
|
|
|
local _LB_HAYSTACK_PART
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)"
|
|
|
|
_LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")"
|
2008-04-28 16:05:30 +00:00
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_ENABLED=0
|
|
|
|
for _LB_NEEDLE_PART in ${_LB_NEEDLE}
|
2008-04-28 16:05:30 +00:00
|
|
|
do
|
2010-09-07 13:11:20 +00:00
|
|
|
for _LB_HAYSTACK_PART in ${_LB_HAYSTACK}
|
2008-04-28 16:05:30 +00:00
|
|
|
do
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${_LB_NEEDLE_PART}" = "${_LB_HAYSTACK_PART}" ]
|
2008-04-28 16:05:30 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_ENABLED=1
|
2008-04-28 16:05:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2008-04-26 22:43:01 +00:00
|
|
|
;;
|
|
|
|
|
2011-06-11 14:03:16 +00:00
|
|
|
\#nif\ *)
|
|
|
|
if [ ${_LB_NESTED} -eq 1 ]
|
|
|
|
then
|
2015-01-06 02:10:43 -01:00
|
|
|
Echo_error "Nesting conditionals is not supported"
|
2011-06-11 14:03:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
_LB_NESTED=1
|
|
|
|
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_NEEDLE
|
|
|
|
local _LB_HAYSTACK
|
|
|
|
local _LB_NEEDLE_PART
|
|
|
|
local _LB_HAYSTACK_PART
|
2011-06-11 14:03:16 +00:00
|
|
|
_LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)"
|
|
|
|
_LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")"
|
|
|
|
|
2016-11-28 14:18:09 -01:00
|
|
|
_LB_ENABLED=1
|
2011-06-11 14:03:16 +00:00
|
|
|
for _LB_NEEDLE_PART in ${_LB_NEEDLE}
|
|
|
|
do
|
|
|
|
for _LB_HAYSTACK_PART in ${_LB_HAYSTACK}
|
|
|
|
do
|
2016-11-28 14:18:09 -01:00
|
|
|
if [ "${_LB_NEEDLE_PART}" = "${_LB_HAYSTACK_PART}" ]
|
2011-06-11 14:03:16 +00:00
|
|
|
then
|
2016-11-28 14:18:09 -01:00
|
|
|
_LB_ENABLED=0
|
2011-06-11 14:03:16 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
|
2008-04-26 22:43:01 +00:00
|
|
|
\#endif*)
|
2010-09-07 13:11:20 +00:00
|
|
|
_LB_NESTED=0
|
|
|
|
_LB_ENABLED=1
|
2008-04-26 22:43:01 +00:00
|
|
|
;;
|
|
|
|
|
2014-12-05 07:45:40 -01:00
|
|
|
\#*)
|
|
|
|
# Skip comments
|
|
|
|
;;
|
|
|
|
|
2008-04-26 22:43:01 +00:00
|
|
|
*)
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ ${_LB_ENABLED} -eq 1 ]
|
2008-04-26 22:43:01 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
echo "${_LB_LINE}"
|
2008-04-26 22:43:01 +00:00
|
|
|
fi
|
|
|
|
;;
|
2008-04-17 20:08:58 +00:00
|
|
|
|
2008-04-26 22:43:01 +00:00
|
|
|
esac
|
2013-06-24 13:06:53 +00:00
|
|
|
done
|
2007-09-23 08:05:12 +00:00
|
|
|
done
|
|
|
|
}
|
2013-06-20 15:36:01 +00:00
|
|
|
|
|
|
|
Discover_package_architectures ()
|
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_EXPANDED_PKG_LIST="${1}"
|
|
|
|
local _LB_DISCOVERED_ARCHITECTURES=""
|
2013-06-20 15:36:01 +00:00
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [ -e "${_LB_EXPANDED_PKG_LIST}" ] && [ -s "${_LB_EXPANDED_PKG_LIST}" ]
|
|
|
|
then
|
2020-02-20 05:58:11 -01:00
|
|
|
local _LB_PACKAGE_LINE
|
|
|
|
local _LB_PACKAGE_LINE_PART
|
2013-06-20 15:36:01 +00:00
|
|
|
while read _LB_PACKAGE_LINE
|
|
|
|
do
|
|
|
|
# Lines from the expanded package list may have multiple, space-separated packages
|
|
|
|
for _LB_PACKAGE_LINE_PART in ${_LB_PACKAGE_LINE}
|
|
|
|
do
|
|
|
|
# Looking for <package>:<architecture>
|
2015-01-25 10:23:13 -01:00
|
|
|
if [ -n "$(echo ${_LB_PACKAGE_LINE_PART} | awk -F"=" '{print $1}' | awk -F':' '{print $2}')" ]
|
2013-06-20 15:36:01 +00:00
|
|
|
then
|
|
|
|
_LB_DISCOVERED_ARCHITECTURES="${_LB_DISCOVERED_ARCHITECTURES} $(echo ${_LB_PACKAGE_LINE_PART} | awk -F':' '{print $2}')"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done < "${_LB_EXPANDED_PKG_LIST}"
|
|
|
|
|
|
|
|
# Output unique architectures, alpha-sorted, one per line
|
|
|
|
echo "${_LB_DISCOVERED_ARCHITECTURES}" | tr -s '[:space:]' '\n' | sort | uniq
|
|
|
|
fi
|
|
|
|
}
|