Hello,
Following is reviewer part, it is not in a usable format because
Rpm.py and Srpm.py modules with Rpm and Srpm classes respectively are
not implemented yet and I will be writing them next. Moreover, the
only check we have needs some work to adjust to latest changes.
I have introduced three more Check classes, one is Check and other two
are SrcRPMCheck and RPMCheck. The fundamental behind this is they
conceptually categorize the spec checks, rpm checks, srpm checks and
hybrid checks. Hybrid checks are those checks where one needs two or
all three types of objects (spec, srpm or rpm). And thus saves lots of
hard code logic for "implement this categorization " and "implement
the number of objects (spec, srpm or rpms)" on needs to keep count on
while doing the running all the guidelines.
runRpmlint is right now a separate method in RomReviewer module. It
calls printRpmLintMessages from Reporter.
I would like to get this up so as Application Block work gets started.
In the meantime I will finish Srpm.py and Rpm.py and fix the
BuildRootCheck (only) test we have and get this Reviewer code working.
The patch files are:
[1]
http://rakesh.fedorapeople.org/misc/0001--Check.py-New-file.patch
[2]
http://rakesh.fedorapeople.org/misc/0002--SrcRPMCheck.py-New-file.patch
[3]
http://rakesh.fedorapeople.org/misc/0003--RPMCheck.py-New-file.patch
[4]
http://rakesh.fedorapeople.org/misc/0004--RomReviewer.py-New-file.patch
[5]
http://rakesh.fedorapeople.org/misc/0005--RomSrcRPMReviewer.py-New-file.p...
[6]
http://rakesh.fedorapeople.org/misc/0006--RomSpecReviewer.py-New-file.patch
[7]
http://rakesh.fedorapeople.org/misc/0007--RomRPMReviewer.py-New-file.patch
--
rakesh
From 1a3671b96227e7041aa9716b4e406a3c3fb77472 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:25:50 +0530
Subject: [PATCH] * Check.py: New file.
---
Check.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
create mode 100644 Check.py
diff --git a/Check.py b/Check.py
new file mode 100644
index 0000000..b97006e
--- /dev/null
+++ b/Check.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+#
+# Every hybrid check file needs to inherit from this class
+#
+
+
+class Check(object):
+ """
+ Base class for all checks.
+ """
+ check_names_seen = []
+ checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in SpecCheck.check_names_seen:
+ SpecCheck.checks.append(self)
+ SpecCheck.check_names_seen.append(name)
+ self.name = name
+
+ def check(self, **details):
+ """
+ This one is for hybrid checks. Where we may need combination of
+ spec, srpm, rpm.
+
+ details: dictionary where one or more of spec, srpm, rpm can object
+ can be passed.
+
+ Will be implemented by derived classes.
+ """
+ raise NotImplementedError()
+
+
+# Check ends here.
--
1.6.0.6
From 8ed449d966e374d6f6136c44f8fca99876ca5488 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:26:51 +0530
Subject: [PATCH] * SrcRPMCheck.py: New file.
---
SrcRPMCheck.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100644 SrcRPMCheck.py
diff --git a/SrcRPMCheck.py b/SrcRPMCheck.py
new file mode 100644
index 0000000..691df8d
--- /dev/null
+++ b/SrcRPMCheck.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+#
+# Every srpm check file needs to inherit this class.
+#
+
+import Check
+
+
+class SrcRPMCheck(Check.Check):
+ """
+ Base class for all srpm checks.
+ """
+ srpm_check_names_seen = []
+ srpm_checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in SrcRPMCheck.srpm_check_names_seen:
+ SrcRPMCheck.srpm_checks.append(self)
+ SrcRPMCheck.srpm_check_names_seen.append(name)
+ self.name = name
+
+ def check(self, srpm):
+ """
+ Implemented by derived classes.
+ """
+ raise NotImplementedError('check must be implemented in subclass')
+
+
+# SrcRPMCheck ends here.
--
1.6.0.6
From f936f07c3241d0f56f089c18e32d72c55773c5ee Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:27:13 +0530
Subject: [PATCH] * RPMCheck.py: New file.
---
RPMCheck.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100644 RPMCheck.py
diff --git a/RPMCheck.py b/RPMCheck.py
new file mode 100644
index 0000000..eb6ca6a
--- /dev/null
+++ b/RPMCheck.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+#
+# Every rpm check file needs to inherit this class.
+#
+
+import Check
+
+
+class RPMCheck(Check.Check):
+ """
+ Base class for all rpm checks.
+ """
+ rpm_check_names_seen = []
+ rpm_checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in RPMCheck.rpm_check_names_seen:
+ RPMCheck.rpm_checks.append(self)
+ RPMCheck.rpm_check_names_seen.append(name)
+ self.name = name
+
+ def check(self, rpm):
+ """
+ Implemented by derived classes.
+ """
+ raise NotImplementedError('check must be implemented in subclass')
+
+
+# RPMCheck ends here.
--
1.6.0.6
From 1e8a8b0f4cbb790fe82809cb7b45c1a0419a6b0e Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:27:55 +0530
Subject: [PATCH] * RomReviewer.py: New file.
---
RomReviewer.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
create mode 100644 RomReviewer.py
diff --git a/RomReviewer.py b/RomReviewer.py
new file mode 100644
index 0000000..f379e7e
--- /dev/null
+++ b/RomReviewer.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+import sys
+import imp
+
+import Check
+
+
+def runRpmlint(self, reporter, *details):
+ """
+ Returns rpmlint messages on spec, srpm, rpm.
+ """
+ # Add -i once we implement config feature and have command
+ # line arguments, so that we can check verbose parameter.
+ rpmlint_args = ""
+ for items in details:
+ rpmlint_args += os.path.join(items.getFilePath(), \
+ items.getFileName()) + " "
+
+ rpmlint_message = os.popen("rpmlint " + rpmlint_args).read()
+
+ # Assuming same object is used for other reporting also.
+ reporter.printRpmLintMessages(rpmlint_message)
+ return
+
+
+class RomReviewer(object):
+ """
+ Reviewer interface. Part of functionality to be implemented by
+ derived class.
+ """
+
+ def __init__(self):
+ """
+ """
+ # Need to update it for each guideline.
+ self.default_guidelines = ("SampleCheck")
+
+ # Load all checks.
+ self.__loadChecks()
+
+ def __loadChecks(self):
+ """
+ Implements the loading module.
+ """
+ for name in self.default_guidelines:
+ try:
+ # Later on we need to generalize the second parameter
+ # depending on where guideline files go after installation.
+ (file, path, description) = imp.find_module(name, ".")
+ except ImportError:
+ print "Guideline import error: ", name
+ sys.exit(1)
+ imp.load_module(name, file, path, description)
+
+ def review(self, **details):
+ """
+ Implements the general checks which may use spec, rpm, srpm.
+
+ details: Dictionary has any number of Spec or Srpm or Rpm
+ obects.
+ """
+ for guide in Check.Check.checks:
+ guide.check(details)
+ return
+
+
+# RomReviewer ends here
--
1.6.0.6
From 954d2371e153f0794a9b6ed8e1bf44f562155ada Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:13 +0530
Subject: [PATCH] * RomSrcRPMReviewer.py: New file.
---
RomSrcRPMReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomSrcRPMReviewer.py
diff --git a/RomSrcRPMReviewer.py b/RomSrcRPMReviewer.py
new file mode 100644
index 0000000..1c00cba
--- /dev/null
+++ b/RomSrcRPMReviewer.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import RomReviewer
+import SrcRPMCheck
+
+
+class RomSrcRPMReviewer(RomReviewer.RomReviewer):
+ """
+ Implements Srource RPM reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, srpm):
+ """
+ Implements reviewer for srpm.
+ """
+ for guide in SrcRPMCheck.SrcRPMCheck.checks:
+ guide.check(srpm)
+ return
+
+
+# RomSrcRPMReviewer ends here
--
1.6.0.6
From cbdb0a7c602b02a6240b4852ee07fab459e49832 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:41 +0530
Subject: [PATCH] * RomSpecReviewer.py: New file.
---
RomSpecReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomSpecReviewer.py
diff --git a/RomSpecReviewer.py b/RomSpecReviewer.py
new file mode 100644
index 0000000..861de79
--- /dev/null
+++ b/RomSpecReviewer.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import RomReviewer
+import SpecCheck
+
+
+class RomSpecReviewer(RomReviewer.RomReviewer):
+ """
+ Implements spec reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, spec):
+ """
+ Implements spec review.
+ """
+ for guide in SpecCheck.SpecCheck.checks:
+ guide.check(spec)
+ return
+
+
+# RomSpecReviewer ends here
--
1.6.0.6
From 1df9e39b11b95d65143b926e0d8bd8eee34649a9 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:56 +0530
Subject: [PATCH] * RomRPMReviewer.py: New file.
---
RomRPMReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomRPMReviewer.py
diff --git a/RomRPMReviewer.py b/RomRPMReviewer.py
new file mode 100644
index 0000000..bc096e4
--- /dev/null
+++ b/RomRPMReviewer.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import Reviewer
+import RPMCheck
+
+
+class RomRPMReviewer(RomReviewer.RomReviewer):
+ """
+ Implements RPM reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, rpm):
+ """
+ Implements reviewer for rpm.
+ """
+ for guide in SrcRPMCheck.SrcRPMCheck.checks:
+ guide.check(rpm)
+ return
+
+
+# RomRPMReviewer ends here
--
1.6.0.6