Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   makepkg: devel_check(): determine vcs (http://www.linux-archive.org/archlinux-pacman-development/643722-makepkg-devel_check-determine-vcs.html)

03-12-2012 05:53 PM

makepkg: devel_check(): determine vcs
 
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

Dave Reisner 03-12-2012 06:13 PM

makepkg: devel_check(): determine vcs
 
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
>
>

Matthew Monaco 03-12-2012 06:22 PM

makepkg: devel_check(): determine vcs
 
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
>>
>>
>

03-12-2012 07:37 PM

makepkg: devel_check(): determine vcs
 
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

Allan McRae 03-12-2012 09:56 PM

makepkg: devel_check(): determine vcs
 
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.

Matthew Monaco 03-12-2012 10:10 PM

makepkg: devel_check(): determine vcs
 
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.

>
>

Allan McRae 03-12-2012 11:34 PM

makepkg: devel_check(): determine vcs
 
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

Matthew Monaco 03-13-2012 12:14 AM

makepkg: devel_check(): determine vcs
 
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


All times are GMT. The time now is 01:17 AM.

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