Date: Mon, 6 May 2013 09:38:42 GMT From: Yanhui Shen <shen.elf@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/178365: New port: ports-mgmt/pkg-rmleaf "Remove leaf packages" Message-ID: <201305060938.r469cg0H052678@oldred.FreeBSD.org> Resent-Message-ID: <201305060940.r469e0XW006761@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 178365 >Category: ports >Synopsis: New port: ports-mgmt/pkg-rmleaf "Remove leaf packages" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon May 06 09:40:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Yanhui Shen >Release: FreeBSD 9.1-STABLE >Organization: NONE >Environment: FreeBSD ThinkPad 9.1-STABLE FreeBSD 9.1-STABLE #0 r249397: Fri Apr 12 17:28:25 CST 2013 shen@ThinkPad:/usr/obj/usr/src/sys/ThinkPad amd64 >Description: A little script for removing leaf packages. (requires pkgng) shar file: pkg-rmleaf.txt >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # pkg-rmleaf # pkg-rmleaf/files # pkg-rmleaf/files/pkg-rmleaf # pkg-rmleaf/Makefile # pkg-rmleaf/pkg-descr # echo c - pkg-rmleaf mkdir -p pkg-rmleaf > /dev/null 2>&1 echo c - pkg-rmleaf/files mkdir -p pkg-rmleaf/files > /dev/null 2>&1 echo x - pkg-rmleaf/files/pkg-rmleaf sed 's/^X//' >pkg-rmleaf/files/pkg-rmleaf << '29ef2316dbde3ecdd0c6487fcf644a44' X#!/bin/sh X X# Copyright (c) 2013 Yanhui Shen, shen.elf@gmail.c0m X# All rights reserved. X# X# Redistribution and use in source and binary forms, with or without X# modification, are permitted provided that the following conditions X# are met: X# 1. Redistributions of source code must retain the above copyright X# notice, this list of conditions and the following disclaimer. X# 2. Redistributions in binary form must reproduce the above copyright X# notice, this list of conditions and the following disclaimer in the X# documentation and/or other materials provided with the distribution. X# X# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X# SUCH DAMAGE. X XKeptLeaves="" XListDialog="dialog --checklist \"leaf packages\" 30 80 30" XDeletePkg="pkg delete -y" XTempFile=`mktemp -t pkg-rmleaf` X XQuit () { X rm $TempFile X exit X} X Xif [ -z $TempFile ]; then X echo "Failed to create tempfile!" X exit Xfi X Xwhile true; do X #==== refresh leaves ==== X echo "Calculating..." X AllLeaves=`pkg query "%o#%c\t#%?r#" | grep "#0#" | cut -f1 | sort` X NewLeaves="" X IFS=$'\n' X for line in $AllLeaves; do X port=$(echo "$line" | cut -d'#' -f1) X desc=$(echo "$line" | cut -d'#' -f2 | sed -e 's/"/\\"/g') X ret=$(echo "$KeptLeaves" | grep "$port") X if [ -z "$ret" ]; then X NewLeaves="$NewLeaves $port \"$desc\" off" X fi X done X X #==== show dialog ==== X if [ -z "$NewLeaves" ]; then X echo "Nothing to do!" X Quit X fi X eval "$ListDialog $NewLeaves" 2>$TempFile X X #==== record old leaves ==== X KeptLeaves="$AllLeaves" X X #==== deinstall selected ==== X selections=`cat $TempFile` X if [ -z $selections ]; then X echo "No selection, quit." X Quit X fi X IFS=$' ' X for pkg in $selections; do X eval "$DeletePkg $pkg" X done Xdone 29ef2316dbde3ecdd0c6487fcf644a44 echo x - pkg-rmleaf/Makefile sed 's/^X//' >pkg-rmleaf/Makefile << '90b081522a03c78615bf1fbde8757eba' X# New ports collection makefile for: pkg-rmleaf X# Date created: 05.06.2013 X# Whom: Yanhui Shen <shen.elf@gmail.com> X XPORTNAME= pkg-rmleaf XPORTVERSION= 0.1 XCATEGORIES= ports-mgmt XMASTER_SITES= # none XDISTFILES= # none X XMAINTAINER= shen.elf@gmail.com XCOMMENT= Remove leaf packages XLICENSE= BSD X XNO_BUILD= yes XRUN_DEPENDS= ${LOCALBASE}/sbin/pkg:${PORTSDIR}/ports-mgmt/pkg X XWRKSRC= ${WRKDIR} X XPLIST_FILES= sbin/pkg-rmleaf X Xdo-extract: X ${MKDIR} ${WRKSRC} X ${CP} ${FILESDIR}/pkg-rmleaf ${WRKSRC} X Xdo-install: X ${INSTALL_SCRIPT} ${WRKSRC}/pkg-rmleaf ${PREFIX}/sbin/pkg-rmleaf X X.include <bsd.port.mk> 90b081522a03c78615bf1fbde8757eba echo x - pkg-rmleaf/pkg-descr sed 's/^X//' >pkg-rmleaf/pkg-descr << '7fe204c325fc4fdeef345cc0f0a99f60' XA little script for removing leaf packages. (requires pkgng) 7fe204c325fc4fdeef345cc0f0a99f60 exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305060938.r469cg0H052678>