[pacman-dev] [PATCH 0/6] VCS versioning modifications
From: Matthew Monaco <matthew.monaco@0x01b.net> I've been bothered by makepkg automatically adjusting pkgver if a package doesn't have the correct -git/svn/etc suffix. The first 4 patches might be useful regardless. They allow for multiple sets of _vcs variables in a PKGBUILD and use the package's name to clear up any ambiguity. The 5th patch changes the current semantics of makepkg. The 6th patch provides a new option to force the old semantics. An alternative might be to sanitize the --forcever option so that it may be used from the command line as well as internally. Matthew Monaco (6): makepkg: remove unused variable makepkg: devel_check(): determine vcs makepkg: devel_check(): consolidate common code makepkg: devel_check(): set newpkgver (cleanup) makepkg: devel_check(): only work for -vcs pkgnames makepkg: add --devver option for SCM packages doc/PKGBUILD.5.txt | 3 +- doc/makepkg.8.txt | 4 ++ scripts/makepkg.sh.in | 126 +++++++++++++++++++++++++++---------------------- 3 files changed, 75 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
On 13/03/12 04:53, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
--- scripts/makepkg.sh.in | 1 - 1 file changed, 1 deletion(-)
Pulled to my patchqueue. Thanks, Allan
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"
From: Matthew Monaco <matthew.monaco@0x01b.net> Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. --- scripts/makepkg.sh.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..1eb62ca 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,27 @@ 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[@]} -eq 0 ]]; then + return + elif [[ ${#vcs[@]} -ge 2 ]]; then + local vcslen=${#vcs[@]} + vcs=(${vcs[@]/${pkgname##*-}/}) + if [[ ${#vcs[@]} -eq $vcslen ]]; then + warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" + return 0 + fi + vcs=${pkgname##*-} + 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
On Mon, Mar 12, 2012 at 12:53:11PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. ---
I'm not really sure I understand the need for this. In what use case are multiple VCS definitions needed?
scripts/makepkg.sh.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..1eb62ca 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,27 @@ 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[@]} -eq 0 ]]; then
We generally use arithmetic contexts elsewhere for numeric comparison.
+ return + elif [[ ${#vcs[@]} -ge 2 ]]; then + local vcslen=${#vcs[@]} + vcs=(${vcs[@]/${pkgname##*-}/})
I think you're intentionally performing whitespace splitting here to avoid counting problems. Even if that isn't the reason, it's not kosher.
+ if [[ ${#vcs[@]} -eq $vcslen ]]; then + warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" + return 0 + fi + vcs=${pkgname##*-}
And after all that array business, vcs is now treated as a string. I appreciate bash's "dynamic" typing, but I rarely seek to abuse it.
+ 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
On 03/12/2012 01:13 PM, Dave Reisner wrote:
On Mon, Mar 12, 2012 at 12:53:11PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. ---
I'm not really sure I understand the need for this. In what use case are multiple VCS definitions needed?
I've only seen multiples when a project is transitioning to a new system. Either way, I think that splitting the check for the which vcs is being used and setting the new version might be useful.
scripts/makepkg.sh.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..1eb62ca 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,27 @@ 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[@]} -eq 0 ]]; then
We generally use arithmetic contexts elsewhere for numeric comparison.
ok
+ return + elif [[ ${#vcs[@]} -ge 2 ]]; then + local vcslen=${#vcs[@]} + vcs=(${vcs[@]/${pkgname##*-}/})
I think you're intentionally performing whitespace splitting here to avoid counting problems. Even if that isn't the reason, it's not kosher.
it's a quick way to test if the -suffix matches the two _vcs variables. also, the potential list is confined to what is above and a vcs with a space in the name isn't likely.
+ if [[ ${#vcs[@]} -eq $vcslen ]]; then + warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" + return 0 + fi + vcs=${pkgname##*-}
And after all that array business, vcs is now treated as a string. I appreciate bash's "dynamic" typing, but I rarely seek to abuse it.
ok
+ 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> EDITS: - user arithmetic contexts for integer comparison - use the regex comparison operator to test array membership Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. --- scripts/makepkg.sh.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..55df323 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,25 @@ 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[@]} >= 2 )); then + if [[ ${vcs[@]} =~ "${pkgname##*-}" ]]; then + warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" + return 0 + fi + vcs=${pkgname##*-} + 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
On 13/03/12 06:37, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
EDITS: - user arithmetic contexts for integer comparison - use the regex comparison operator to test array membership
Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. --- scripts/makepkg.sh.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 05a611d..55df323 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1714,6 +1714,25 @@ 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[@]} >= 2 )); then + if [[ ${vcs[@]} =~ "${pkgname##*-}" ]]; then
If you remove this check based on the package name, I will ack patches 2 to 4. Allan
On 13/03/12 05:22, Matthew Monaco wrote:
On 03/12/2012 01:13 PM, Dave Reisner wrote:
On Mon, Mar 12, 2012 at 12:53:11PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. ---
I'm not really sure I understand the need for this. In what use case are multiple VCS definitions needed?
I've only seen multiples when a project is transitioning to a new system. Either way, I think that splitting the check for the which vcs is being used and setting the new version might be useful.
I do not understand this argument. I have never seen a project transitioning from one VCS to another in such a way that you had to use both VCS systems to get the source. If that happens, you probably have two different projects managed by the same people and should have two packages.
On 03/12/2012 04:56 PM, Allan McRae wrote:
On 13/03/12 05:22, Matthew Monaco wrote:
On 03/12/2012 01:13 PM, Dave Reisner wrote:
On Mon, Mar 12, 2012 at 12:53:11PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
Rather than prioritizing an arbitrary VCS, collect all development directives. If there is more than one, use the package name as a hint. If that doesn't work, abort. ---
I'm not really sure I understand the need for this. In what use case are multiple VCS definitions needed?
I've only seen multiples when a project is transitioning to a new system. Either way, I think that splitting the check for the which vcs is being used and setting the new version might be useful.
I do not understand this argument. I have never seen a project transitioning from one VCS to another in such a way that you had to use both VCS systems to get the source. If that happens, you probably have two different projects managed by the same people and should have two packages.
It wasn't the point of the change; just a potential scenario given when asked. I was in the function and figured Murphy's Law indicated at some point someone was going to do something funny. The real change that I'm after is that a package has to be named appropriately to get an automatic version bump by default.
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 1eb62ca..c5259c9 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1735,47 +1735,24 @@ devel_check() { vcs=${pkgname##*-} 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 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
On Mon, Mar 12, 2012 at 12:53:13PM -0600, dgbaley27@0x01b.net wrote:
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
If we're going to be changing this, please use pushd/popd, quote properly, and check for errors.
+ 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
On 03/12/2012 01:19 PM, Dave Reisner wrote:
On Mon, Mar 12, 2012 at 12:53:13PM -0600, dgbaley27@0x01b.net wrote:
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
If we're going to be changing this, please use pushd/popd, quote properly, and check for errors.
I can do this, but this set didn't touch any of the code that sets newpkgver.
+ 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> If the package's name does not end in -git/svn/etc, then don't touch the pkgver or pkgrel. This changes the current semantics of makepkg, but it shouldn't be too mind blowing. Currently in core/extra there are two vcs packages (svn) which use _svntrunk and _svnmod. They also use -svn in the pkgname so they won't be affected (mplayer-svn, seom-svn). In addition, vim uses the _hg directives but with a double underscore (presumably to avoid automatic versioning despite not being vim-git). In community there are a few packages which use the vcs directives but do not have a -vcs name. Most of these appear to never want an automatic version number (blender, boinc, bti, cfml, go, lorcon, sfml). The exceptions in community are: fusion-icon, ldc, notion, opencollada. --- doc/PKGBUILD.5.txt | 3 ++- scripts/makepkg.sh.in | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index a21c1df..7459521 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -389,7 +389,8 @@ makepkg supports building development versions of packages without having to manually update the pkgver in the PKGBUILD. This was formerly done using the separate utility 'versionpkg'. In order to utilize this functionality, your PKGBUILD must use correct variable names depending on the SCM being fetched -from (e.g., 'makepkg-git', 'mplayer-svn'). +from *and* the name of the package must end in -SCM (e.g., 'makepkg-git', +'mplayer-svn'). *CVS*:: The generated pkgver will be the date the package is built. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d4798ca..dd545c6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1735,6 +1735,11 @@ devel_check() { vcs=${pkgname##*-} fi + if [[ "$vcs" != "${pkgname##*-}" ]]; then + warning "$(gettext "The pkgname does not end in -%s, skipping automatic versioning.")" "$vcs" + 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 -- 1.7.9.3
On Mon, Mar 12, 2012 at 12:53:14PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
If the package's name does not end in -git/svn/etc, then don't touch the pkgver or pkgrel. This changes the current semantics of makepkg, but it shouldn't be too mind blowing.
And I strongly disagree... What's the point in holding the package version if you can't tell the VCS behind the source files to obey this arbitrary date (e.g. in the case of git)?
Currently in core/extra there are two vcs packages (svn) which use _svntrunk and _svnmod. They also use -svn in the pkgname so they won't be affected (mplayer-svn, seom-svn). In addition, vim uses the _hg directives but with a double underscore (presumably to avoid automatic versioning despite not being vim-git).
In community there are a few packages which use the vcs directives but do not have a -vcs name. Most of these appear to never want an automatic version number (blender, boinc, bti, cfml, go, lorcon, sfml).
The exceptions in community are: fusion-icon, ldc, notion, opencollada.
And in my opinion, these packages are wrong.
--- doc/PKGBUILD.5.txt | 3 ++- scripts/makepkg.sh.in | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index a21c1df..7459521 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -389,7 +389,8 @@ makepkg supports building development versions of packages without having to manually update the pkgver in the PKGBUILD. This was formerly done using the separate utility 'versionpkg'. In order to utilize this functionality, your PKGBUILD must use correct variable names depending on the SCM being fetched -from (e.g., 'makepkg-git', 'mplayer-svn'). +from *and* the name of the package must end in -SCM (e.g., 'makepkg-git', +'mplayer-svn').
*CVS*:: The generated pkgver will be the date the package is built. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d4798ca..dd545c6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1735,6 +1735,11 @@ devel_check() { vcs=${pkgname##*-} fi
+ if [[ "$vcs" != "${pkgname##*-}" ]]; then + warning "$(gettext "The pkgname does not end in -%s, skipping automatic versioning.")" "$vcs" + 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 -- 1.7.9.3
On 03/12/2012 01:22 PM, Dave Reisner wrote:
On Mon, Mar 12, 2012 at 12:53:14PM -0600, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
If the package's name does not end in -git/svn/etc, then don't touch the pkgver or pkgrel. This changes the current semantics of makepkg, but it shouldn't be too mind blowing.
And I strongly disagree... What's the point in holding the package version if you can't tell the VCS behind the source files to obey this arbitrary date (e.g. in the case of git)?
I'm not sure I follow. If the package uses _gitroot and _gitname, but is not -git, then from what I saw in packages.git and community.git, most of the time the package is built using git, but the intention is to still build some specific version. (There are a lot of packages that have to use __gitroot, __gitname...). The situation I intend(ed) to help with is when there is some package in the repos that I temporarily want to replace with the git version until the next release. For this, I grab the -git version but set the pkgver to some number just before the next release so future upgrades will happen automatically. That, coupled with my look through existing packages, made it seem like packages that don't have a -vcs shouldn't have the version's automatically set.
Currently in core/extra there are two vcs packages (svn) which use _svntrunk and _svnmod. They also use -svn in the pkgname so they won't be affected (mplayer-svn, seom-svn). In addition, vim uses the _hg directives but with a double underscore (presumably to avoid automatic versioning despite not being vim-git).
In community there are a few packages which use the vcs directives but do not have a -vcs name. Most of these appear to never want an automatic version number (blender, boinc, bti, cfml, go, lorcon, sfml).
The exceptions in community are: fusion-icon, ldc, notion, opencollada.
And in my opinion, these packages are wrong.
So then I'm not sure where the disagreement is =)
--- doc/PKGBUILD.5.txt | 3 ++- scripts/makepkg.sh.in | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index a21c1df..7459521 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -389,7 +389,8 @@ makepkg supports building development versions of packages without having to manually update the pkgver in the PKGBUILD. This was formerly done using the separate utility 'versionpkg'. In order to utilize this functionality, your PKGBUILD must use correct variable names depending on the SCM being fetched -from (e.g., 'makepkg-git', 'mplayer-svn'). +from *and* the name of the package must end in -SCM (e.g., 'makepkg-git', +'mplayer-svn').
*CVS*:: The generated pkgver will be the date the package is built. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d4798ca..dd545c6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1735,6 +1735,11 @@ devel_check() { vcs=${pkgname##*-} fi
+ if [[ "$vcs" != "${pkgname##*-}" ]]; then + warning "$(gettext "The pkgname does not end in -%s, skipping automatic versioning.")" "$vcs" + 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 -- 1.7.9.3
On Mon, Mar 12, 2012 at 01:33:47PM -0600, Matthew Monaco wrote:
On 03/12/2012 01:22 PM, Dave Reisner wrote:
And in my opinion, these packages are wrong.
So then I'm not sure where the disagreement is =)
*rereads* I'm not sure either. I'm going to get some more coffee. Ignore my rambling.
On 13/03/12 04:53, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
If the package's name does not end in -git/svn/etc, then don't touch the pkgver or pkgrel. This changes the current semantics of makepkg, but it shouldn't be too mind blowing.
Well... even if Dave's ramblings are to be ignored, I am very strongly against this. 1) If you have defined _gitroot etc then you have a git package. The name of the package is immaterial. 2) If you do not want to update your pkgver then use the --holdver flag. (which is crap... but achieves the same as this patch). What problem is this solving? All I can see is adding a restriction to what a package name can be with absolutely no benefit. Allan
On 03/12/2012 05:12 PM, Allan McRae wrote:
On 13/03/12 04:53, dgbaley27@0x01b.net wrote:
From: Matthew Monaco <matthew.monaco@0x01b.net>
If the package's name does not end in -git/svn/etc, then don't touch the pkgver or pkgrel. This changes the current semantics of makepkg, but it shouldn't be too mind blowing.
Well... even if Dave's ramblings are to be ignored, I am very strongly against this.
Fair enough
1) If you have defined _gitroot etc then you have a git package. The name of the package is immaterial.
2) If you do not want to update your pkgver then use the --holdver flag. (which is crap... but achieves the same as this patch).
What problem is this solving? All I can see is adding a restriction to what a package name can be with absolutely no benefit.
I thought that requiring a package to be named appropriately to be considered a development package was at least worthy of discussion.
Allan
On Mon, Mar 12, 2012 at 05:54:52PM -0600, Matthew Monaco wrote:
On 03/12/2012 05:12 PM, Allan McRae wrote:
I thought that requiring a package to be named appropriately to be considered a development package was at least worthy of discussion.
Why not display a warning? Automagically modifying things is very unlike what pacman tools do, but vcs naming conventions are something I'd like to see encouraged. Since I'm currently out of aur helpers, I search for packages manually by name and missing packages because they don't stick to the convention is something I'd like to avoid. So, while we're at it, what other approaches on this can you suggest? Downloading pkgbuilds and checking the way mathew's code does now? cheers! mar77i
From: Matthew Monaco <matthew.monaco@0x01b.net> This will allow packages to be built with an automatic development version even if the package's name does not end in -git/svn/etc. --- doc/makepkg.8.txt | 4 ++++ scripts/makepkg.sh.in | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index df41e18..e0255d0 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -58,6 +58,10 @@ Options will break the build process if all of the dependencies are not installed. +*--devver*:: + Force makepkg to automatically bump pkgver if a package uses VCS directives + but does not have a name that ends in -vcs. + *-e, \--noextract*:: Do not extract source files; use whatever source already exists in the src/ directory. This is handy if you want to go into src/ and manually diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index dd545c6..aa68dc5 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -70,6 +70,7 @@ LOGGING=0 SOURCEONLY=0 IGNOREARCH=0 HOLDVER=0 +DEVVER=0 BUILDFUNC=0 CHECKFUNC=0 PKGFUNC=0 @@ -1735,8 +1736,8 @@ devel_check() { vcs=${pkgname##*-} fi - if [[ "$vcs" != "${pkgname##*-}" ]]; then - warning "$(gettext "The pkgname does not end in -%s, skipping automatic versioning.")" "$vcs" + if [[ "$vcs" != "${pkgname##*-}" ]] && (( ! DEVVER )); then + warning "$(gettext "The pkgname does not end in -%s, use --devver to force automatic versioning.")" "$vcs" return 0 fi @@ -1892,6 +1893,7 @@ usage() { printf -- "$(gettext " --asroot Allow %s to run as root user")\n" "makepkg" printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" + printf -- "$(gettext " --devver Force automatic version bumping for development %ss")\n" "$BUILDSCRIPT" printf -- "$(gettext " --holdver Prevent automatic version bumping for development %ss")\n" "$BUILDSCRIPT" printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg" printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" @@ -1933,7 +1935,7 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcdefFghiLmop:rRsSV" -OPT_LONG="allsource,asroot,ignorearch,check,clean,nodeps" +OPT_LONG="allsource,asroot,ignorearch,check,clean,nodeps,devver" OPT_LONG+=",noextract,force,forcever:,geninteg,help,holdver,skippgpcheck" OPT_LONG+=",install,key:,log,nocolor,nobuild,nocheck,nosign,pkg:,rmdeps" OPT_LONG+=",repackage,skipchecksums,skipinteg,skippgpcheck,sign,source,syncdeps" @@ -1961,6 +1963,7 @@ while true; do --check) RUN_CHECK='y' ;; --config) shift; MAKEPKG_CONF=$1 ;; -d|--nodeps) NODEPS=1 ;; + --devver) DEVVER=1 ;; -e|--noextract) NOEXTRACT=1 ;; -f|--force) FORCE=1 ;; #hidden opt used by fakeroot call for svn/cvs/etc PKGBUILDs to set pkgver -- 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 11de2b7..0169bbf 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1763,8 +1763,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 @@ -1774,11 +1773,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
participants (5)
-
Allan McRae
-
Dave Reisner
-
dgbaley27@0x01b.net
-
Martti Kühne
-
Matthew Monaco