aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile14
-rw-r--r--debian/changelog5
-rw-r--r--debian/compat1
-rw-r--r--debian/control15
-rw-r--r--debian/copyright0
-rw-r--r--debian/pyversions1
-rwxr-xr-xdebian/rules7
-rw-r--r--sos/__init__.py.in (renamed from sos/__init__.py)0
-rw-r--r--sos/plugins/__init__.py8
-rw-r--r--sos/plugins/dpkg.py22
-rw-r--r--sos/policies/Makefile20
-rw-r--r--sos/policies/debian.py154
-rw-r--r--sos/policies/ubuntu.py31
13 files changed, 272 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 1e1b249a..b586ae47 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,9 @@
NAME = sos
VERSION = $(shell echo `awk '/^Version:/ {print $$2}' sos.spec`)
RELEASE = $(shell echo `awk '/^Release:/ {gsub(/\%.*/,""); print $2}' sos.spec`)
-REPO = http://svn.fedorahosted.org/svn/sos
+REPO = http://github.com/sosreport
-SUBDIRS = po sos sos/plugins
+SUBDIRS = po sos sos/plugins sos/policies
PYFILES = $(wildcard *.py)
# OS X via brew
# MSGCAT = /usr/local/Cellar/gettext/0.18.1.1/bin/msgcat
@@ -33,7 +33,7 @@ ZIP_DEST = $(SRC_BUILD)/$(ARCHIVE_NAME)
build:
for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1 ; done
-install:
+install: updateversion
mkdir -p $(DESTDIR)/usr/sbin
mkdir -p $(DESTDIR)/usr/share/man/man1
mkdir -p $(DESTDIR)/usr/share/man/man5
@@ -47,9 +47,11 @@ install:
install -m644 LICENSE README TODO $(DESTDIR)/usr/share/$(NAME)/.
install -m644 $(NAME).conf $(DESTDIR)/etc/$(NAME).conf
install -m644 gpgkeys/rhsupport.pub $(DESTDIR)/usr/share/$(NAME)/.
- sed 's/@SOSVERSION@/$(VERSION)/g' < sos/__init__.py > sos/__init__.py
for d in $(SUBDIRS); do make DESTDIR=`cd $(DESTDIR); pwd` -C $$d install; [ $$? = 0 ] || exit 1; done
+updateversion:
+ sed 's/@SOSVERSION@/$(VERSION)/g' sos/__init__.py.in > sos/__init__.py
+
$(NAME)-$(VERSION).tar.gz: clean gpgkey
@mkdir -p $(ARCHIVE_DIR)
@tar -cv sosreport sos doc man po sos.conf TODO LICENSE README sos.spec Makefile | tar -x -C $(ARCHIVE_DIR)
@@ -58,7 +60,7 @@ $(NAME)-$(VERSION).tar.gz: clean gpgkey
@tar Ccvzf $(RPM_BUILD_DIR) $(RPM_BUILD_DIR)/$(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)
clean:
- @rm -fv *~ .*~ changenew ChangeLog.old $(NAME)-$(VERSION).tar.gz sosreport.1.gz
+ @rm -fv *~ .*~ changenew ChangeLog.old $(NAME)-$(VERSION).tar.gz sosreport.1.gz sos.conf.5.gz
@rm -rf rpm-build
@for i in `find . -iname *.pyc`; do \
rm $$i; \
@@ -85,7 +87,7 @@ po: clean
cp $(PO_DIR)/sos_en.properties $(PO_DIR)/sos_en_US.properties
cp $(PO_DIR)/sos_en.properties $(PO_DIR)/sos.properties
-as7: po
+as7: po updateversion
cp -r sos/* $(SRC_BUILD)/sos/
find $(SRC_BUILD)/sos/plugins/ -not -name "*as7.py" -not -name "*__init__.py" -type f -delete
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 00000000..a788b652
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+sosreport (2.3) unstable; urgency=low
+
+ * Initial release.
+
+ -- Adam Stokes <adam.stokes@canonical.com> Mon, 20 Feb 2012 16:41:39 +0000
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 00000000..45a4fb75
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/debian/control b/debian/control
new file mode 100644
index 00000000..1625c69e
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: sosreport
+Maintainer: Adam Stokes <adam.stokes@canonical.com>
+Section: python
+Priority: optional
+Standards-Version: 3.9.2
+Build-Depends: debhelper (>= 8), python-support, python (>=2.7), gettext
+
+Package: sosreport
+Architecture: any
+Depends: ${python:Depends}, ${misc:Depends}
+Description: A set of tools to gather troubleshooting information from a system
+ Sos is a set of tools that gathers information about system
+ hardware and configuration. The information can then be used for
+ diagnostic purposes and debugging. Sos is commonly used to help
+ support technicians and developers.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/debian/copyright
diff --git a/debian/pyversions b/debian/pyversions
new file mode 100644
index 00000000..3ad2293e
--- /dev/null
+++ b/debian/pyversions
@@ -0,0 +1 @@
+2.7-
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 00000000..3e0dfd04
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+
+DH_ALWAYS_EXCLUDE=.git
+
+%:
+ dh $@
+
diff --git a/sos/__init__.py b/sos/__init__.py.in
index f703a834..f703a834 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py.in
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 576196de..a1d38f45 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -610,6 +610,14 @@ class RedHatPlugin(object):
"""Tagging class to indicate that this plugin works with Red Hat Linux"""
pass
+class UbuntuPlugin(object):
+ """Tagging class to indicate that this plugin works with Ubuntu Linux"""
+ pass
+
+class DebianPlugin(object):
+ """Tagging class to indicate that this plugin works with Debian Linux"""
+ pass
+
class IndependentPlugin(object):
"""Tagging class that indicates this plugin can run on any platform"""
pass
diff --git a/sos/plugins/dpkg.py b/sos/plugins/dpkg.py
new file mode 100644
index 00000000..47c2c9e4
--- /dev/null
+++ b/sos/plugins/dpkg.py
@@ -0,0 +1,22 @@
+### 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 this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from sos.plugins import Plugin, DebianPlugin, UbuntuPlugin
+
+class dpkg(Plugin, DebianPlugin, UbuntuPlugin):
+ """dpkg information
+ """
+ def setup(self):
+ self.addCopySpec("/var/log/dpkg.log")
+ self.collectExtOutput("/usr/bin/dpkg-query -W -f='${Package}-${Version}-${Architecture}\n' \*", root_symlink = "installed-debs")
diff --git a/sos/policies/Makefile b/sos/policies/Makefile
new file mode 100644
index 00000000..8fd6a1bf
--- /dev/null
+++ b/sos/policies/Makefile
@@ -0,0 +1,20 @@
+PYTHON=python
+PACKAGE = $(shell basename `pwd`)
+PYFILES = $(wildcard *.py)
+PYVER := $(shell $(PYTHON) -c 'import sys; print "%.3s" %(sys.version)')
+PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print sys.prefix')
+PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
+PKGDIR = $(PYLIBDIR)/site-packages/sos/$(PACKAGE)
+
+all:
+ echo "nada"
+
+clean:
+ rm -f *.pyc *.pyo *~
+
+install:
+ mkdir -p $(DESTDIR)/$(PKGDIR)
+ for p in $(PYFILES) ; do \
+ install -m 755 $$p $(DESTDIR)/$(PKGDIR)/$$p; \
+ done
+ $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(PKGDIR)', 1, '$(PYDIR)', 1)"
diff --git a/sos/policies/debian.py b/sos/policies/debian.py
new file mode 100644
index 00000000..77a5487c
--- /dev/null
+++ b/sos/policies/debian.py
@@ -0,0 +1,154 @@
+from sos import _sos as _
+from sos.plugins import DebianPlugin, IndependentPlugin
+from sos.policies import PackageManager, Policy
+from sos.utilities import shell_out
+
+import os
+import sys
+import re
+
+class DebianPackageManager(PackageManager):
+
+ def _get_deb_list(self):
+ pkg_list = shell_out(["dpkg-query",
+ "-W",
+ "-f=",
+ "'${Package}|${Version}\\n' \*"]).splitlines()
+ self._debs = {}
+ for pkg in pkg_list:
+ name, version = pkg.split("|")
+ self._debs[name] = {
+ 'name': name,
+ 'version': version
+ }
+
+ def allPkgsByName(self, name):
+ return fnmatch.filter(self.allPkgs().keys(), name)
+
+ def allPkgsByNameRegex(self, regex_name, flags=None):
+ reg = re.compile(regex_name, flags)
+ return [pkg for pkg in self.allPkgs().keys() if reg.match(pkg)]
+
+ def pkgByName(self, name):
+ try:
+ self.AllPkgsByName(name)[-1]
+ except Exception:
+ return None
+
+ def allPkgs(self):
+ if not self._debs:
+ self._debs = self._get_deb_list()
+ return self._debs
+
+ def pkgNVRA(self, pkg):
+ fields = pkg.split("-")
+ version, release, arch = fields[-3:]
+ name = "-".join(fields[:-3])
+ return (name, version, release, arch)
+
+class DebianPolicy(Policy):
+ def __init__(self):
+ super(DebianPolicy, self).__init__()
+ self.reportName = ""
+ self.ticketNumber = ""
+ self.package_manager = DebianPackageManager()
+
+ def validatePlugin(self, plugin_class):
+ "Checks that the plugin will execute given the environment"
+ return issubclass(plugin_class, DebianPlugin) or issubclass(plugin_class, IndependentPlugin)
+
+ @classmethod
+ def check(self):
+ """This method checks to see if we are running on Debian.
+ It returns True or False."""
+ if os.path.isfile('/etc/debian_version'):
+ return True
+ return False
+
+ def preferedArchive(self):
+ from sos.utilities import TarFileArchive
+ return TarFileArchive
+
+ def getPreferredHashAlgorithm(self):
+ checksum = "md5"
+ try:
+ fp = open("/proc/sys/crypto/fips_enabled", "r")
+ except:
+ return checksum
+
+ fips_enabled = fp.read()
+ if fips_enabled.find("1") >= 0:
+ checksum = "sha256"
+ fp.close()
+ return checksum
+
+ def pkgByName(self, name):
+ return self.package_manager.pkgByName(name)
+
+ def runlevelDefault(self):
+ try:
+ with open("/etc/inittab") as fp:
+ pattern = r"id:(\d{1}):initdefault:"
+ text = fp.read()
+ return int(re.findall(pattern, text)[0])
+ except:
+ return 3
+
+ def kernelVersion(self):
+ return self.release
+
+ def hostName(self):
+ return self.hostname
+
+ def debianVersion(self):
+ try:
+ fp = open("/etc/debian_version").read()
+ if "wheezy/sid" in fp:
+ return 6
+ fp.close()
+ except:
+ pass
+ return False
+
+ def isKernelSMP(self):
+ return self.smp
+
+ def getArch(self):
+ return self.machine
+
+ def preWork(self):
+ # this method will be called before the gathering begins
+
+ localname = self.hostName()
+
+ if not self.commons['cmdlineopts'].batch and not self.commons['cmdlineopts'].silent:
+ try:
+ self.reportName = raw_input(_("Please enter your first initial and last name [%s]: ") % localname)
+ self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName)
+
+ self.ticketNumber = raw_input(_("Please enter the case number that you are generating this report for: "))
+ self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)
+ self._print()
+ except:
+ self._print()
+ sys.exit(0)
+
+ if len(self.reportName) == 0:
+ self.reportName = localname
+
+ if self.commons['cmdlineopts'].customerName:
+ self.reportName = self.commons['cmdlineopts'].customerName
+ self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName)
+
+ if self.commons['cmdlineopts'].ticketNumber:
+ self.ticketNumber = self.commons['cmdlineopts'].ticketNumber
+ self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)
+
+ return
+
+ def packageResults(self, archive_filename):
+ self._print(_("Creating compressed archive..."))
+
+ def get_msg(self):
+ msg_dict = {"distro": "Debian"}
+ return self.msg % msg_dict
diff --git a/sos/policies/ubuntu.py b/sos/policies/ubuntu.py
new file mode 100644
index 00000000..d0ecae0f
--- /dev/null
+++ b/sos/policies/ubuntu.py
@@ -0,0 +1,31 @@
+from sos import _sos as _
+from sos.plugins import UbuntuPlugin, IndependentPlugin
+from sos.policies.debian import DebianPolicy, DebianPackageManager
+from sos.utilities import shell_out
+from __future__ import with_statement
+
+import os
+
+class UbuntuPolicy(DebianPolicy):
+ def __init__(self):
+ super(UbuntuPolicy, self).__init__()
+
+ def validatePlugin(self, plugin_class):
+ "Checks that the plugin will execute given the environment"
+ return issubclass(plugin_class, UbuntuPlugin) or issubclass(plugin_class, IndependentPlugin)
+
+ @classmethod
+ def check(self):
+ """This method checks to see if we are running on Ubuntu.
+ It returns True or False."""
+ if os.path.isfile('/etc/lsb-release'):
+ try:
+ with open('/etc/lsb-release', 'r') as fp:
+ return "Ubuntu" in fp.read()
+ except:
+ return False
+ return False
+
+ def get_msg(self):
+ msg_dict = {"distro": "Ubuntu"}
+ return self.msg % msg_dict