Message ID | 1420583899-15338-1-git-send-email-bpringlemeir@nbsps.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Hi Bill, On Tue, 6 Jan 2015 17:38:19 -0500 Bill Pringlemeir <bpringlemeir@nbsps.com> wrote: > Commit 73c25753 fixed the common issue that binutil packages (tool/organization > that packaged or built the bin-utils) are included in brackets and this may > falsely be recognized as a version. However, some tools do not provide a > 'package' and previously we add the 'Gnu assembler..' to the version. > > Run a 2nd pass on the 'version_string' to strip off any leading characters when > a package is not provided in brackets. > > Signed-off-by: Bill Pringlemeir <bpringlemeir@nbsps.com> > --- > scripts/binutils-version.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/binutils-version.sh b/scripts/binutils-version.sh > index 0bc26cf..b1afc98 100755 > --- a/scripts/binutils-version.sh > +++ b/scripts/binutils-version.sh > @@ -5,7 +5,6 @@ > # Prints the binutils version of `gas-command' in a canonical 4-digit form > # such as `0222' for binutils 2.22 > # > - > gas="$*" > > if [ ${#gas} -eq 0 ]; then > @@ -15,6 +14,7 @@ if [ ${#gas} -eq 0 ]; then > fi > > version_string=$($gas --version | head -1 | sed -e 's/.*) *\([0-9.]*\).*/\1/' ) > +version_string=$(echo "$version_string" | sed -e 's/[^0-9]*\([0-9.]*\).*/\1/') > > MAJOR=$(echo $version_string | cut -d . -f 1) > MINOR=$(echo $version_string | cut -d . -f 2) > -- > 1.8.0.2 Thanks for your patch. I think this works but could it be more simplified? In your commit-log, you mentioned only some of tools provide additional information surrounded by brackets. If so, we can [1] remove blackets [2] and then take the first word that consists of numbers+period Like this: version_string=$($gas --version | head -1 | \ sed -e 's/(.*)//' -e 's/[^0-9.]*\([0-9.]*\).*/\1/') MAJOR=$(echo $version_string | cut -d . -f 1) MINOR=$(echo $version_string | cut -d . -f 2) printf "%02d%02d\\n" $MAJOR $MINOR Best Regards Masahiro Yamada
On 7 Jan 2015, yamada.m@jp.panasonic.com wrote: > Thanks for your patch. > > I think this works but could it be more simplified? > > In your commit-log, you mentioned only some of tools provide > additional information surrounded by brackets. > > If so, we can > [1] remove blackets > [2] and then take the first word that consists of numbers+period > > > Like this: > > version_string=$($gas --version | head -1 | \ > sed -e 's/(.*)//' -e 's/[^0-9.]*\([0-9.]*\).*/\1/') > > MAJOR=$(echo $version_string | cut -d . -f 1) > MINOR=$(echo $version_string | cut -d . -f 2) > > printf "%02d%02d\\n" $MAJOR $MINOR I realized I didn't need to spawn sed twice, but removing the '(package)' stuff seems better. Thanks for giving me a reason to fix the whitespace. Also the string, GNU assembler version 2.24.0-6.fc21 20140613 Was originally reporting '2014061320140613' prior to your version. The new version reports '0224' like all the others. Fwiw, Bill.
diff --git a/scripts/binutils-version.sh b/scripts/binutils-version.sh index 0bc26cf..b1afc98 100755 --- a/scripts/binutils-version.sh +++ b/scripts/binutils-version.sh @@ -5,7 +5,6 @@ # Prints the binutils version of `gas-command' in a canonical 4-digit form # such as `0222' for binutils 2.22 # - gas="$*" if [ ${#gas} -eq 0 ]; then @@ -15,6 +14,7 @@ if [ ${#gas} -eq 0 ]; then fi version_string=$($gas --version | head -1 | sed -e 's/.*) *\([0-9.]*\).*/\1/' ) +version_string=$(echo "$version_string" | sed -e 's/[^0-9]*\([0-9.]*\).*/\1/') MAJOR=$(echo $version_string | cut -d . -f 1) MINOR=$(echo $version_string | cut -d . -f 2)
Commit 73c25753 fixed the common issue that binutil packages (tool/organization that packaged or built the bin-utils) are included in brackets and this may falsely be recognized as a version. However, some tools do not provide a 'package' and previously we add the 'Gnu assembler..' to the version. Run a 2nd pass on the 'version_string' to strip off any leading characters when a package is not provided in brackets. Signed-off-by: Bill Pringlemeir <bpringlemeir@nbsps.com> --- scripts/binutils-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)