Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   makepkg: devel_check(): set newpkgver (cleanup) (http://www.linux-archive.org/archlinux-pacman-development/643725-makepkg-devel_check-set-newpkgver-cleanup.html)

03-12-2012 05:53 PM

makepkg: devel_check(): set newpkgver (cleanup)
 
From: Matthew Monaco <matthew.monaco@0x01b.net>

The case structure allows the syntax to focus on what's actually being
done here.
---
scripts/makepkg.sh.in | 61 +++++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index c5259c9..d4798ca 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1742,34 +1742,41 @@ devel_check() {

msg "$(gettext "Determining latest %s revision...")" "$vcs"

- if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_cvsroot} && -n ${_cvsmod} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_gitroot} && -n ${_gitname} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_svntrunk} && -n ${_svnmod} ]] ; then
- newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: ([0-9]*)$/1/p')
- elif [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] ; then
- newpkgver=$(bzr revno ${_bzrtrunk})
- elif [[ -n ${_hgroot} && -n ${_hgrepo} ]] ; then
- if [[ -d ./src/$_hgrepo ]] ; then
- cd ./src/$_hgrepo
- local ret=0
- hg pull || ret=$?
- if (( ! ret )); then
- hg update
- elif (( ret != 1 )); then
- return 1
+ case "$vcs" in
+ darcs)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ cvs)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ git)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ svn)
+ newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: ([0-9]*)$/1/p')
+ ;;
+ bzr)
+ newpkgver=$(bzr revno ${_bzrtrunk})
+ ;;
+ hg)
+ if [[ -d ./src/$_hgrepo ]] ; then
+ cd ./src/$_hgrepo
+ local ret=0
+ hg pull || ret=$?
+ if (( ! ret )); then
+ hg update
+ elif (( ret != 1 )); then
+ return 1
+ fi
+ else
+ [[ ! -d ./src/ ]] && mkdir ./src/
+ hg clone $_hgroot/$_hgrepo ./src/$_hgrepo
+ cd ./src/$_hgrepo
fi
- else
- [[ ! -d ./src/ ]] && mkdir ./src/
- hg clone $_hgroot/$_hgrepo ./src/$_hgrepo
- cd ./src/$_hgrepo
- fi
- newpkgver=$(hg tip --template "{rev}")
- cd ../../
- fi
+ newpkgver=$(hg tip --template "{rev}")
+ cd ../../
+ ;;
+ esac

if [[ -n $newpkgver ]]; then
msg2 "$(gettext "Version found: %s")" "$newpkgver"
--
1.7.9.3

Matthew Monaco 03-13-2012 12:14 AM

makepkg: devel_check(): set newpkgver (cleanup)
 
From: Matthew Monaco <matthew.monaco@0x01b.net>

The case structure allows the syntax to focus on what's actually being
done here.
---
scripts/makepkg.sh.in | 61 +++++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 74dfd96..5dcaf60 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1737,34 +1737,41 @@ devel_check() {

msg "$(gettext "Determining latest %s revision...")" "$vcs"

- if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_cvsroot} && -n ${_cvsmod} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_gitroot} && -n ${_gitname} ]] ; then
- newpkgver=$(date +%Y%m%d)
- elif [[ -n ${_svntrunk} && -n ${_svnmod} ]] ; then
- newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: ([0-9]*)$/1/p')
- elif [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] ; then
- newpkgver=$(bzr revno ${_bzrtrunk})
- elif [[ -n ${_hgroot} && -n ${_hgrepo} ]] ; then
- if [[ -d ./src/$_hgrepo ]] ; then
- cd ./src/$_hgrepo
- local ret=0
- hg pull || ret=$?
- if (( ! ret )); then
- hg update
- elif (( ret != 1 )); then
- return 1
+ case "$vcs" in
+ darcs)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ cvs)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ git)
+ newpkgver=$(date +%Y%m%d)
+ ;;
+ svn)
+ newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: ([0-9]*)$/1/p')
+ ;;
+ bzr)
+ newpkgver=$(bzr revno ${_bzrtrunk})
+ ;;
+ hg)
+ if [[ -d ./src/$_hgrepo ]] ; then
+ cd ./src/$_hgrepo
+ local ret=0
+ hg pull || ret=$?
+ if (( ! ret )); then
+ hg update
+ elif (( ret != 1 )); then
+ return 1
+ fi
+ else
+ [[ ! -d ./src/ ]] && mkdir ./src/
+ hg clone $_hgroot/$_hgrepo ./src/$_hgrepo
+ cd ./src/$_hgrepo
fi
- else
- [[ ! -d ./src/ ]] && mkdir ./src/
- hg clone $_hgroot/$_hgrepo ./src/$_hgrepo
- cd ./src/$_hgrepo
- fi
- newpkgver=$(hg tip --template "{rev}")
- cd ../../
- fi
+ newpkgver=$(hg tip --template "{rev}")
+ cd ../../
+ ;;
+ esac

if [[ -n $newpkgver ]]; then
msg2 "$(gettext "Version found: %s")" "$newpkgver"
--
1.7.9.3


All times are GMT. The time now is 01:24 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.