Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ gzip, bzip2, xz, ..:
man:
to read our minimalistic manpages 8)

fakeroot:
only for beesh --fakeroot, which runs the install and packaging
steps under fakeroot

to be continued - please let us know if you find additional dependencies.
88 changes: 88 additions & 0 deletions src/beesh.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ function show_help() {
-h, --help display this help
--no-archive-build do not archive the build directory
--check run mee_check, mee_check_pre and mee_check_post
--fakeroot run only the install and packaging steps
under fakeroot instead of all of beesh
EOF
}
Expand Down Expand Up @@ -705,6 +707,74 @@ function bee_archivebuild() {
--transform="s,^${BEE_BEEDIR},${PKGALLPKG}/files,"
}

#### bee_fakeroot_start() #####################################################

# Under fakeroot, the stat, chmod and chown calls of every process go through
# the one faked daemon, which slows down file-heavy builds a lot. With
# --fakeroot, only the steps that need the files in ${D} to look owned by root
# run under it: install, crosscheck and packaging.
#
# Starting faked only now also keeps its database clean: files deleted by the
# build outside of fakeroot would leave stale ownership records behind, which
# a new file reusing the inode inherits.
#
# fakeroot keeps faked running only as long as its command, so the command
# reports the environment to use and then waits until its standard input is
# closed, by bee_fakeroot_stop() or by beesh exiting.
function bee_fakeroot_start() {
local key preload library_path v

[ "${OPT_FAKEROOT}" = "yes" ] || return 0

if [ -n "${FAKEROOTKEY}" ] ; then
print_info "already running under fakeroot (FAKEROOTKEY=${FAKEROOTKEY})"
return 0
fi

bee_fakeroot_saved_env=()
for v in LD_PRELOAD LD_LIBRARY_PATH ; do
if [ -n "${!v+set}" ] ; then
bee_fakeroot_saved_env+=( "${v}=${!v}" )
fi
done

coproc BEE_FAKEROOT {
fakeroot -- sh -c 'printf "%s\n" "${FAKEROOTKEY}" "${LD_PRELOAD}" "${LD_LIBRARY_PATH}"; exec cat > /dev/null'
}
bee_fakeroot_pid=${BEE_FAKEROOT_PID}

if ! { read -r key && read -r preload && read -r library_path ; } <&"${BEE_FAKEROOT[0]}" \
|| [ -z "${key}" ] ; then
print_error "ERROR: cannot start fakeroot"
exit 1
fi

print_info "starting fakeroot (FAKEROOTKEY=${key})"

export FAKEROOTKEY=${key}
export LD_PRELOAD=${preload}
export LD_LIBRARY_PATH=${library_path}
}

#### bee_fakeroot_stop() ######################################################

function bee_fakeroot_stop() {
local e

[ -n "${bee_fakeroot_pid}" ] || return 0

print_info "stopping fakeroot"

unset FAKEROOTKEY LD_PRELOAD LD_LIBRARY_PATH
for e in "${bee_fakeroot_saved_env[@]}" ; do
export "${e}"
done

exec {BEE_FAKEROOT[1]}>&-
wait "${bee_fakeroot_pid}"
unset bee_fakeroot_pid
}

function load_buildmagic() {
local oIFS=${IFS}
local IFS=":${IFS}"
Expand Down Expand Up @@ -870,6 +940,7 @@ OPTIONS=$("${BEE_BINDIR}/beegetopt" --name beesh \
--option no-archive-build \
--option ignore-issue \
--option check \
--option fakeroot \
-- "$@")

if [ $? != 0 ] ; then
Expand All @@ -884,6 +955,7 @@ eval set -- "${OPTIONS}"
: ${OPT_CHECK:="no"}
: ${OPT_ARCHIVE_BUILD:="yes"}
: ${OPT_IGNORE_ISSUE:="no"}
: ${OPT_FAKEROOT:="no"}

while true ; do
case "$1" in
Expand Down Expand Up @@ -925,6 +997,10 @@ while true ; do
OPT_CHECK="yes"
shift
;;
--fakeroot)
OPT_FAKEROOT="yes"
shift
;;
--debug)
DEBUG=$2
shift 2
Expand All @@ -940,6 +1016,14 @@ while true ; do
esac
done

# Find out now, not after a build of hours, that the install step cannot run.
if [ "${OPT_FAKEROOT}" = "yes" -a -z "${FAKEROOTKEY}" ] ; then
if ! fakeroot -- true ; then
print_error "ERROR: --fakeroot needs a working fakeroot"
exit 1
fi
fi

config_init

echo -e "${COLOR_CYAN}BEE v${BEE_VERSION} 2009-2016"
Expand Down Expand Up @@ -1093,6 +1177,8 @@ if [ "${OPT_CHECK}" != "no" ] ; then
bee_run check
fi

bee_fakeroot_start

bee_run install

print_info "changing to image directory: ${D}"
Expand All @@ -1102,6 +1188,8 @@ bee_crosscheck

bee_pkg_pack

bee_fakeroot_stop

function bee_check_conflicts() {
"${BEE_LIBEXECDIR}/bee/bee-cache-inventory" CONTENT \
--prepend "${PKGALLPKG} " \
Expand Down