* [yocto-autobuilder][PATCH] PublishArtifacts.py: fix file check to work under dash
@ 2016-08-20 22:50 Bill Randle
2016-08-22 10:28 ` Joshua Lock
0 siblings, 1 reply; 3+ messages in thread
From: Bill Randle @ 2016-08-20 22:50 UTC (permalink / raw)
To: yocto
An earlier patch (ed3857990) to check for existing msd5sum files worked
fine when tested under bash, but failed with an error message about [[
not found when run under dash. Updated the test to not rely on bashisms.
Signed-off-by: Bill Randle <william.c.randle@intel.com>
---
lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py b/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
index d8b554f..58048f0 100644
--- a/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
+++ b/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
@@ -259,8 +259,9 @@ class PublishArtifacts(ShellCommand):
def generateMD5cmd(self, artifact, deploy_dir):
cmd = ""
if os.environ.get('GEN_IMG_MD5') == "True":
+ # crufty test for existing md5sum file required for dash shell
cmd += "for x in `find " + deploy_dir + " -maxdepth 5 -type f`;"
- cmd += "do if [[ $x != *.md5sum ]]; then md5sum $x >> " + "$x.md5sum; fi; done;"
+ cmd += "do echo ${x} | grep -q '\.md5sum'; if [ $? -ne 0 ]; then md5sum $x >> " + "$x.md5sum; fi; done;"
return cmd
def getDeployNames(self, artifact, buildername):
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [yocto-autobuilder][PATCH] PublishArtifacts.py: fix file check to work under dash
2016-08-20 22:50 [yocto-autobuilder][PATCH] PublishArtifacts.py: fix file check to work under dash Bill Randle
@ 2016-08-22 10:28 ` Joshua Lock
2016-08-22 14:40 ` Randle, William C
0 siblings, 1 reply; 3+ messages in thread
From: Joshua Lock @ 2016-08-22 10:28 UTC (permalink / raw)
To: Bill Randle, yocto
On Sat, 2016-08-20 at 15:50 -0700, Bill Randle wrote:
> An earlier patch (ed3857990) to check for existing msd5sum files
> worked
> fine when tested under bash, but failed with an error message about
> [[
> not found when run under dash. Updated the test to not rely on
> bashisms.
>
> Signed-off-by: Bill Randle <william.c.randle@intel.com>
> ---
> lib/python2.7/site-
> packages/autobuilder/buildsteps/PublishArtifacts.py | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/python2.7/site-
> packages/autobuilder/buildsteps/PublishArtifacts.py
> b/lib/python2.7/site-
> packages/autobuilder/buildsteps/PublishArtifacts.py
> index d8b554f..58048f0 100644
> --- a/lib/python2.7/site-
> packages/autobuilder/buildsteps/PublishArtifacts.py
> +++ b/lib/python2.7/site-
> packages/autobuilder/buildsteps/PublishArtifacts.py
> @@ -259,8 +259,9 @@ class PublishArtifacts(ShellCommand):
> def generateMD5cmd(self, artifact, deploy_dir):
> cmd = ""
> if os.environ.get('GEN_IMG_MD5') == "True":
> + # crufty test for existing md5sum file required for dash
> shell
> cmd += "for x in `find " + deploy_dir + " -maxdepth 5
> -type f`;"
> - cmd += "do if [[ $x != *.md5sum ]]; then md5sum $x >> "
> + "$x.md5sum; fi; done;"
> + cmd += "do echo ${x} | grep -q '\.md5sum'; if [ $? -ne 0
> ]; then md5sum $x >> " + "$x.md5sum; fi; done;"
> return cmd
Rather than a "crufty" test, how about using POSIX sh parameter
expansion, i.e.
$ foo="blah.bar"
$ if [ ${foo##*.} == bar ]; then echo "bar!"; fi
bar!
Therefore, the patch would be something like (untested):
cmd += "if [ ${x##*.} == .md5sum ]; then md5sum $x >> $x.md5sum; fi"
Regards,
Joshua
>
> def getDeployNames(self, artifact, buildername):
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [yocto-autobuilder][PATCH] PublishArtifacts.py: fix file check to work under dash
2016-08-22 10:28 ` Joshua Lock
@ 2016-08-22 14:40 ` Randle, William C
0 siblings, 0 replies; 3+ messages in thread
From: Randle, William C @ 2016-08-22 14:40 UTC (permalink / raw)
To: joshua.g.lock@linux.intel.com, yocto@yoctoproject.org
[-- Attachment #1: Type: text/plain, Size: 1995 bytes --]
On Mon, 2016-08-22 at 11:28 +0100, Joshua Lock wrote:
On Sat, 2016-08-20 at 15:50 -0700, Bill Randle wrote:
An earlier patch (ed3857990) to check for existing msd5sum files
worked
fine when tested under bash, but failed with an error message about
[[
not found when run under dash. Updated the test to not rely on
bashisms.
Signed-off-by: Bill Randle <william.c.randle@intel.com<mailto:william.c.randle@intel.com>>
---
lib/python2.7/site-
packages/autobuilder/buildsteps/PublishArtifacts.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/python2.7/site-
packages/autobuilder/buildsteps/PublishArtifacts.py
b/lib/python2.7/site-
packages/autobuilder/buildsteps/PublishArtifacts.py
index d8b554f..58048f0 100644
--- a/lib/python2.7/site-
packages/autobuilder/buildsteps/PublishArtifacts.py
+++ b/lib/python2.7/site-
packages/autobuilder/buildsteps/PublishArtifacts.py
@@ -259,8 +259,9 @@ class PublishArtifacts(ShellCommand):
def generateMD5cmd(self, artifact, deploy_dir):
cmd = ""
if os.environ.get('GEN_IMG_MD5') == "True":
+ # crufty test for existing md5sum file required for dash
shell
cmd += "for x in `find " + deploy_dir + " -maxdepth 5
-type f`;"
- cmd += "do if [[ $x != *.md5sum ]]; then md5sum $x >> "
+ "$x.md5sum; fi; done;"
+ cmd += "do echo ${x} | grep -q '\.md5sum'; if [ $? -ne 0
]; then md5sum $x >> " + "$x.md5sum; fi; done;"
return cmd
Rather than a "crufty" test, how about using POSIX sh parameter
expansion, i.e.
$ foo="blah.bar"
$ if [ ${foo##*.} == bar ]; then echo "bar!"; fi
bar!
Therefore, the patch would be something like (untested):
cmd += "if [ ${x##*.} == .md5sum ]; then md5sum $x >> $x.md5sum; fi"
Regards,
Joshua
Good suggestion! The correct (tested) patch would be:
if [ ${x##*.} != md5sum ]; then md5sum $x >> $x.md5sum; fi"
Updated patch coming shortly.
-Bill
[-- Attachment #2: Type: text/html, Size: 3078 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-22 14:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-20 22:50 [yocto-autobuilder][PATCH] PublishArtifacts.py: fix file check to work under dash Bill Randle
2016-08-22 10:28 ` Joshua Lock
2016-08-22 14:40 ` Randle, William C
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.