Re: A little script to remove packages don't needed

2006-07-02 Thread Andrés

I changed a couple of things:

a) Now there's a license notice (template from
/usr/src/share/misc/license.template). Nothing important, just to be
sure.

b) All packages which you didn't want to delete are saved to a file,
so you will not have to answer n in future runs (to check the full
list of packages just do: sudo rm /etc/pkg_check.conf).

c) If, in a run, packages were deleted, a new run is suggested,
because maybe there are packages which were *only* used by those
packages.

Again, feedback is useful :)



#!/bin/ksh

# Copyright (c) 2006 AndrC)s Delfino [EMAIL PROTECTED]
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

function move_cursor_up {

tput up dl 0

}

function check_for_packages {

for package in $( ls /var/db/pkg ); {

echo Checking for $package

if ! { test -a /var/db/pkg/$package/+REQUIRED_BY || {
package_name=$( echo $package | sed s/-[^-]\{1,\}$// ); grep -qs
$package_name /etc/pkg_check.conf; } } then

move_cursor_up

echo -n No package depends on $package, would you like to 
delete it? YES/n 

while true; do

read answer

case $answer in

YES )

sudo pkg_delete $package

let deleted_packages = 1

break

;;

n )

echo $package_name  
/etc/pkg_check.conf

break

;;

* )

echo -n 'YES/n '

;;

esac

done

else

move_cursor_up

fi

}

}

while true; do

check_for_packages

if ! let deleted_packages; then

break

fi

let deleted_packages = 0

echo -n \nIt's possible that there are packages which were only used
by any of the deleted ones, would you like to run pkg_check again? y/n


while true; do

read answer

case $answer in

y )

echo

break

;;

n )

break 2

;;

* )

echo -n 'y/n '

;;

esac

done

done



Re: A little script to remove packages don't needed

2006-07-01 Thread Andrés

I've done a rewrite, which reads directories and searches for files,
which is MUCH faster :)

Greetings

#!/bin/ksh

function check_for_packages {

for package in $(ls /var/db/pkg); {

echo Checking if any package depends on $package

if ! $(test -a /var/db/pkg/$package/+REQUIRED_BY); then

tput up dl 0

echo No package depends on $package, would you like to 
delete it? YES/n

while :; do

read answer

tput up dl 0

case $answer in

YES )

sudo pkg_delete $package

break

;;

n )

break

;;

* )

echo 'YES/n'

;;

esac

done

else

tput up dl 0

fi

}

}

check_for_packages



A little script to remove packages don't needed

2006-06-30 Thread Andrés

I don't know how to explain it well (:P), the script finds which
packages are not needed by others, so you can delete those you don't
use.

It's my first shell script, so feedback is apreciated, :) This is in
public domain, blah blah blah blah.



#!/bin/ksh

function check_for_packages {

for package in $(pkg_info | cut -f 1 -d \ ); {

echo Checking if any package depends on $package

if ! pkg_info -R $package | fgrep -q 'Required by:'; then

tput up dl 0

echo No package depends on $package, would you like to 
delete it? YES/n

while :; do

read answer

tput up dl 0

case $answer in

YES )

sudo pkg_delete $package

break

;;

n )

break

;;

* )

echo 'YES/n'

;;

esac

done

else

tput up dl 0

fi

}

}

check_for_packages



Re: A little script to remove packages don't needed

2006-06-30 Thread Andrés

It's going to get deleted if you choose that. It's not a fully automated script.

Thanks for the feedback :)

On 6/30/06, Wade, Daniel [EMAIL PROTECTED] wrote:

That all good and well, but what happens when my package that I use has zero 
depends?
It's going to get deleted.