mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Jon Ringle <jon@ringle.org>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] ptxd_ipkg_rev_smaller: fix compare with empty micro
Date: Mon, 17 Oct 2011 19:21:44 -0400	[thread overview]
Message-ID: <1318893704-23961-1-git-send-email-jon@ringle.org> (raw)

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

             reply	other threads:[~2011-10-17 23:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 23:21 Jon Ringle [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318893704-23961-1-git-send-email-jon@ringle.org \
    --to=jon@ringle.org \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox