From 5b2fecb49cb0a26aba71cceb91766ddfda540b89 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Thu, 7 Apr 2022 10:18:08 +0200 Subject: [PATCH] Make evocommit fully compatible with OpenBSD --- CHANGELOG.md | 1 + etc-git/files/evocommit | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70600d04..58426028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * redis: Remount /usr with RW before adding nagios plugin * postfix: Do not send mails through milters a second time after amavis (in packmail) * etc-git : Remount /usr in rw for git gc in in /usr/share/scripts/ +* etc-git: Make evocommit fully compatible with OpenBSD ### Removed diff --git a/etc-git/files/evocommit b/etc-git/files/evocommit index 36050d02..0053784b 100644 --- a/etc-git/files/evocommit +++ b/etc-git/files/evocommit @@ -2,7 +2,7 @@ set -u -VERSION="21.10" +VERSION="22.04" show_version() { cat </dev/null + syslog "Re-mount ${mountpoint} as read-write to commit in repository $1" else mountpoint=$(stat -c '%m' $1) mount -o remount,rw ${mountpoint} @@ -73,6 +74,7 @@ remount_repository_readonly() { if [ "$(get_system)" = "OpenBSD" ]; then partition=$(stat -f '%Sd' $1) mount -u -r /dev/${partition} 2>/dev/null + syslog "Re-mount ${mountpoint} as read-only after commit to repository $1" else mountpoint=$(stat -c '%m' $1) mount -o remount,ro ${mountpoint} 2>/dev/null @@ -92,8 +94,12 @@ main() { rc=0 lock="${GIT_DIR}/index.lock" if [ -f "${lock}" ]; then - limit=$(date +"%s" -d "now - 1 hour") - updated_at=$(stat -c "%Y" "${lock}") + limit=$(($(date +"%s") - (1 * 60 * 60))) + if [ "$(get_system)" = "OpenBSD" ]; then + updated_at=$(stat -f "%m" "${lock}") + else + updated_at=$(stat -c "%Y" "${lock}") + fi if [ "$updated_at" -lt "$limit" ]; then rm -f "${lock}" fi @@ -262,4 +268,4 @@ if [ -d "${GIT_DIR}" ]; then else echo "There is no Git repository in '${REPOSITORY}'" >&2 exit 1 -fi \ No newline at end of file +fi