From luca@morettoni.net  Fri Sep  2 06:50:35 2005
Return-Path: <luca@morettoni.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 81CA216A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  2 Sep 2005 06:50:35 +0000 (GMT)
	(envelope-from luca@morettoni.net)
Received: from smtp20.libero.it (smtp20.libero.it [193.70.192.147])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1F51D43D46
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  2 Sep 2005 06:50:34 +0000 (GMT)
	(envelope-from luca@morettoni.net)
Received: from current.morettoni.local (151.38.48.209) by smtp20.libero.it (7.0.027-DD01)
        id 42F2CBAB006E71E7 for FreeBSD-gnats-submit@freebsd.org; Fri, 2 Sep 2005 08:50:33 +0200
Received: (qmail 81915 invoked by uid 0); 2 Sep 2005 06:51:18 -0000
Message-Id: <20050902065118.81914.qmail@current.morettoni.local>
Date: 2 Sep 2005 06:51:18 -0000
From: Luca Morettoni <luca@morettoni.net>
Reply-To: Luca Morettoni <luca@morettoni.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: cperciva@FreeBSD.org
Subject: [patch] allow portsnap to refuse ports categories
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         85619
>Category:       bin
>Synopsis:       [patch] allow portsnap to refuse ports categories
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cperciva
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 02 07:00:32 GMT 2005
>Closed-Date:    Wed Sep 07 12:05:32 GMT 2005
>Last-Modified:  Wed Sep 07 12:05:32 GMT 2005
>Originator:     Luca Morettoni
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD current.morettoni.local 7.0-CURRENT FreeBSD 7.0-CURRENT #289: Mon Aug 22 13:34:21 CEST 2005 luca@current.morettoni.local:/usr/obj/usr/src/sys/FRODO i386


	
>Description:
	With this patch you can "refuse" one or more directory (categories) in
	ports three. Now you can add, into portsnap.conf, a line like this:
	REFUSE="games cad"
	In "extract" command listed directory are skipped.
	In "update" command listed directory are deleted and new (or
	updated) files inside that are ignored.
>How-To-Repeat:
	
>Fix:

	Apply this patch (into src/usr.sbin/portsnap/portsnap/):

--- portsnap.sh-refuse.patch begins here ---
*** portsnap.sh-orig	Fri Sep  2 08:32:08 2005
--- portsnap.sh	Fri Sep  2 08:32:17 2005
***************
*** 81,86 ****
--- 81,87 ----
  	DDSTATS=""
  	INDEXONLY=""
  	SERVERNAME=""
+ 	REFUSE=""
  }
  
  # Parse the command line
***************
*** 170,181 ****
  	fi
  }
  
! # Read {KEYPRINT, SERVERNAME, WORKDIR, PORTSDIR} from the configuration
  # file if they haven't already been set.  If the configuration
  # file doesn't exist, do nothing.
  parse_conffile() {
  	if [ -r "${CONFFILE}" ]; then
! 		for X in KEYPRINT WORKDIR PORTSDIR SERVERNAME; do
  			eval _=\$${X}
  			if [ -z "${_}" ]; then
  				eval ${X}=`grep "^${X}=" "${CONFFILE}" |
--- 171,182 ----
  	fi
  }
  
! # Read {KEYPRINT, SERVERNAME, WORKDIR, PORTSDIR, REFUSE} from the configuration
  # file if they haven't already been set.  If the configuration
  # file doesn't exist, do nothing.
  parse_conffile() {
  	if [ -r "${CONFFILE}" ]; then
! 		for X in KEYPRINT WORKDIR PORTSDIR SERVERNAME REFUSE; do
  			eval _=\$${X}
  			if [ -z "${_}" ]; then
  				eval ${X}=`grep "^${X}=" "${CONFFILE}" |
***************
*** 193,199 ****
  	_WORKDIR="/var/db/portsnap"
  	_PORTSDIR="/usr/ports"
  	_NDEBUG="-n"
! 	for X in QUIETREDIR QUIETFLAG STATSREDIR WORKDIR PORTSDIR NDEBUG; do
  		eval _=\$${X}
  		eval __=\$_${X}
  		if [ -z "${_}" ]; then
--- 194,201 ----
  	_WORKDIR="/var/db/portsnap"
  	_PORTSDIR="/usr/ports"
  	_NDEBUG="-n"
! 	_REFUSE=""
! 	for X in QUIETREDIR QUIETFLAG STATSREDIR WORKDIR PORTSDIR NDEBUG REFUSE; do
  		eval _=\$${X}
  		eval __=\$_${X}
  		if [ -z "${_}" ]; then
***************
*** 771,776 ****
--- 773,780 ----
  	if ! grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX | while read LINE; do
  		FILE=`echo ${LINE} | cut -f 1 -d '|'`
  		HASH=`echo ${LINE} | cut -f 2 -d '|'`
+ 		# skip refused ports categories
+ 		echo ${REFUSE:-} | grep -q "${FILE%%/*}" && continue
  		echo ${PORTSDIR}/${FILE}
  		if ! [ -r "${WORKDIR}/files/${HASH}.gz" ]; then
  			echo "files/${HASH}.gz not found -- snapshot corrupt."
***************
*** 779,784 ****
--- 783,789 ----
  		case ${FILE} in
  		*/)
  			rm -rf ${PORTSDIR}/${FILE}
