[pacman-dev] [PATCH v3 0/5] development package cleanups
From: Matthew Monaco <matthew.monaco@0x01b.net> Some cleanup in the devel_check() function. The semantics aren't really changed here. Guard against the potential to specify multiple groups of development directives. Matthew Monaco (5): makepkg: remove unused variable makepkg: devel_check(): determine vcs makepkg: devel_check(): consolidate common code makepkg: devel_check(): set newpkgver (cleanup) makepkg: devel_check(): cleanup for hg version scripts/makepkg.sh.in | 117 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 58 deletions(-) -- 1.7.9.3
From: Matthew Monaco <matthew.monaco@0x01b.net> --- scripts/makepkg.sh.in | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 89cd118..05a611d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,7 +1714,6 @@ devel_check() { # calls to makepkg via fakeroot will explicitly pass the version # number to avoid having to determine the version number twice. # Also do a check to make sure we have the VCS tool available. - oldpkgver=$pkgver if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then if ! type -p darcs >/dev/null; then warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "darcs" "darcs" -- 1.7.9.3
From: Matthew Monaco <matthew.monaco@0x01b.net> Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, give a warning and abort. --- scripts/makepkg.sh.in | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..46e787f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,22 @@ devel_check() { # calls to makepkg via fakeroot will explicitly pass the version # number to avoid having to determine the version number twice. # Also do a check to make sure we have the VCS tool available. + local vcs=() + + [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] && vcs+=("darcs") + [[ -n ${_cvsroot} && -n ${_cvsmod} ]] && vcs+=("cvs") + [[ -n ${_gitroot} && -n ${_gitname} ]] && vcs+=("git") + [[ -n ${_svntrunk} && -n ${_svnmod} ]] && vcs+=("svn") + [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] && vcs+=("bzr") + [[ -n ${_hgroot} && -n ${_hgrepo} ]] && vcs+=("hg") + + if (( ${#vcs[@]} == 0 )); then + return + elif (( ${#vcs[@]} > 1 )); then + warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" + return 0 + fi + if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then if ! type -p darcs >/dev/null; then warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "darcs" "darcs" -- 1.7.9.3
From: Matthew Monaco <matthew.monaco@0x01b.net> --- scripts/makepkg.sh.in | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 46e787f..74dfd96 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1730,47 +1730,24 @@ devel_check() { return 0 fi + if ! type -p "$vcs" >/dev/null; then + warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "$vcs" "$vcs" + return 0 + fi + + msg "$(gettext "Determining latest %s revision...")" "$vcs" + if [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] ; then - if ! type -p darcs >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "darcs" "darcs" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'darcs' newpkgver=$(date +%Y%m%d) elif [[ -n ${_cvsroot} && -n ${_cvsmod} ]] ; then - if ! type -p cvs >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "cvs" "cvs" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'cvs' newpkgver=$(date +%Y%m%d) elif [[ -n ${_gitroot} && -n ${_gitname} ]] ; then - if ! type -p git >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "git" "git" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'git' newpkgver=$(date +%Y%m%d) elif [[ -n ${_svntrunk} && -n ${_svnmod} ]] ; then - if ! type -p svn >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "svn" "svn" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'svn' newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: \([0-9]*\)$/\1/p') elif [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] ; then - if ! type -p bzr >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "bzr" "bzr" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'bzr' newpkgver=$(bzr revno ${_bzrtrunk}) elif [[ -n ${_hgroot} && -n ${_hgrepo} ]] ; then - if ! type -p hg >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "hg" "hg" - return 0 - fi - msg "$(gettext "Determining latest %s revision...")" 'hg' if [[ -d ./src/$_hgrepo ]] ; then cd ./src/$_hgrepo local ret=0 -- 1.7.9.3
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
From: Matthew Monaco <matthew.monaco@0x01b.net> Use pushd/popd, quote args, handle some more errors --- scripts/makepkg.sh.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5dcaf60..98e9a5a 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1754,8 +1754,7 @@ devel_check() { newpkgver=$(bzr revno ${_bzrtrunk}) ;; hg) - if [[ -d ./src/$_hgrepo ]] ; then - cd ./src/$_hgrepo + if pushd "./src/$_hgrepo" > /dev/null; then local ret=0 hg pull || ret=$? if (( ! ret )); then @@ -1765,11 +1764,14 @@ devel_check() { fi else [[ ! -d ./src/ ]] && mkdir ./src/ - hg clone $_hgroot/$_hgrepo ./src/$_hgrepo - cd ./src/$_hgrepo + hg clone "$_hgroot/$_hgrepo" "./src/$_hgrepo" + if ! pushd "./src/$_hgrepo" > /dev/null; then + warning "$(gettext "An error occured while determining the hg version number.")" + return 0 + fi fi newpkgver=$(hg tip --template "{rev}") - cd ../../ + popd > /dev/null ;; esac -- 1.7.9.3
On 13/03/12 11:14, Matthew Monaco wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
Some cleanup in the devel_check() function. The semantics aren't really changed here. Guard against the potential to specify multiple groups of development directives.
Matthew Monaco (5): makepkg: remove unused variable makepkg: devel_check(): determine vcs makepkg: devel_check(): consolidate common code makepkg: devel_check(): set newpkgver (cleanup) makepkg: devel_check(): cleanup for hg version
scripts/makepkg.sh.in | 117 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 58 deletions(-)
Thanks, These all look good to me. I have pulled them to my patchqueue branch for Dan to take to master. Allan
participants (2)
-
Allan McRae
-
Matthew Monaco