#1522 Issue closed
: OBS rpm build fails for SLES10 (snapshot release)¶
Labels: fixed / solved / done
, minor bug
gdha opened issue at 2017-10-02 15:30:¶
- rear version (/usr/sbin/rear -V): snapshot
- OS version (cat /etc/rear/os.conf or lsb_release -a): SLES10
- Brief description of the issue:
Noticed on OBS that the rpm package build failed for SLES10 - I know we do not support it anymore, but still...
[ 58s] [1m== Validating scripts and configuration ==[0;0m
[ 58s] find etc/ usr/share/rear/conf/ -name '*.conf' | xargs -n 1 bash -n
[ 58s] bash -n usr/sbin/rear
[ 58s] find . -name '*.sh' | xargs -n 1 bash -O extglob -O nullglob -n
[ 59s] ./usr/share/rear/lib/network-functions.sh: line 732: syntax error in conditional expression: unexpected token `('
[ 59s] ./usr/share/rear/lib/network-functions.sh: line 732: syntax error near `^(('
[ 59s] ./usr/share/rear/lib/network-functions.sh: line 732: ` if [[ "$test_ip" =~ ^(([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))\.){3}([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$ ]] ; then'
[ 60s] make: *** [validate] Error 123
- Work-around, if any: to be verified -most likely due to old bash version the test fails
jsmeix commented at 2017-10-04 09:15:¶
The is_ip() function that contains this was introduced by
@schabrolles via
https://github.com/rear/rear/commit/ef0256256d38e8c52d7f3e17797ea9378f3727b4
@schabrolles
could you try if you could also implement that functionality
with some more traditional bash 3.0 compliant code?
jsmeix commented at 2017-10-04 09:18:¶
On my SLES10SP4 system:
# bash --version GNU bash, version 3.1.17(1)-release (x86_64-suse-linux) Copyright (C) 2005 Free Software Foundation, Inc. # test_ip=1.2.3.4 # if [[ $test_ip =~ ^(([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))\.){3}([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$ ]] ; then echo OK ; fi -bash: syntax error in conditional expression: unexpected token `(' -bash: syntax error near `^(('
jsmeix commented at 2017-10-04 09:27:¶
@schabrolles
only FYI you may have a look at
https://github.com/rear/rear/issues/758
and the resulting
https://github.com/rear/rear/commit/be841759880e0a3a3a1282bba01d0cc0e3b5fc36
where I had "fun with bash 3.x compliance" ;-)
@gdha
do you think it is possible with reasonable effort
to run several automated tests that run "bash -n"
with various bash versions to catch such issues early?
schabrolles commented at 2017-10-05 17:18:¶
@jsmeix Sorry, for the delay, a bit busy...
Do you know if there is a way to easily test bash-3.1
without
installing a SLES10 ?
I tried shopt -s compat31
but I can't reproduce the error with it :(
Do you have a better idea ?
jsmeix commented at 2017-10-06 09:18:¶
@schabrolles
my question about automated tests in
https://github.com/rear/rear/issues/1522#issuecomment-334099770
was primarily meant for @gdha who implemented (as far as I know)
the current continuous integration checks with Travis that are run
automatically for each pull request.
My idea was if it is possible to run those tests on several systems
e.g. older ones with older bash and newer ones with newer bash
or perhaps only on an older one with an old bash as long as
"bash -n" is the only actual test that is done.
Currently, e.g. on
https://github.com/rear/rear/pull/1526
click on "Show all checks" and then on "Details" which leads
to a Travis page where a "Job log" is shown.
On such a Travis job log click on "Raw log" to inspect
the log in better readable form.
Currently for me such a Travis raw log contains (excerpts)
Operating System Details Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS ... bash version GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Therefore my question to @gdha was if it is possible
with reasonable effort to use an older operating system
with a sufficiently old bash for the "bash -n" tests.
gdha commented at 2017-10-06 13:01:¶
@jsmeix @schabrolles No problem - I will test this next week on SLES10 SP4 systems, which is probably old enough
schabrolles commented at 2017-10-06 15:42:¶
@jsmeix @gdha
The following seems to work for me for bash-3.1 and bash-4.X ..
The only change is to use a variable to store the regex.
Could you confirm it works on your SLES10 ?
pattern="^(([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))\.){3}([0-9]{1,2}|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$"
for test_ip in 1.2.3.4 1.a.3.4 1.999.3.4 ; do
echo -n "$test_ip "
if [[ $test_ip =~ $pattern ]]; then
echo OK
else
echo FAILED
fi
done
- With bash 4.3
# bash --version
GNU bash, version 4.3.48(1)-release (powerpc64le-unknown-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# bash seb.sh
1.2.3.4 OK
1.a.3.4 FAILED
1.999.3.4 FAILED
- with bash 3.1
# ./bin/bash-3.1 --version
GNU bash, version 3.1.0(2)-release (powerpc64le-unknown-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
# ./bin/bash-3.1 seb.sh
1.2.3.4 OK
1.a.3.4 FAILED
1.999.3.4 FAILED
gdha commented at 2017-10-07 10:31:¶
Here are the results of SLES 10SP4:
$ cat /etc/SuSE-release
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4
$ bash --version
GNU bash, version 3.1.17(1)-release (x86_64-suse-linux)
Copyright (C) 2005 Free Software Foundation, Inc.
$ bash seb.sh
1.2.3.4 OK
1.a.3.4 FAILED
1.999.3.4 FAILED
jsmeix commented at 2017-10-09 08:03:¶
With
https://github.com/rear/rear/pull/1528
merged
this issue should be fixed.
@schabrolles
many thanks for the fix and even more thanks
for finding a way that seems to solve the problem of
quoted regex (bash <3.2) and non-quoted regex (bash >= 3.2), cf.
https://github.com/rear/rear/issues/758#issuecomment-181903918
[Export of Github issue for rear/rear.]