2011-08-07 18:23:32 +02:00
|
|
|
# Emerge wrapper, uses matter lock file support to avoid
|
|
|
|
# concurrent execution
|
|
|
|
emerge() {
|
2012-09-06 14:29:11 +02:00
|
|
|
snapshot_lock_file=/var/tmp/.emerge.snapshot.lock"
|
2011-08-07 18:23:32 +02:00
|
|
|
matter_lock_file="/var/tmp/.matter_resource.lock"
|
|
|
|
flock -x -n "${matter_lock_file}" true
|
|
|
|
rc=${?}
|
|
|
|
if [ "${rc}" != "0" ]; then
|
2012-09-06 14:29:11 +02:00
|
|
|
echo >&2
|
|
|
|
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >&2
|
|
|
|
echo "matter is running on this chroot, in order to prevent explosions" >&2
|
|
|
|
echo "this emerge instance will terminate NOW" >&2
|
|
|
|
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >&2
|
|
|
|
echo >&2
|
2011-08-07 18:23:32 +02:00
|
|
|
return 1
|
|
|
|
else
|
2012-09-06 14:29:11 +02:00
|
|
|
# acquire snapshot read lock in non-blocking, shared mode
|
|
|
|
(
|
|
|
|
flock -s -n 9 || {
|
|
|
|
echo "Hello there," >&2;
|
|
|
|
echo "a chroot snapshot is in progress..." >%2;
|
|
|
|
echo "Try again later." >&2;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
# eval $(portageq envvar -v FETCHCOMMAND RESUMECOMMAND PORTAGE_RSYNC_OPTS)
|
|
|
|
# add bandwidth limit here
|
|
|
|
/usr/bin/emerge --quiet-build=n "$@"
|
|
|
|
exit ${?}
|
|
|
|
) 9> "${snapshot_lock_file}"
|
|
|
|
return "${?}"
|
2011-08-07 18:23:32 +02:00
|
|
|
fi
|
|
|
|
}
|