~ubuntu-branches/ubuntu/natty/computer-janitor/natty

« back to all changes in this revision

Viewing changes to plugins/add_nfs_common_plugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Lars Wirzenius
  • Date: 2009-02-19 09:37:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090219093752-4e3rkcoatpr4x2u8
Tags: 1.12-0ubuntu1
* New upstream release.
* Upstream source has partially been moved to update-manager. This
  has resulted in some packaging changes.
* debian/control: Add dependency on update-manager-core for 
  computer-janitor, on the version of update-manager-core that includes
  the computer-janitor core code (plugin management, plugins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# add_nfs_common_plugin.py - install nfs-common if nfs is used
 
2
# Copyright (C) 2009  Canonical, Ltd.
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, version 3 of the License.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
 
 
17
import grp
 
18
import logging
 
19
import os
 
20
import subprocess
 
21
 
 
22
import computerjanitor
 
23
_ = computerjanitor.setup_gettext()
 
24
 
 
25
 
 
26
class AddNfsCommonPlugin(computerjanitor.Plugin):
 
27
 
 
28
    """Plugin to install missing nfs-common package, if nfs is being used.
 
29
    
 
30
    This is a fix for the feisty->gutsy transition of utils-linux to
 
31
    nfs-common. See also LP: #141559.
 
32
    
 
33
    """
 
34
 
 
35
    description = _("NFS is being used, so the nfs-common package needs "
 
36
                    "to be installed.")
 
37
 
 
38
    def get_cruft(self):
 
39
        if "nfs-common" not in self.app.apt_cache:
 
40
            logging.warning("nfs-common package not available")
 
41
            return
 
42
        pkg = self.app.apt_cache["nfs-common"]
 
43
        try:
 
44
            for line in map(string.strip, open("/proc/mounts")):
 
45
                if line == '' or line.startswith("#"):
 
46
                    continue
 
47
                try:
 
48
                    (device, mount_point, fstype, options, a, b) = line.split()
 
49
                except Exception, e:
 
50
                    logging.error("can't parse line '%s'" % line)
 
51
                    continue
 
52
                if "nfs" in fstype and not pkg.isInstalled:
 
53
                    logging.debug("found nfs mount in line '%s', "
 
54
                                  "marking nfs-common for install " % line)
 
55
                    yield computerjanitor.MissingPackageCruft(pkg)
 
56
                    break
 
57
        except Exception, e:
 
58
            logging.warning("problem while transitioning "
 
59
                            "util-linux -> nfs-common (%s)" % e)