## -*- coding: utf-8 -*-
##
##
## Copyright 2009, 2013 Oracle and/or its affiliates. All rights reserved.
##
<%!
import pkg.fmri
import urllib
%>\
<%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>\
% if config.mirror:
Information about packages is not available when the server
is operating in mirror mode.
% elif not request.publisher:
This package repository is empty or no default publisher has
been set.
% 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:
% else:
% endif
| Name |
Version |
Install |
Manifest |
<%
# 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()))
%>
|
${pfmri.pkg_name}
|
${pfmri.version} |
% if not show_obsolete or catalog.PKG_STATE_OBSOLETE not in states:
Install
% else:
% endif
|
Manifest
|
% endfor
| ${total} package(s) |
% endif