[Pkg-debile-commits] [debile-slave] 07/100: making piuparts work
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:52:58 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository debile-slave.
commit 3dd5d01a60d01dc4c1e55ddd288cc2ef54f0989a
Author: Paul Tagliamonte <tag at pault.ag>
Date: Wed May 22 14:41:02 2013 -0400
making piuparts work
---
ethel/chroot.py | 32 +++++++++++++---
ethel/commands/piuparts.py | 91 ++++++++++++++++++++++++++++++++++++++++----
ethel/error.py | 4 ++
3 files changed, 114 insertions(+), 13 deletions(-)
diff --git a/ethel/chroot.py b/ethel/chroot.py
index 5a7cac8..56cdc3c 100644
--- a/ethel/chroot.py
+++ b/ethel/chroot.py
@@ -1,4 +1,6 @@
from ethel.utils import run_command
+from ethel.error import EthelError
+
import configparser
import contextlib
import shutil
@@ -6,6 +8,15 @@ import sys
import os
+class EthelSubprocessError(EthelError):
+ def __init__(self, out, err, ret, cmd):
+ super(EthelError, self).__init__()
+ self.out = out
+ self.err = err
+ self.ret = ret
+ self.cmd = cmd
+
+
def get_session_file(session):
return '/var/lib/schroot/session/%s' % (session)
@@ -38,11 +49,7 @@ def safe_run(cmd, expected=0):
out, err = (x.decode('utf-8') for x in (out, err))
if ret != expected:
- e = Exception("Bad command")
- e.out = out
- e.err = err
- e.ret = ret
- e.cmd = cmd
+ e = EthelSubprocessError(out, err, ret, cmd)
raise e
return out, err
@@ -87,9 +94,22 @@ def copy(session, source, dest):
def update(chroot):
with schroot(chroot, source=True) as session:
+ print("Updating")
scmd(session, ['apt-get', 'update'], user='root')
+ print("Upgrading")
scmd(session, ['apt-get', '-y', 'dist-upgrade'], user='root')
+ print("Finished update.")
def run_update():
- update(*sys.argv[1:])
+ try:
+ update(*sys.argv[1:])
+ except EthelSubprocessError as e:
+ print(e.cmd)
+ print()
+ print(e.out)
+ print()
+ print(e.err)
+ print()
+ print(e.ret)
+ raise
diff --git a/ethel/commands/piuparts.py b/ethel/commands/piuparts.py
index 8b646d4..e8d4bc7 100644
--- a/ethel/commands/piuparts.py
+++ b/ethel/commands/piuparts.py
@@ -1,5 +1,10 @@
-from ethel.chroot import schroot, copy, scmd, get_tarball
+from ethel.chroot import schroot, copy, scmd, get_tarball, EthelSubprocessError
+from firehose.model import Issue, Message, File, Location
+from storz.wrapper import generate_analysis
+
+import sys
import os
+import re
def piuparts(chroot, package):
@@ -22,12 +27,84 @@ def piuparts(chroot, package):
], user='root')
print("Piuparts installed.")
- out, ret = scmd(session, [
- 'piuparts', '-b', internal_path, internal_package
- ], user='root')
- print(out)
+
+ failed = False
+ try:
+ out, err = scmd(session, [
+ 'piuparts',
+ '-b', internal_path,
+ internal_package,
+ '--warn-on-debsums-errors',
+ '--pedantic-purge-test',
+ ], user='root')
+ except EthelSubprocessError as e:
+ out, err = e.out, e.err
+ failed = True
+
+ return parse_log(out.splitlines(), package)
+
+
+LINE_INFO = re.compile(
+ r"(?P<minutes>\d+)m(?P<sec>(\d(\.?))+)s (?P<severity>\w+): (?P<info>.*)")
+
+def parse_log(lines, path):
+ obj = None
+ info = None
+ cur_msg = ""
+
+ cat = {
+ "dependency-is-messed-up": [
+ "E: Unable to correct problems, you have held broken packages.",
+ ],
+ "conffile-stuff-sucks": ["owned by: .+"],
+ "command-not-found": ["command not found|: not found"],
+ "conffile-modified": [
+ "debsums reports modifications inside the chroot"
+ ]
+ }
+
+ def handle_obj(obj):
+ obj.message = Message(text=cur_msg)
+ for k, v in cat.items():
+ for expr in v:
+ if re.findall(expr, cur_msg) != []:
+ obj.testid = k
+ break
+ #if obj.testid is None:
+ # print(cur_msg)
+ # raise Exception
+ return obj
+
+ for line in lines:
+ if line.startswith(" "):
+ cur_msg += "\n" + line.strip()
+ continue
+
+ match = LINE_INFO.match(line)
+ if match is None:
+ continue
+
+ info = match.groupdict()
+ if info['severity'] in ['DEBUG', 'DUMP', 'INFO']:
+ continue
+
+ if obj:
+ yield handle_obj(obj)
+ cur_msg = ""
+
+ obj = Issue(cwe=None,
+ testid=None,
+ location=Location(file=File(path, None),
+ function=None,
+ point=None),
+ severity=info['severity'],
+ message=Message(text=""),
+ notes=None,
+ trace=None)
+ if obj:
+ yield handle_obj(obj)
def main():
- import sys
- piuparts(*sys.argv[1:])
+ report = piuparts(*sys.argv[1:])
+ print(report)
diff --git a/ethel/error.py b/ethel/error.py
new file mode 100644
index 0000000..b61c595
--- /dev/null
+++ b/ethel/error.py
@@ -0,0 +1,4 @@
+
+
+class EthelError(Exception):
+ pass
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git
More information about the Pkg-debile-commits
mailing list