diff options
author | Nicolas Vigier <boklm@mageia.org> | 2011-10-14 23:51:35 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2011-10-14 23:51:35 +0000 |
commit | d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac (patch) | |
tree | 1cffe662950f0fa724720c61e2a08d13042d1d9d /functions | |
parent | 97df7e04d27020620c583b8bb65f8b155427e81e (diff) | |
download | repoctl-d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac.tar repoctl-d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac.tar.gz repoctl-d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac.tar.bz2 repoctl-d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac.tar.xz repoctl-d6e8ffa164fde2a8a704b0018f7f02f7fb9876ac.zip |
add lock functions
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 75 |
1 files changed, 75 insertions, 0 deletions
@@ -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" |