+ 
  			mkdir -p ${PORTSDIR}/${FILE}
  			tar -xzf ${WORKDIR}/files/${HASH}.gz	\
  			    -C ${PORTSDIR}/${FILE}
***************
*** 816,821 ****
--- 821,829 ----
  	echo -n "Removing old files and directories... "
  	sort ${WORKDIR}/INDEX | comm -23 ${PORTSDIR}/.portsnap.INDEX - |
  	    cut -f 1 -d '|' | lam -s "${PORTSDIR}/" - | xargs rm -rf
+ 	for DIR in ${REFUSE:-}; do
+ 		rm -fr ${PORTSDIR}/${DIR}
+ 	done
  	echo "done."
  
  # Install new files
***************
*** 825,830 ****
--- 833,840 ----
  	    while read LINE; do
  		FILE=`echo ${LINE} | cut -f 1 -d '|'`
  		HASH=`echo ${LINE} | cut -f 2 -d '|'`
+ 		# skip refused ports categories
+ 		echo ${REFUSE:-} | grep -q "${FILE%%/*}" && continue
  		echo ${PORTSDIR}/${FILE}
  		if ! [ -r "${WORKDIR}/files/${HASH}.gz" ]; then
  			echo "files/${HASH}.gz not found -- snapshot corrupt."
--- portsnap.sh-refuse.patch ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->cperciva 
Responsible-Changed-By: cperciva 
Responsible-Changed-When: Fri Sep 2 10:58:06 GMT 2005 
Responsible-Changed-Why:  
Grab this PR. 

I'm not going to commit this patch exactly as submitted because it 
1. Doesn't document the new option in the manual pages, 
2. Has the counterintuitive effect of removing directories listed as 
"refuse" (which is what the submitter seems to intend, but it isn't 
what most users will expect), and 
3. Doesn't make any attempt to modify "portsnap fetch" to avoid 
downloading unwanted files, 
but I do intend to implement this functionality soon. 



http://www.freebsd.org/cgi/query-pr.cgi?pr=85619 

From: Brooks Davis <brooks@one-eyed-alien.net>
To: Colin Percival <cperciva@freebsd.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/85619: [patch] allow portsnap to refuse ports categories
Date: Fri, 2 Sep 2005 10:02:33 -0700

 --7qSK/uQB79J36Y4o
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Fri, Sep 02, 2005 at 11:07:03AM +0000, Colin Percival wrote:
 > I'm not going to commit this patch exactly as submitted because it
 > 1. Doesn't document the new option in the manual pages,
 
 Any documentation should include a very visiable note that the ports
 collection is not supported if any part is refused.  If it works for the
 user that's fine, but if it doesn't that's 100% their problem.
 
 -- Brooks
 
 --=20
 Any statement of the form "X is the one, true Y" is FALSE.
 PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
 
 --7qSK/uQB79J36Y4o
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.1 (GNU/Linux)
 
 iD8DBQFDGIWoXY6L6fI4GtQRAl1DAKCqAIoBUCEQIjsSxkU4a0LPigAUdQCfbQ7z
 muRH5IHkB3TZ4Frrs5xRxpE=
 =QxN8
 -----END PGP SIGNATURE-----
 
 --7qSK/uQB79J36Y4o--
State-Changed-From-To: open->closed 
State-Changed-By: cperciva 
State-Changed-When: Wed Sep 7 12:04:02 GMT 2005 
State-Changed-Why:  
I've added this feature to portsnap; I'll MFC it after the release. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85619 
>Unformatted:
