Bug 170118 - [patch] Add pkgng Support to sysutils/bsdstats
Summary: [patch] Add pkgng Support to sysutils/bsdstats
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Michael Scheidell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-24 21:00 UTC by A.J. Kehoe IV (Nanoman)
Modified: 2012-07-28 13:30 UTC (History)
0 users

See Also:


Attachments
file.diff (2.49 KB, patch)
2012-07-24 21:00 UTC, A.J. Kehoe IV (Nanoman)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description A.J. Kehoe IV (Nanoman) 2012-07-24 21:00:26 UTC
The FreeBSD port sysutils/bsdstats supports pkg_* tools, but does not support pkgng.  pkgng will soon become the default package management system in FreeBSD, whereas pkg_* tools will soon become unsupported.

Thank you to Anton Shterenlikht for reporting this problem.

Fix: I've attached a patch for the port's files/300.statistics.in file.  The patch adds support for pkgng while preserving support for pkg_* tools.  The patch also includes instructions for removing pkg_* tools support when it's officially discontinued.

Patch attached with submission follows:
Comment 1 Michael Scheidell freebsd_committer freebsd_triage 2012-07-28 08:51:47 UTC
Responsible Changed
From-To: freebsd-ports-bugs->scheidell

I'll take it.
Comment 2 Michael Scheidell freebsd_committer freebsd_triage 2012-07-28 13:27:35 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 3 dfilter service freebsd_committer freebsd_triage 2012-07-28 13:28:01 UTC
Author: scheidell
Date: Sat Jul 28 12:27:28 2012
New Revision: 301654
URL: http://svn.freebsd.org/changeset/ports/301654

Log:
  - Add pkgng support
  
  PR:		ports/170118
  Submitted by:	bsdstats@nanoman.ca (maintainer)

Modified:
  head/sysutils/bsdstats/files/300.statistics.in
  head/sysutils/bsdstats/pkg-install

Modified: head/sysutils/bsdstats/files/300.statistics.in
==============================================================================
--- head/sysutils/bsdstats/files/300.statistics.in	Sat Jul 28 12:21:10 2012	(r301653)
+++ head/sysutils/bsdstats/files/300.statistics.in	Sat Jul 28 12:27:28 2012	(r301654)
@@ -100,13 +100,63 @@ send_devices () {
 send_ports () {
     case $(uname) in
 	FreeBSD )
-	    for line in `/usr/sbin/pkg_info | /usr/bin/awk '{print $1}' `
-	    do
-              category=`grep "@comment ORIGIN" /var/db/pkg/${line}/+CONTENTS | sed -E 's/^\@comment ORIGIN:(.+)\/.+/\1/g'`
-              line=$(uri_escape $line)
-              category=$(uri_escape $category)
-	      query_string=$query_string`echo \&port[]=${category}:${line}`
-	    done
+
+	############################################################################
+	# At the time of this writing (2012-07-24), FreeBSD is switching from
+	# pkg_* tools to pkgng.  Starting in FreeBSD 9.1, pkgng will become the
+	# default tool for package management.
+	#
+	# Until pkg_* tools are officially declared unsupported, they will need
+	# legacy support in ports like this one.  When the need for this support is
+	# officially discontinued, please do the following:
+	#
+	# 1. Delete the contents of this "LEGACY" section:
+	#
+	#-----BEGIN LEGACY-----
+	    # Detect pkgng
+	    if [ -e /var/db/pkg/local.sqlite ]; then
+
+	      # Use pkgng
+
+	      for line in `pkg info | awk '{ print $1 }'`
+	      do
+	        category=`pkg info -q -o ${line} | sed 's/\/.*//g'`
+	        line=$(uri_escape $line)
+	        category=$(uri_escape $category)
+	        query_string=$query_string`echo \&port[]=${category}:${line}`
+	      done
+
+	    else
+
+	      # Use pkg_* tools
+
+	      for line in `pkg_info | awk '{ print $1 }'`
+	      do
+	        category=`grep "@comment ORIGIN" /var/db/pkg/${line}/+CONTENTS | sed -E 's/^\@comment ORIGIN:(.+)\/.+/\1/g'`
+	        line=$(uri_escape $line)
+	        category=$(uri_escape $category)
+	        query_string=$query_string`echo \&port[]=${category}:${line}`
+	      done
+
+	    fi
+	#-----END LEGACY-----
+	#
+	# 2. Uncomment the contents of this "PKGNG" section:
+	#
+	#-----BEGIN PKGNG-----
+#	    for line in `pkg info | awk '{ print $1 }'`
+#	    do
+#	       category=`pkg info -q -o ${line} | sed 's/\/.*//g'`
+#	       line=$(uri_escape $line)
+#	       category=$(uri_escape $category)
+#	      query_string=$query_string`echo \&port[]=${category}:${line}`
+#	    done
+	#-----END PKGNG-----
+	#
+	# 3. Delete these comments.
+	#
+	# Thank you!
+	############################################################################
 
 	    report_ports
 	    ;;

Modified: head/sysutils/bsdstats/pkg-install
==============================================================================
--- head/sysutils/bsdstats/pkg-install	Sat Jul 28 12:21:10 2012	(r301653)
+++ head/sysutils/bsdstats/pkg-install	Sat Jul 28 12:27:28 2012	(r301654)
@@ -85,4 +85,3 @@ if [ "$2" = "POST-INSTALL" ]; then
         fi
     fi
 fi
-
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"