## -*- coding: utf-8 -*-
##
## 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
## 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) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
##
<%!
import pkg.fmri
from six.moves.urllib.parse import quote
%>\
<%inherit file="layout.shtml"/>\
<%page args="g_vars"/>\
<%
catalog = g_vars["catalog"]
config = g_vars["config"]
request = g_vars["request"]
%>\
<%def name="page_title(g_vars)"><%
return "Package Catalog"
%></%def>\
<div id="yui-main">
<div class="yui-b">
% if config.mirror:
<p>Information about packages is not available when the server
is operating in mirror mode.</p>
% elif not request.publisher:
<p>This package repository is empty or no default publisher has
been set.</p>
% else:
<%
versions = self.shared.get_releases(g_vars)
if versions:
# Add an "All" selection so that user can view entire catalog.
versions.insert(0, ("", "", "All"))
selected_val = request.params.get("version", None)
show_all_versions = request.params.get("show_all_versions", None)
show_obsolete = request.params.get("show_obsolete", None)
show_renamed = request.params.get("show_renamed", None)
selected_match = None
selected_pkg = None
if selected_val:
for v in versions:
ver, val, label = v
if selected_val == val:
selected_match = ver
selected_pkg = val.split("@")[0]
break
if versions and selected_val != "" and not selected_match:
# Either a version wasn't already selected, or the version
# provided didn't match a valid one, so default to the first in
# the list.
selected_match = versions[1][0]
selected_val = versions[1][1]
selected_pkg = selected_val.split("@")[0]
%>
% if versions:
<form action="catalog.shtml">
<p>
<label for="version">Release and Branch</label>
<select id="version" name="version">
<%
for v in versions:
ver, val, label = v
attrs = ""
if val == selected_val:
attrs = 'selected="selected" '
context.write("""<option {0}value="{1}">{2}</option>""".format(
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/{0}".format(
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/{0}.p5i".format(
quote(pfmri.pkg_name, "")))
mhref = self.shared.rpath(g_vars,
"manifest/0/{0}".format(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:
% 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>