2007-09-23 08:04:46 +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:04:46 +00:00
|
|
|
|
|
|
|
Chroot ()
|
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local CHROOT="${1}"; shift
|
|
|
|
local COMMANDS
|
|
|
|
COMMANDS="${@}" #must be on separate line to 'local' declaration to avoid error
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Executing commands in chroot
|
2008-08-11 20:28:54 +00:00
|
|
|
Echo_debug "Executing: %s" "${COMMANDS}"
|
2007-11-10 16:39:49 -01:00
|
|
|
|
2012-06-06 19:32:08 +00:00
|
|
|
ENV=""
|
|
|
|
|
2020-02-20 05:58:11 -01:00
|
|
|
local _FILE
|
2012-06-06 19:32:08 +00:00
|
|
|
for _FILE in config/environment config/environment.chroot
|
|
|
|
do
|
|
|
|
if [ -e "${_FILE}" ]
|
|
|
|
then
|
|
|
|
ENV="${ENV} $(grep -v '^#' ${_FILE})"
|
|
|
|
fi
|
|
|
|
done
|
2012-05-24 07:41:27 +00:00
|
|
|
|
2016-11-28 14:20:29 -01:00
|
|
|
# Only pass SOURCE_DATE_EPOCH if its already set
|
|
|
|
if [ "${SOURCE_DATE_EPOCH:-}" != "" ]
|
|
|
|
then
|
|
|
|
ENV="${ENV} SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}"
|
|
|
|
fi
|
|
|
|
|
2013-02-18 11:56:07 -01:00
|
|
|
${_LINUX32} chroot "${CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" DEBIAN_FRONTEND="${LB_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LB_DEBCONF_PRIORITY}" DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" ${ENV} ${COMMANDS}
|
2007-09-23 08:05:09 +00:00
|
|
|
|
2020-02-12 01:40:38 -01:00
|
|
|
return ${?}
|
2007-09-23 08:04:46 +00:00
|
|
|
}
|
2019-12-19 14:21:58 -01:00
|
|
|
|
|
|
|
Chroot_has_package() {
|
2020-02-20 05:58:11 -01:00
|
|
|
local PACKAGE="${1}"; shift
|
|
|
|
local CHROOT="${2:-chroot}"; shift
|
2019-12-19 14:21:58 -01:00
|
|
|
|
|
|
|
if dpkg-query --admindir=${CHROOT}/var/lib/dpkg -s ${PACKAGE} >/dev/null 2>&1 | grep -q "^Status: install"
|
|
|
|
then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
2019-12-19 14:53:30 -01:00
|
|
|
|
|
|
|
Chroot_package_list() {
|
2020-02-20 05:58:11 -01:00
|
|
|
local CHROOT="${1:-chroot}"; shift
|
2019-12-19 14:53:30 -01:00
|
|
|
|
|
|
|
dpkg-query --admindir=${CHROOT}/var/lib/dpkg -W -f'${Package}\n'
|
|
|
|
}
|