diff --git a/scripts/cleanup_pkgcache.sh b/scripts/cleanup_pkgcache.sh index 8cc349f..81fc643 100755 --- a/scripts/cleanup_pkgcache.sh +++ b/scripts/cleanup_pkgcache.sh @@ -4,7 +4,6 @@ # Path to molecules.git dir SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" -export SABAYON_MOLECULE_HOME DIR="${SABAYON_MOLECULE_HOME}/pkgcache" find "${DIR}" -atime +30 -type f -delete diff --git a/scripts/cleanup_pkgcache_locked.sh b/scripts/cleanup_pkgcache_locked.sh new file mode 100755 index 0000000..5c9fc3d --- /dev/null +++ b/scripts/cleanup_pkgcache_locked.sh @@ -0,0 +1,14 @@ +# Path to molecules.git dir +SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" +. "${SABAYON_MOLECULE_HOME}/scripts/iso_build.include" + +( + flock --timeout 7200 -x 9 + if [ "${?}" != "0" ]; then + echo "[cleanup] cannot acquire lock, stale process holding it?" >&2 + exit 1 + fi + "${SABAYON_MOLECULE_HOME}/scripts/cleanup_pkgcache.sh" +) 9> "${ISO_BUILD_LOCK}" + +exit ${?} \ No newline at end of file