index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-06-15 11:20:37 -0600 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-06-15 11:20:37 -0600 |
commit | a8c95177c7f9bab8cb7e697c6e925b2fb1c5d342 (patch) | |
tree | ed43f04c4e2aaab033aba23fae4ead687555ca9b /lib | |
parent | a7ee45d6259e84628599f721abc297f935504fee (diff) | |
parent | a7a05deb37b3db6aa3606f488467f621c40ce32d (diff) |
-rw-r--r-- | lib/common.sh | 90 |
diff --git a/lib/common.sh b/lib/common.sh index 9f537c7..c6c5993 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -107,48 +107,76 @@ in_array() { } ## -# usage : lock_open_write( $fd, $path.lock, $wait_message ) +# usage : get_full_version( [$pkgname] ) +# return : full version spec, including epoch (if necessary), pkgver, pkgrel ## -lock_open_write() { +get_full_version() { + # set defaults if they weren't specified in buildfile + pkgbase=${pkgbase:-${pkgname[0]}} + epoch=${epoch:-0} + if [[ -z $1 ]]; then + if [[ $epoch ]] && (( ! $epoch )); then + echo $pkgver-$pkgrel + else + echo $epoch:$pkgver-$pkgrel + fi + else + for i in pkgver pkgrel epoch; do + local indirect="${i}_override" + eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p") + [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\" + done + if (( ! $epoch_override )); then + echo $pkgver_override-$pkgrel_override + else + echo $epoch_override:$pkgver_override-$pkgrel_override + fi + fi +} + +## +# usage : lock( $fd, $file, $message ) +## +lock() { local fd=$1 - local path=$2 - local msg=$3 + local file=$2 + local mesg=$3 # Only reopen the FD if it wasn't handed to us - if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "${path}")" ]]; then - mkdir -p "${path%/*}" - eval "exec $fd>${path}" + if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "$file")" ]]; then + mkdir -p "${file%/*}" + eval "exec $fd>"'"$file"' fi if ! flock -n $fd; then - stat_busy "$msg" + stat_busy "$mesg" flock $fd stat_done fi } ## -# usage : lock_open_read( $fd, $path.lock, $wait_message ) +# usage : slock( $fd, $file, $message ) ## -lock_open_read() { +slock() { local fd=$1 - local path=$2 - local msg=$3 + local file=$2 + local mesg=$3 # Only reopen the FD if it wasn't handed to us - if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "${path}")" ]]; then - mkdir -p "${path%/*}" - eval "exec $fd>${path}" + if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "$file")" ]]; then + mkdir -p "${file%/*}" + eval "exec $fd>"'"$file"' fi + eval "exec $fd>"'"$file"' if ! flock -sn $fd; then - stat_busy "$msg" + stat_busy "$mesg" flock -s $fd stat_done fi } - ## # usage : lock_close( $fd ) ## @@ -156,31 +184,3 @@ lock_close() { local fd=$1 eval "exec $fd>&-" } - -## -# usage : get_full_version( [$pkgname] ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { - # set defaults if they weren't specified in buildfile - pkgbase=${pkgbase:-${pkgname[0]}} - epoch=${epoch:-0} - if [[ -z $1 ]]; then - if [[ $epoch ]] && (( ! $epoch )); then - echo $pkgver-$pkgrel - else - echo $epoch:$pkgver-$pkgrel - fi - else - for i in pkgver pkgrel epoch; do - local indirect="${i}_override" - eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p") - [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\" - done - if (( ! $epoch_override )); then - echo $pkgver_override-$pkgrel_override - else - echo $epoch_override:$pkgver_override-$pkgrel_override - fi - fi -} |