aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README3
-rw-r--r--functions75
-rw-r--r--repoctl.conf1
3 files changed, 79 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..eccdd6a
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+
+Dependencies :
+ - inotify-tools
diff --git a/functions b/functions
index 5df904e..13d9e1a 100644
--- a/functions
+++ b/functions
@@ -51,6 +51,81 @@ function update_hdlists()
update_common_MD5SUM $distrorelease
}
+function get_lock()
+{
+ local lockdir="$1"
+ local waitdir="$lockdir/wait.$$"
+
+ if mkdir "$lockdir"
+ then
+ return
+ else
+ if ! mkdir "$waitdir"
+ then
+ get_lock "$lockdir"
+ return
+ fi
+ inotifywait -e delete_self "$waitdir"
+ fi
+}
+
+function rm_lock()
+{
+ local lockdir="$1"
+ if rmdir "$lockdir"
+ then
+ return
+ fi
+ local l=$(ls -tr "$lockdir" | head -1)
+ rmdir "$lockdir/$l"
+}
+
+function get_repo_lock()
+{
+ local distrorelease="$1"
+ local section="$2"
+ local sectionrepo="$3"
+ repolock="$lockdir/$distrorelease-$section-$sectionrepo.lock"
+ get_lock "$repolock"
+}
+
+function rm_repo_lock()
+{
+ local distrorelease="$1"
+ local section="$2"
+ local sectionrepo="$3"
+ repolock="$lockdir/$distrorelease-$section-$sectionrepo.lock"
+ rm_lock "$repolock"
+}
+
+function get_distro_lock()
+{
+ local distrorelease="$1"
+ local distrolock="$lockdir/$distrorelease"
+ get_lock "$distrolock"
+ for distrosection in $distrosections
+ do
+ for sectionrepo in $sectionsrepos
+ do
+ get_repo_lock $distrorelease $distrosection $sectionrepo
+ done
+ done
+}
+
+function rm_distro_lock()
+{
+ local distrorelease="$1"
+ local distrolock="$lockdir/$distrorelease"
+ for distrosection in $distrosections
+ do
+ for sectionrepo in $sectionsrepos
+ do
+ rm_repo_lock $distrorelease $distrosection $sectionrepo
+ done
+ done
+ rm_lock "$distrolock"
+}
+
function update_common_MD5SUM()
{
distrorelease="$1"
diff --git a/repoctl.conf b/repoctl.conf
index d88a811..1c556fa 100644
--- a/repoctl.conf
+++ b/repoctl.conf
@@ -8,6 +8,7 @@ else
requestuser="$SUDO_USER"
fi
moveupdate_mailfrom="$requestuser <root@mageia.org>"
+lockdir=/var/lib/repoctl/locks
distribdir=/distrib/bootstrap/distrib
finaldistribdir=/distrib/mirror/distrib
distroreleases='1'