java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java | 16 ++ java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 6 java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java | 62 ++++++++++ java/code/webapp/WEB-INF/pages/rhnpackage/packagedetail.jsp | 34 +++++ 4 files changed, 118 insertions(+)
New commits: commit 4dac61ce519fcca50b7cd08b4293527ddc111bc3 Author: Justin Sherrill jsherril@redhat.com Date: Wed Sep 1 16:38:21 2010 -0400
616570 - adding support for looking up debuginfo rpms if they are located on the satellite itself
diff --git a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java index c7781e3..04b06b5 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/PackageDetailsAction.java @@ -89,6 +89,22 @@ public class PackageDetailsAction extends RhnAction { request.setAttribute(PACKAGE_KEY, pkg.getPackageKeys().iterator().next().getKey()); } + boolean isDebug = pkg.getPackageName().getName().contains("debuginfo"); + + request.setAttribute("isDebuginfo", isDebug); + if (!isDebug) { + Package debugPkg = PackageManager.findDebugInfo(user, pkg); + String ftpUrl = PackageManager.generateFtpDebugPath(pkg); + if (debugPkg == null && ftpUrl != null) { + request.setAttribute("debugUrl", ftpUrl); + request.setAttribute("debugFtp", true); + } + else { + request.setAttribute("debugUrl", + DownloadManager.getPackageDownloadPath(debugPkg, user)); + } + } + }
if (DownloadManager.isFileAvailable(pkg.getPath())) { diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index 9403f52..b659fc3 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -22495,6 +22495,12 @@ given channel.</source> <trans-unit id="schedule.monthly.day"> <source>Day</source> </trans-unit> + <trans-unit id="debuginfo.header"> + <source>DebugInfo Package</source> + </trans-unit> + <trans-unit id="debuginfo.external"> + <source>Note: A local debuginfo rpm could not be found. The above links to an external FTP server and may not be valid.</source> + </trans-unit>
</body> </file> diff --git a/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java b/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java index 5654470..ce11de0 100644 --- a/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java +++ b/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java @@ -14,6 +14,7 @@ */ package com.redhat.rhn.manager.rhnpackage;
+import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.db.datasource.ModeFactory; @@ -24,10 +25,12 @@ import com.redhat.rhn.common.security.PermissionException; import com.redhat.rhn.common.util.CompressionUtil; import com.redhat.rhn.common.util.RpmVersionComparator; import com.redhat.rhn.domain.channel.Channel; +import com.redhat.rhn.domain.channel.DistChannelMap; import com.redhat.rhn.domain.errata.Errata; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.org.OrgFactory; import com.redhat.rhn.domain.rhnpackage.Package; +import com.redhat.rhn.domain.rhnpackage.PackageArch; import com.redhat.rhn.domain.rhnpackage.PackageEvr; import com.redhat.rhn.domain.rhnpackage.PackageEvrFactory; import com.redhat.rhn.domain.rhnpackage.PackageFactory; @@ -1398,4 +1401,63 @@ public class PackageManager extends BaseManager { DataResult result = m.execute(params); return result; } + + /** + * Find a debuginfo package for a given package + * @param user The User doing the search + * @param pack the package we need a debug info for + * @return The Package object that is debug info, or null if not found + */ + public static Package findDebugInfo(User user, Package pack) { + PackageEvr evr = pack.getPackageEvr(); + String name = pack.getPackageName().getName() + "-debuginfo"; + List<Package> list = PackageFactory.lookupByNevra(user.getOrg(), + name, evr.getVersion(), evr.getRelease(), null, pack.getPackageArch()); + if (list.isEmpty()) { + return null; + } + else { + return list.get(0); + } + } + + + private static String getAssociatedRelease(Package pack) { + for (Channel chan : pack.getChannels()) { + for (DistChannelMap map : chan.getDistChannelMaps()) { + return map.getRelease(); + } + } + return null; + } + + /** + * Guess the package URL for a debugInfo rpm + * @param pack the package to guess a debugInfo rpm url for + * @return the url + */ + public static String generateFtpDebugPath(Package pack) { + + String release = getAssociatedRelease(pack); + if (release == null) { + return null; + } + + + PackageEvr evr = pack.getPackageEvr(); + PackageArch arch = pack.getPackageArch(); + String ftpMachine = Config.get().getString("ftp_server", "ftp.redhat.com"); + String dbgFilename = pack.getPackageName().getName() + + "-debuginfo-" + + evr.getVersion() + "-" + + evr.getRelease() + "." + + arch.getLabel() + "." + + arch.getArchType().getLabel(); + + return "ftp://" + ftpMachine + "/pub/redhat/linux/enterprise/" + + release + "/en/os/" + + arch.getLabel() + "/Debuginfo/" + dbgFilename; + } + + } diff --git a/java/code/webapp/WEB-INF/pages/rhnpackage/packagedetail.jsp b/java/code/webapp/WEB-INF/pages/rhnpackage/packagedetail.jsp index 7853d50..ee1a8ad 100644 --- a/java/code/webapp/WEB-INF/pages/rhnpackage/packagedetail.jsp +++ b/java/code/webapp/WEB-INF/pages/rhnpackage/packagedetail.jsp @@ -169,6 +169,9 @@ <th><bean:message key="package.jsp.rpmversion"/>:</th> <td><c:out value="${pack.rpmVersion}" /> </td> </tr> + + + </rhn:require>
<tr> @@ -204,6 +207,37 @@ </tr>
+ <rhn:require acl="package_type_capable(rpm)" + mixins="com.redhat.rhn.common.security.acl.PackageAclHandler"> + + <c:if test="${not isDebuginfo}" > + <tr> + <th> + <bean:message key="debuginfo.header" />: + </th> + <td> + + <c:if test="${debugUrl != null}"> + <a href="${debugUrl}"><bean:message key="package.jsp.download"/></a> + <c:if test="${debugFtp}" > + <br> + <span class="small-text"> + <bean:message key="debuginfo.external" /> + </span> + </c:if> + </c:if> + <c:if test="${debugUrl == null}"> + <div style="font-weight: bold;"> + <bean:message key="package.jsp.unavailable" /> + </div> + </c:if> + </td> + </tr> + </c:if> + </rhn:require> + + + </div>
</body>
spacewalk-commits@lists.fedorahosted.org