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