userland-mangler revision 1113
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Common Development and Distribution License (the "License").
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You may not use this file except in compliance with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# See the License for the specific language governing permissions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# and limitations under the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# When distributing Covered Code, include this CDDL HEADER in each
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# If applicable, add the following below this CDDL HEADER, with the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# fields enclosed by brackets "[]" replaced with your own identifying
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER END
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# userland-mangler - a file mangling utility
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# A simple program to mangle files to conform to Solaris WOS or Consoldation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# requirements.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe.\\\" Oracle has added the ARC stability level to this manual page"""
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe.SH ATTRIBUTES
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe.BR attributes (5)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowefor descriptions of the following attributes:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowecbp-1 | cbp-1
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweATTRIBUTE TYPE ATTRIBUTE VALUE """
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweAvailability %s"""
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweStability %s"""
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowedef attributes_section_text(availability, stability, modified_date):
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # is there anything to do?
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if availability is not None or stability is not None:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result += (attribute_table_availability % availability)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result += (attribute_table_stability % stability.capitalize())
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe.\\\" Oracle has added source availability information to this manual page"""
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweFurther information about this software can be found on the open source community website at %s.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweThis software was built from source available at http://opensolaris.org/. The original community source was downloaded from %s
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowedef notes_section_text(header_seen, community, source, modified_date):
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # is there anything to do?
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if community is not None or source is not None:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowesection_re = re.compile('\.SH "?([^"]+).*$', re.IGNORECASE)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# mangler.man.stability = (mangler.man.stability)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# mangler.man.modified_date = (mangler.man.modified-date)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # manpages must have a taxonomy defined
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe stability = action.attrs.pop('mangler.man.stability', None)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe sys.stderr.write("ERROR: manpage action missing mangler.man.stability: %s" % action)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # manpages may have a 'modified date'
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe modified_date = action.attrs.pop('mangler.man.modified-date', None)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe fmri = pkg.fmri.PkgFmri(manifest.attributes['pkg.fmri'])
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe community = manifest.attributes['info.upstream-url']
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe source = manifest.attributes['info.source-url']
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe elif 'info.repository-url' in manifest.attributes:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe source = manifest.attributes['info.repository-url']
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # skip reference only pages
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # tell man that we want tables (and eqn)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # write the orginal data
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result += attributes_section_text(availability, stability,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result += notes_section_text(notes_seen, community, source,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe strip_cddl = action.attrs.pop('mangler.strip_cddl', 'true')
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cddl_re = re.compile('^[^\n]*CDDL HEADER START.+CDDL HEADER END[^\n]*$',
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # a 'text' document (script, man page, config file, ...
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe # remove the CDDL from files
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result = mangle_manpage(manifest, action, result)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe elif 'mode' in action.attrs and int(action.attrs['mode'], 8) & 0111 != 0:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe result = mangle_script(manifest, action, result)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# mangler.bypass = (true|false)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowedef mangle_paths(manifest, search_paths, destination):
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for action in manifest.gen_actions_by_type("file"):
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe bypass = action.attrs.pop('mangler.bypass', 'false').lower()
return manifest
print "Usage: %s [-m|--manifest (file)] [-d|--search-directory (dir)] [-D|--destination (dir)] " % (sys.argv[0].split('/')[-1])
search_paths = []
manifests = []
try:
try:
print manifest