gentooup.sh: add option to disable locking

This commit is contained in:
layman 2023-01-24 17:57:37 +01:00
parent 9a27a6a7f6
commit fe76b1fe4e

View file

@ -1,14 +1,6 @@
#!/bin/bash #!/bin/bash
LOCKFILE=/usr/portage/gentooup.lock LOCKFILE=/usr/portage/gentooup.lock
exec {FD_LOCK}<>"$LOCKFILE"
echo "Try to acquire lock for $LOCKFILE"
if ! flock -x -w 60 "$FD_LOCK" ; then
echo "Could not acquire lock for $LOCKFILE"
exit 1
fi
echo "Lock acquired"
PORTAGE_OPTIONS=("--keep-going" "--autounmask-write" "--binpkg-changed-deps=y" "--autounmask-continue") PORTAGE_OPTIONS=("--keep-going" "--autounmask-write" "--binpkg-changed-deps=y" "--autounmask-continue")
PORTAGE_UPGRADE_OPTIONS=("-vuNDk") PORTAGE_UPGRADE_OPTIONS=("-vuNDk")
@ -54,6 +46,11 @@ while [[ $# -gt 0 ]]; do
SYNC_COMMAND="" SYNC_COMMAND=""
shift shift
;; ;;
--no-lock)
echo "not locking"
NO_LOCK=1
shift
;;
--full) --full)
echo "Do a full upgrade including build dependencies" echo "Do a full upgrade including build dependencies"
PORTAGE_UPGRADE_OPTIONS+=("--with-bdeps=y") PORTAGE_UPGRADE_OPTIONS+=("--with-bdeps=y")
@ -92,6 +89,16 @@ myemerge() {
echo "emerge return value: $?" echo "emerge return value: $?"
} }
if [[ -z "$NO_LOCK" ]] ; then
exec {FD_LOCK}<>"$LOCKFILE"
echo "Try to acquire lock for $LOCKFILE"
if ! flock -x -w 60 "$FD_LOCK" ; then
echo "Could not acquire lock for $LOCKFILE"
exit 1
fi
echo "Lock acquired"
fi
if [[ -n ${SYNC_COMMAND} ]] ; then if [[ -n ${SYNC_COMMAND} ]] ; then
${SYNC_COMMAND} ${SYNC_COMMAND}
eix-update >& /dev/null eix-update >& /dev/null