#!/usr/bin/python2.6
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
#
# OSNet-specific pkglint(1) checks, called as part of pkglint commands in
# usr/src/pkg/Makefile, with settings in usr/src/pkg/*pkglintrc.
#
import pkg.lint.base as base
class OSNetActionChecker(base.ActionChecker):
"""An osnet-specific class to check actions."""
name = "osnet.action"
def __init__(self, config):
self.description = _(
"checks OS Net packages for common action errors")
super(OSNetActionChecker, self).__init__(config)
def varmigrate(self, action, manifest, engine, pkglint_id="001"):
"""Check that we only deliver directories to /var/.migrate.
During filesystem/minimal, a script runs to migrate unpackaged
content from /var/.migrate to the newly mounted /var/share
dataset.
Directories are created if necessary under /var/share, but files
are moved. If packaged objects were delivered under
/var/.migrate then subsequently migrated, they would cause
'pkg verify/fix' errors in the image.
Ensure /var/.migrate entries that have a salvage-from attribute
also have an actuator (needed for self-assembly of ROZR zones
in particular)
"""
if "path" not in action.attrs:
return
path = action.attrs["path"]
if not path.startswith("var/.migrate"):
return
if action.name != "dir":
engine.error(_("Non-directory %(path)s cannot be "
"delivered to /var/.migrate by %(pkg)s") %
{"path": path, "pkg": manifest.fmri},
msgid="%s%s.1" % (self.name, pkglint_id))
seen_salvage_from = action.attrs.get("salvage-from")
seen_actuator = action.attrs.get("reboot-needed")
if seen_actuator and seen_actuator.lower() != "true":
seen_actuator = False
if seen_salvage_from and not seen_actuator:
engine.error(_("/var/.migrate action %(path)s must "
"have a reboot-needed actuator when 'salvage-from'"
" is set in %(pkg)s") %
{"path": path, "pkg": manifest.fmri},
msgid="%s%s.2" % (self.name, pkglint_id))
varmigrate.pkglint_desc = _(
"Only directories should be delivered to /var/.migrate")
def varshare(self, action, manifest, engine, pkglint_id="002"):
"""Ensure that we deliver nothing underneath /var/share.
During upgrade, from a system without an <rpool>/VARSHARE
dataset, we create that dataset and mount it there - a populated
mountpoint would foil our plans.
With a mounted /var/share, since the dataset is shared across
boot environments, we can't risk packaging operations from two
separate boot environments trying to modify content in
/var/share.
"""
if "path" not in action.attrs:
return
path = action.attrs["path"]
if path.rstrip("/").startswith("var/share/"):
engine.error(_("Path %(path)s cannot be delivered by "
"%(pkg)s, reserved for unpackaged content shared "
"across boot environments.") %
{"path": path, "pkg": manifest.fmri},
msgid="%s%s" % (self.name, pkglint_id))
varshare.pkglint_desc = _(
"Packages should not deliver content beneath /var/share.")