catalog.shtml revision 2958
520N/A## -*- coding: utf-8 -*-
520N/A##
520N/A## CDDL HEADER START
520N/A##
520N/A## The contents of this file are subject to the terms of the
520N/A## Common Development and Distribution License (the "License").
520N/A## You may not use this file except in compliance with the License.
520N/A##
520N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
520N/A## or http://www.opensolaris.org/os/licensing.
520N/A## See the License for the specific language governing permissions
520N/A## and limitations under the License.
520N/A##
520N/A## When distributing Covered Code, include this CDDL HEADER in each
520N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
520N/A## If applicable, add the following below this CDDL HEADER, with the
520N/A## fields enclosed by brackets "[]" replaced with your own identifying
520N/A## information: Portions Copyright [yyyy] [name of copyright owner]
520N/A##
520N/A## CDDL HEADER END
520N/A##
520N/A## Copyright 2009, 2013 Oracle and/or its affiliates. All rights reserved.
520N/A##
520N/A<%!
520N/A import pkg.fmri
520N/A import urllib
520N/A%>\
520N/A<%inherit file="layout.shtml"/>\
520N/A<%page args="g_vars"/>\
520N/A<%
520N/A catalog = g_vars["catalog"]
520N/A config = g_vars["config"]
520N/A request = g_vars["request"]
520N/A%>\
520N/A<%def name="page_title(g_vars)"><%
520N/A return "Package Catalog"
520N/A%></%def>\
520N/A<div id="yui-main">
520N/A <div class="yui-b">
520N/A% if config.mirror:
520N/A <p>Information about packages is not available when the server
520N/A is operating in mirror mode.</p>
520N/A% elif not request.publisher:
520N/A <p>This package repository is empty or no default publisher has
520N/A been set.</p>
520N/A% else:
520N/A<%
520N/A versions = self.shared.get_releases(g_vars)
520N/A if versions:
520N/A # Add an "All" selection so that user can view entire catalog.
520N/A versions.insert(0, ("", "", "All"))
520N/A
520N/A selected_val = request.params.get("version", None)
520N/A show_all_versions = request.params.get("show_all_versions", None)
520N/A show_obsolete = request.params.get("show_obsolete", None)
520N/A show_renamed = request.params.get("show_renamed", None)
520N/A selected_match = None
520N/A selected_pkg = None
520N/A if selected_val:
520N/A for v in versions:
520N/A ver, val, label = v
520N/A if selected_val == val:
520N/A selected_match = ver
520N/A selected_pkg = val.split("@")[0]
520N/A break
520N/A
520N/A if versions and selected_val != "" and not selected_match:
520N/A # Either a version wasn't already selected, or the version
520N/A # provided didn't match a valid one, so default to the first in
520N/A # the list.
520N/A selected_match = versions[1][0]
520N/A selected_val = versions[1][1]
520N/A selected_pkg = selected_val.split("@")[0]
520N/A%>
520N/A% if versions:
520N/A <form action="catalog.shtml">
520N/A <p>
520N/A <label for="version">Release and Branch</label>
520N/A <select id="version" name="version">
520N/A<%
520N/A for v in versions:
520N/A ver, val, label = v
520N/A attrs = ""
520N/A if val == selected_val:
520N/A attrs = 'selected="selected" '
context.write("""<option %svalue="%s">%s</option>""" % (
attrs, val, label))
%>
</select>
<input id="submit-browse" type="submit"
name="action" value="Browse"/>
</p>
<p>
<input id="show-all-versions" type="checkbox"
% if show_all_versions:
checked="checked"
% endif
name="show_all_versions" value="1"/>
<label for="show-all-versions" title="By
default, only the latest versions of packages are shown. To show all versions,
check this checkbox.">Show all versions</label>
<input id="show-obsolete" type="checkbox"
% if show_obsolete:
checked="checked"
% endif
name="show_obsolete" value="1"/>
<label for="show-obsolete" title="By
default, obsolete packages are not shown. To show obsolete
packages, check this checkbox.">Show obsolete packages</label>
<input id="show-renamed" type="checkbox"
% if show_renamed:
checked="checked"
% endif
name="show_renamed" value="1"/>
<label for="show-renamed" title="By
default, renamed packages are not shown. To show renamed
packages, check this checkbox.">Show renamed packages</label>
</p>
</form>
% else:
<form action="catalog.shtml">
<p>
<input id="show-all-versions" type="checkbox"
% if show_all_versions:
checked="checked"
% endif
name="show_all_versions" value="1"/>
<label for="show-all-versions" title="By
default, only the latest versions of packages are shown. To show all versions,
check this checkbox and click Refresh.">Show all versions</label>
<input id="show-obsolete" type="checkbox"
% if show_obsolete:
checked="checked"
% endif
name="show_obsolete" value="1"/>
<label for="show-obsolete" title="By
default, obsolete packages are not shown. To show obsolete
packages, check this checkbox.">Show obsolete packages</label>
<input id="show-renamed" type="checkbox"
% if show_renamed:
checked="checked"
% endif
name="show_renamed" value="1"/>
<label for="show-renamed" title="By
default, renamed packages are not shown. To show renamed
packages, check this checkbox.">Show renamed packages</label>
<input id="submit-browse" type="submit"
name="action" value="Refresh"/>
</p>
</form>
% endif
</div>
<div class="yui-b results">
<table summary="A list of packages available in the repository
restricted by the specified listing criteria.">
<tr class="first">
<th scope="row">Name</th>
<th>Version</th>
<th>Install</th>
<th>Manifest</th>
</tr>
<%
# Output each FMRI that we have in the catalog.
flist = []
if selected_val and selected_match:
ver = selected_match
pfmri = pkg.fmri.PkgFmri(name=selected_pkg,
publisher=request.publisher.prefix,
version=str(ver))
flist = catalog.gen_allowed_packages([pfmri])
else:
# Entries need to be in descending version order.
flist = (
(pfmri, states)
for (pfmri, states, attrs) in catalog.gen_packages(
return_fmris=True)
)
found = set()
omit_stems = set()
rclass = None
total = 0
%>
% for pfmri, states in flist:
<%
pkg_name = pfmri.pkg_name
if not show_all_versions and pkg_name in found:
continue
# For renames and obsoletes, only use package state for the
# latest version.
if states:
# The pkg_name should only be added to the list of stems
# to omit if the latest version of the package listed is
# renamed or obsolete. If not all versions are being
# shown, then this is the latest version.
if not (show_renamed or show_obsolete):
# Only possible states are OBSOLETE or RENAMED.
if not show_all_versions or \
pkg_name not in found:
omit_stems.add(pkg_name)
found.add(pkg_name)
continue
if not show_obsolete and \
catalog.PKG_STATE_OBSOLETE in states:
if not show_all_versions or \
pkg_name not in found:
omit_stems.add(pkg_name)
found.add(pkg_name)
continue
if not show_renamed and \
catalog.PKG_STATE_RENAMED in states:
if not show_all_versions or \
pkg_name not in found:
omit_stems.add(pkg_name)
found.add(pkg_name)
continue
if show_all_versions and pkg_name in omit_stems:
# Terminal version found that is allowed by selected
# filter criteria; so omit all versions of that package.
continue
found.add(pkg_name)
total += 1
if rclass is None or rclass == ' class="odd"':
rclass = ""
else:
rclass = ' class="odd"'
# Start FMRI entry
phref = self.shared.rpath(g_vars, "info/0/%s" % (
urllib.quote(str(pfmri), "")))
# XXX the .p5i extension is a bogus hack because
# packagemanager requires it and shouldn't.
p5ihref = self.shared.rpath(g_vars, "p5i/0/%s.p5i" % (
urllib.quote(pfmri.pkg_name, "")))
mhref = self.shared.rpath(g_vars,
"manifest/0/%s" % (pfmri.get_url_path()))
%>
<tr${rclass}>
<td scope="row">
<a title="Package Information Summary"
href="${phref}">${pfmri.pkg_name}</a>
</td>
<td>${pfmri.version.get_version(include_build=False)}</td>
<td>
% if not show_obsolete or catalog.PKG_STATE_OBSOLETE not in states:
<a class="p5i"
title="Launch the Package Manager and install this package"
href="${p5ihref}">Install</a>
% else:
&nbsp;
% endif
</td>
<td>
<a title="Package Manifest"
href="${mhref}">Manifest</a>
</td>
</tr>
% endfor
<tr class="last">
<td colspan="4" scope="row">${total} package(s)</td>
</tr>
</table>
% endif
</div>
</div>