* [wic][PATCH 0/6] wic: kickstart fixes
@ 2016-01-18 12:22 Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 1/6] wic: add custom exception KickStartError Ed Bartosh
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
Hi,
This patchset includes usability fixes and error handling improvements
for new kickstart parser.
The following changes since commit a2f23fa62858b89850aab339ddec16dcf6026b37:
openssh: CVE-2016-1907 (2016-01-18 11:47:08 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ed/wic/kickstart-fixes
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/wic/kickstart-fixes
Ed Bartosh (6):
wic: add custom exception KickStartError
wic: catch KickStartError
wic: improve processing of parseing errors
wic: removed unused imports
wic: override ArgumentParser.error
wic: rename kickstarter.py -> ksparser.py
scripts/lib/wic/conf.py | 7 +++++--
scripts/lib/wic/{kickstart.py => ksparser.py} | 24 ++++++++++++++++++----
scripts/lib/wic/plugins/source/bootimg-efi.py | 2 +-
scripts/lib/wic/plugins/source/bootimg-pcbios.py | 2 +-
.../lib/wic/plugins/source/isoimage-isohybrid.py | 2 +-
.../lib/wic/plugins/source/rootfs_pcbios_ext.py | 1 -
6 files changed, 28 insertions(+), 10 deletions(-)
rename scripts/lib/wic/{kickstart.py => ksparser.py} (82%)
--
Regards,
Ed
^ permalink raw reply [flat|nested] 7+ messages in thread
* [wic][PATCH 1/6] wic: add custom exception KickStartError
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 2/6] wic: catch KickStartError Ed Bartosh
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
This exception will be raised by kickstart parser
on parsing errors and processed in the code which
calls parser to produce meaningful error output.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/kickstart.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/kickstart.py
index 2208395..7f0105d 100644
--- a/scripts/lib/wic/kickstart.py
+++ b/scripts/lib/wic/kickstart.py
@@ -31,6 +31,9 @@ from argparse import ArgumentParser, ArgumentTypeError
from wic.partition import Partition
+class KickStartError(Exception):
+ pass
+
def sizetype(arg):
"""
Custom type for ArgumentParser
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [wic][PATCH 2/6] wic: catch KickStartError
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 1/6] wic: add custom exception KickStartError Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 3/6] wic: improve processing of parseing errors Ed Bartosh
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
Catch parsing errors and output them using msger.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/conf.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/lib/wic/conf.py b/scripts/lib/wic/conf.py
index 2e29451..922a0f6 100644
--- a/scripts/lib/wic/conf.py
+++ b/scripts/lib/wic/conf.py
@@ -17,7 +17,7 @@
import os
-from wic.kickstart import KickStart
+from wic.kickstart import KickStart, KickStartError
from wic import msger
from wic.utils import misc
@@ -87,7 +87,10 @@ class ConfigMgr(object):
if not ksconf:
return
- ksobj = KickStart(ksconf)
+ try:
+ ksobj = KickStart(ksconf)
+ except KickStartError as err:
+ msger.error(str(err))
self.create['ks'] = ksobj
self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0]
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [wic][PATCH 3/6] wic: improve processing of parseing errors
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 1/6] wic: add custom exception KickStartError Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 2/6] wic: catch KickStartError Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 4/6] wic: removed unused imports Ed Bartosh
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
Caught argparse.ArgumentError
Included .ks file name and line number into the error messages.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/kickstart.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/kickstart.py
index 7f0105d..5d3a572 100644
--- a/scripts/lib/wic/kickstart.py
+++ b/scripts/lib/wic/kickstart.py
@@ -27,7 +27,7 @@
import shlex
-from argparse import ArgumentParser, ArgumentTypeError
+from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
from wic.partition import Partition
@@ -113,11 +113,16 @@ class KickStart(object):
line = line.strip()
lineno += 1
if line and line[0] != '#':
- parsed = parser.parse_args(shlex.split(line))
+ try:
+ parsed = parser.parse_args(shlex.split(line))
+ except ArgumentError as err:
+ raise KickStartError('%s:%d: %s' % \
+ (confpath, lineno, err))
if line.startswith('part'):
self.partitions.append(Partition(parsed, lineno))
else:
if not self.bootloader:
self.bootloader = parsed
else:
- raise KickStartError("Error: more than one bootloader specified")
+ raise KickStartError("%s:%d: more than one bootloader "\
+ "specified" % (confpath, lineno))
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [wic][PATCH 4/6] wic: removed unused imports
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
` (2 preceding siblings ...)
2016-01-18 12:22 ` [wic][PATCH 3/6] wic: improve processing of parseing errors Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 5/6] wic: override ArgumentParser.error Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 6/6] wic: rename kickstarter.py -> ksparser.py Ed Bartosh
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
Removed imports of wic.kickstart from plugins as they're
not used in the code.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/plugins/source/bootimg-efi.py | 2 +-
scripts/lib/wic/plugins/source/bootimg-pcbios.py | 2 +-
scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 2 +-
scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 1 -
4 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 22f9813..125c943 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -27,7 +27,7 @@
import os
import shutil
-from wic import kickstart, msger
+from wic import msger
from wic.pluginbase import SourcePlugin
from wic.utils.misc import get_custom_config
from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 0b5478e..a1bfa26 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -27,7 +27,7 @@
import os
from wic.utils.errors import ImageError
-from wic import kickstart, msger
+from wic import msger
from wic.utils import runner
from wic.utils.misc import get_custom_config
from wic.pluginbase import SourcePlugin
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
index daefff3..c1e2a5d 100644
--- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
+++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
@@ -24,7 +24,7 @@ import os
import re
import shutil
-from wic import kickstart, msger
+from wic import msger
from wic.pluginbase import SourcePlugin
from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
index 48b4817..3d60e6f 100644
--- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
+++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py
@@ -19,7 +19,6 @@
#
import os
-from wic import kickstart
from wic import msger
from wic.utils import syslinux
from wic.utils import runner
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [wic][PATCH 5/6] wic: override ArgumentParser.error
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
` (3 preceding siblings ...)
2016-01-18 12:22 ` [wic][PATCH 4/6] wic: removed unused imports Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 6/6] wic: rename kickstarter.py -> ksparser.py Ed Bartosh
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
Overriden error method to throw exception instead of
printing usage error message. Exception is caught by
KickStart code to add .ks file name and line number.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/kickstart.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/kickstart.py
index 5d3a572..7dbe052 100644
--- a/scripts/lib/wic/kickstart.py
+++ b/scripts/lib/wic/kickstart.py
@@ -34,6 +34,14 @@ from wic.partition import Partition
class KickStartError(Exception):
pass
+class KickStartParser(ArgumentParser):
+ """
+ This class overwrites error method to throw exception
+ instead of producing usage message(default argparse behavior).
+ """
+ def error(self, message):
+ raise ArgumentError(None, message)
+
def sizetype(arg):
"""
Custom type for ArgumentParser
@@ -77,7 +85,7 @@ class KickStart(object):
self.bootloader = None
self.lineno = 0
- parser = ArgumentParser()
+ parser = KickStartParser()
subparsers = parser.add_subparsers()
part = subparsers.add_parser('part')
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [wic][PATCH 6/6] wic: rename kickstarter.py -> ksparser.py
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
` (4 preceding siblings ...)
2016-01-18 12:22 ` [wic][PATCH 5/6] wic: override ArgumentParser.error Ed Bartosh
@ 2016-01-18 12:22 ` Ed Bartosh
5 siblings, 0 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-01-18 12:22 UTC (permalink / raw)
To: openembedded-core
kickstarter.py was not the best name for this module as previously
there was a directory with the same name in scripts/lib/wic/.
All files were removed from it, but .pyc files could still stay there
causing imports from wic.kickstart to fail with
ImportError: cannot import name KickStart.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/conf.py | 2 +-
scripts/lib/wic/{kickstart.py => ksparser.py} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename scripts/lib/wic/{kickstart.py => ksparser.py} (100%)
diff --git a/scripts/lib/wic/conf.py b/scripts/lib/wic/conf.py
index 922a0f6..f7d56d0 100644
--- a/scripts/lib/wic/conf.py
+++ b/scripts/lib/wic/conf.py
@@ -17,7 +17,7 @@
import os
-from wic.kickstart import KickStart, KickStartError
+from wic.ksparser import KickStart, KickStartError
from wic import msger
from wic.utils import misc
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/ksparser.py
similarity index 100%
rename from scripts/lib/wic/kickstart.py
rename to scripts/lib/wic/ksparser.py
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-01-18 14:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-18 12:22 [wic][PATCH 0/6] wic: kickstart fixes Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 1/6] wic: add custom exception KickStartError Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 2/6] wic: catch KickStartError Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 3/6] wic: improve processing of parseing errors Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 4/6] wic: removed unused imports Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 5/6] wic: override ArgumentParser.error Ed Bartosh
2016-01-18 12:22 ` [wic][PATCH 6/6] wic: rename kickstarter.py -> ksparser.py Ed Bartosh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox