* [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
@ 2011-10-17 23:21 Jon Ringle
2011-10-18 8:42 ` Jon Ringle
0 siblings, 1 reply; 6+ messages in thread
From: Jon Ringle @ 2011-10-17 23:21 UTC (permalink / raw)
To: ptxdist
ptxd_ipkg_rev_smaller will return the wrong value if the version number
does not include a $micro component.
For example:
pkgd_ipkg_rev_smaller foo_1.0-2_armel.ipk foo_1.0-1_armel.ipk
will incorrectly return 0
Increased the number of parts of rev_upstream that is compared since any
extra parts will be filled in with 0 for comparison purposes
Signed-off-by: Jon Ringle <jon@ringle.org>
---
scripts/libptxdist.sh | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh
index 48dbd64..adf2e12 100644
--- a/scripts/libptxdist.sh
+++ b/scripts/libptxdist.sh
@@ -743,23 +743,31 @@ ptxd_ipkg_rev_smaller() {
local first=`ptxd_ipkg_split $1`
local first_rev_upstream=`ptxd_ipkg_rev_upstream $first`
- local first_rev_packet=`ptxd_ipkg_rev_package $first`
+ local first_rev_packet=$((`ptxd_ipkg_rev_package $first` + 0))
local second=`ptxd_ipkg_split $2`
local second_rev_upstream=`ptxd_ipkg_rev_upstream $second`
- local second_rev_packet=`ptxd_ipkg_rev_package $second`
- local first_major=`echo $first_rev_upstream | awk -F. '{print $1}'`
- local first_minor=`echo $first_rev_upstream | awk -F. '{print $2}'`
- local first_micro=`echo $first_rev_upstream | awk -F. '{print $3}'`
- local second_major=`echo $second_rev_upstream | awk -F. '{print $1}'`
- local second_minor=`echo $second_rev_upstream | awk -F. '{print $2}'`
- local second_micro=`echo $second_rev_upstream | awk -F. '{print $3}'`
+ local second_rev_packet=$((`ptxd_ipkg_rev_package $second` + 0))
+ local first_major=$((`echo $first_rev_upstream | awk -F. '{print $1}'` + 0))
+ local first_minor=$((`echo $first_rev_upstream | awk -F. '{print $2}'` + 0))
+ local first_micro1=$((`echo $first_rev_upstream | awk -F. '{print $3}'` + 0))
+ local first_micro2=$((`echo $first_rev_upstream | awk -F. '{print $4}'` + 0))
+ local first_micro3=$((`echo $first_rev_upstream | awk -F. '{print $5}'` + 0))
+ local second_major=$((`echo $second_rev_upstream | awk -F. '{print $1}'` + 0))
+ local second_minor=$((`echo $second_rev_upstream | awk -F. '{print $2}'` + 0))
+ local second_micro1=$((`echo $second_rev_upstream | awk -F. '{print $3}'` + 0))
+ local second_micro2=$((`echo $second_rev_upstream | awk -F. '{print $4}'` + 0))
+ local second_micro3=$((`echo $second_rev_upstream | awk -F. '{print $5}'` + 0))
[ $first_major -lt $second_major ] && return 0
[ $first_major -gt $second_major ] && return 1
[ $first_minor -lt $second_minor ] && return 0
[ $first_minor -gt $second_minor ] && return 1
- [ $first_micro -lt $second_micro ] && return 0
- [ $first_micro -gt $second_micro ] && return 1
+ [ $first_micro1 -lt $second_micro1 ] && return 0
+ [ $first_micro1 -gt $second_micro1 ] && return 1
+ [ $first_micro2 -lt $second_micro2 ] && return 0
+ [ $first_micro2 -gt $second_micro2 ] && return 1
+ [ $first_micro3 -lt $second_micro3 ] && return 0
+ [ $first_micro3 -gt $second_micro3 ] && return 1
[ $first_rev_packet -lt $second_rev_packet ] && return 0
[ $first_rev_packet -gt $second_rev_packet ] && return 1
--
1.7.0.4
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
2011-10-17 23:21 [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro Jon Ringle
@ 2011-10-18 8:42 ` Jon Ringle
2011-10-19 17:46 ` Robert Schwebel
0 siblings, 1 reply; 6+ messages in thread
From: Jon Ringle @ 2011-10-18 8:42 UTC (permalink / raw)
To: ptxdist
[-- Attachment #1.1: Type: text/plain, Size: 624 bytes --]
On Mon, Oct 17, 2011 at 7:21 PM, Jon Ringle <jon@ringle.org> wrote:
> ptxd_ipkg_rev_smaller will return the wrong value if the version number
> does not include a $micro component.
>
For example:
> pkgd_ipkg_rev_smaller foo_1.0-2_armel.ipk foo_1.0-1_armel.ipk
> will incorrectly return 0
>
>
After more testing, I found that there were other situations where the
version comparison does not work well.
I ended up replacing the implementation of ptxd_ipkg_rev_smaller() with
something much simpler, albeit dependent on dpkg that seems to work well:
ptxd_ipkg_rev_smaller() {
dpkg --compare-versions $1 lt $2
}
[-- Attachment #1.2: Type: text/html, Size: 1095 bytes --]
[-- Attachment #2: Type: text/plain, Size: 48 bytes --]
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
2011-10-18 8:42 ` Jon Ringle
@ 2011-10-19 17:46 ` Robert Schwebel
2011-10-19 18:52 ` Bernhard Walle
0 siblings, 1 reply; 6+ messages in thread
From: Robert Schwebel @ 2011-10-19 17:46 UTC (permalink / raw)
To: ptxdist
On Tue, Oct 18, 2011 at 04:42:46AM -0400, Jon Ringle wrote:
> After more testing, I found that there were other situations where the version
> comparison does not work well.
>
> I ended up replacing the implementation of ptxd_ipkg_rev_smaller() with
> something much simpler, albeit dependent on dpkg that seems to work well:
>
> ptxd_ipkg_rev_smaller() {
> dpkg --compare-versions $1 lt $2
> }
Hmm, that makes us dependend on dpkg (and thus on Debian). PTXdist tries
hard to run on any distribution, so I'm not happy with this.
rsc
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
2011-10-19 17:46 ` Robert Schwebel
@ 2011-10-19 18:52 ` Bernhard Walle
2011-10-19 19:55 ` Jon Ringle
0 siblings, 1 reply; 6+ messages in thread
From: Bernhard Walle @ 2011-10-19 18:52 UTC (permalink / raw)
To: ptxdist
Am 19.10.2011 19:46, schrieb Robert Schwebel:
> On Tue, Oct 18, 2011 at 04:42:46AM -0400, Jon Ringle wrote:
>> After more testing, I found that there were other situations where the version
>> comparison does not work well.
>>
>> I ended up replacing the implementation of ptxd_ipkg_rev_smaller() with
>> something much simpler, albeit dependent on dpkg that seems to work well:
>>
>> ptxd_ipkg_rev_smaller() {
>> dpkg --compare-versions $1 lt $2
>> }
>
> Hmm, that makes us dependend on dpkg (and thus on Debian). PTXdist tries
> hard to run on any distribution, so I'm not happy with this.
Maybe Perl would be okay?
http://www.emdebian.org/trac/browser/current/target/dpkg/trunk/scripts/Dpkg/Version.pm?rev=6998
Seems to be quite official, and the Dpkg::ErrorHandling and
Dpkg::Gettext could be easily removed.
Regards,
Bernhard
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
2011-10-19 18:52 ` Bernhard Walle
@ 2011-10-19 19:55 ` Jon Ringle
2011-10-20 6:10 ` Bernhard Walle
0 siblings, 1 reply; 6+ messages in thread
From: Jon Ringle @ 2011-10-19 19:55 UTC (permalink / raw)
To: ptxdist
[-- Attachment #1.1: Type: text/plain, Size: 1182 bytes --]
On Wed, Oct 19, 2011 at 2:52 PM, Bernhard Walle <bernhard@bwalle.de> wrote:
> Am 19.10.2011 19:46, schrieb Robert Schwebel:
>
> On Tue, Oct 18, 2011 at 04:42:46AM -0400, Jon Ringle wrote:
>>
>>> After more testing, I found that there were other situations where the
>>> version
>>> comparison does not work well.
>>>
>>> I ended up replacing the implementation of ptxd_ipkg_rev_smaller() with
>>> something much simpler, albeit dependent on dpkg that seems to work well:
>>>
>>> ptxd_ipkg_rev_smaller() {
>>> dpkg --compare-versions $1 lt $2
>>> }
>>>
>>
>> Hmm, that makes us dependend on dpkg (and thus on Debian). PTXdist tries
>> hard to run on any distribution, so I'm not happy with this.
>>
>
> Maybe Perl would be okay?
>
> http://www.emdebian.org/trac/**browser/current/target/dpkg/**
> trunk/scripts/Dpkg/Version.pm?**rev=6998<http://www.emdebian.org/trac/browser/current/target/dpkg/trunk/scripts/Dpkg/Version.pm?rev=6998>
>
> Seems to be quite official, and the Dpkg::ErrorHandling and Dpkg::Gettext
> could be easily removed.
>
>
What do you think about the bash implementation found here:
http://lists.us.dell.com/pipermail/dkms-devel/2004-July/000142.html
Jon
[-- Attachment #1.2: Type: text/html, Size: 1878 bytes --]
[-- Attachment #2: Type: text/plain, Size: 48 bytes --]
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
2011-10-19 19:55 ` Jon Ringle
@ 2011-10-20 6:10 ` Bernhard Walle
0 siblings, 0 replies; 6+ messages in thread
From: Bernhard Walle @ 2011-10-20 6:10 UTC (permalink / raw)
To: ptxdist
* Jon Ringle <jon@ringle.org> [2011-10-19 21:55]:
> >
> What do you think about the bash implementation found here:
> http://lists.us.dell.com/pipermail/dkms-devel/2004-July/000142.html
If it is correct and works, why not.
Regards,
Bernhard
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-20 6:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 23:21 [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro Jon Ringle
2011-10-18 8:42 ` Jon Ringle
2011-10-19 17:46 ` Robert Schwebel
2011-10-19 18:52 ` Bernhard Walle
2011-10-19 19:55 ` Jon Ringle
2011-10-20 6:10 ` Bernhard Walle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox