diff options
author | rakuco <rakuco@FreeBSD.org> | 2013-05-16 06:21:30 +0800 |
---|---|---|
committer | rakuco <rakuco@FreeBSD.org> | 2013-05-16 06:21:30 +0800 |
commit | 7b02b449d00ecb264593217fe9477392e1d41057 (patch) | |
tree | 5e18b1193c0a0b0a698132183176030b7c52ce33 /ports-mgmt/pkg-rmleaf | |
parent | 074d6c4a7b6f04934dab57bb23a96e62f31e9e14 (diff) | |
download | freebsd-ports-gnome-7b02b449d00ecb264593217fe9477392e1d41057.tar.gz freebsd-ports-gnome-7b02b449d00ecb264593217fe9477392e1d41057.tar.zst freebsd-ports-gnome-7b02b449d00ecb264593217fe9477392e1d41057.zip |
Add ports-mgmt/pkg-rmleaf.
A little script for removing leaf packages (requires pkgng).
PR: ports/178366
Submitted by: Yanhui Shen <shen.elf@gmail.com> (maintainer)
Diffstat (limited to 'ports-mgmt/pkg-rmleaf')
-rw-r--r-- | ports-mgmt/pkg-rmleaf/Makefile | 29 | ||||
-rw-r--r-- | ports-mgmt/pkg-rmleaf/files/pkg-rmleaf | 77 | ||||
-rw-r--r-- | ports-mgmt/pkg-rmleaf/pkg-descr | 1 |
3 files changed, 107 insertions, 0 deletions
diff --git a/ports-mgmt/pkg-rmleaf/Makefile b/ports-mgmt/pkg-rmleaf/Makefile new file mode 100644 index 000000000000..4fc88ade4afd --- /dev/null +++ b/ports-mgmt/pkg-rmleaf/Makefile @@ -0,0 +1,29 @@ +# Created by: Yanhui Shen <shen.elf@gmail.com> +# $FreeBSD$ + +PORTNAME= pkg-rmleaf +PORTVERSION= 0.2 +CATEGORIES= ports-mgmt +MASTER_SITES= # none +DISTFILES= # none + +MAINTAINER= shen.elf@gmail.com +COMMENT= Remove leaf packages + +LICENSE= BSD + +RUN_DEPENDS= ${LOCALBASE}/sbin/pkg:${PORTSDIR}/ports-mgmt/pkg + +NO_BUILD= yes +WRKSRC= ${WRKDIR} + +PLIST_FILES= sbin/pkg-rmleaf + +do-extract: + ${MKDIR} ${WRKSRC} + ${CP} ${FILESDIR}/pkg-rmleaf ${WRKSRC} + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/pkg-rmleaf ${PREFIX}/sbin/pkg-rmleaf + +.include <bsd.port.mk> diff --git a/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf b/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf new file mode 100644 index 000000000000..381827d89cf9 --- /dev/null +++ b/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf @@ -0,0 +1,77 @@ +#!/bin/sh + +# Copyright (c) 2013 Yanhui Shen, shen.elf@gmail.c0m +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +#Twiddle="echo '|/-\\' | cut -c" +PkgQuery="pkg query -e \"%#r=0\" \"%o#%c\" | sort" +PkgDelete="pkg delete -y" +DialogList="dialog --stdout --checklist \"leaf packages (%s)\" 30 90 30" + +KeptLeaves="" +while true; do + #==== refresh leaves ==== + echo "Calculating..." + AllLeaves=`eval $PkgQuery` + NewLeaves="" + nNewLeaves="0" + #n="0" + IFS=$'\n' + for line in $AllLeaves; do + # print twiddle will be a little slower + #n=$(($n % 4 + 1)) + #ch=`eval "$Twiddle $n"` + #printf "Calculating...%s\r" "$ch" + + port=`echo "$line" | cut -d'#' -f1` + desc=`echo "$line" | cut -d'#' -f2 | sed -e 's/\"/\\\"/g'` + ret=`echo "$KeptLeaves" | grep "$port"` + if [ -z "$ret" ]; then + NewLeaves="$NewLeaves $port \"$desc\" off" + nNewLeaves=$(($nNewLeaves + 1)) + fi + done + + #==== show dialog ==== + if [ -z "$NewLeaves" ]; then + echo "Nothing to do!" + exit + fi + cmd=`printf $DialogList "$nNewLeaves"` + selections=`eval "$cmd $NewLeaves"` + if [ $? -ne 0 ]; then + echo "Canceled." + exit + fi + + #==== record old leaves ==== + KeptLeaves="$AllLeaves" + + #==== deinstall selected ==== + if [ -z $selections ]; then + echo "No selection, quit." + exit + fi + eval "$PkgDelete $selections" +done diff --git a/ports-mgmt/pkg-rmleaf/pkg-descr b/ports-mgmt/pkg-rmleaf/pkg-descr new file mode 100644 index 000000000000..62593e03f400 --- /dev/null +++ b/ports-mgmt/pkg-rmleaf/pkg-descr @@ -0,0 +1 @@ +A little script for removing leaf packages (requires pkgng). |