Re: A handy utility (at least for me)

2006-08-30 Thread Oliver Fromme
Thiago Damas <[EMAIL PROTECTED]> wrote:
 >  It can be:
 >  cd /usr/ports
 >  rm -rf */*/work

That could overflow your argument verctor if there's a
large number of work directories.

It's better to use "echo */*/work | xargs rm -rf" if
you don't know the size of the pattern expansion in
advance, especially in shell scripts.  echo is a shell-
builtin, so the argument vector limit doesn't apply.

xargs is your friend.  :-)

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"Clear perl code is better than unclear awk code; but NOTHING
comes close to unclear perl code"  (taken from comp.lang.awk FAQ)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-29 Thread Thiago Damas

It can be:
cd /usr/ports
rm -rf */*/work

[]s


On 8/26/06, Rick C. Petty <[EMAIL PROTECTED]> wrote:

On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
>
> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the
> 'work' directories !
>
> Removing them one by one was a pain so I wrote this little utility to wipe
> them off.

I find that the following command works just fine for me:

find /usr/ports -type d -name work -prune -print -delete

=)

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-29 Thread Naram Qashat
- Original Message - 
From: "Bill Vermillion" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, August 29, 2006 12:24 PM
Subject: Re: A handy utility (at least for me)


> On Tue, Aug 29, 2006 at 12:00 [EMAIL PROTECTED]
> saw "Error reading FAT table? Try SKINNY table?" And promptly
> said:
>
> > Date: Mon, 28 Aug 2006 18:18:58 +0200 (CEST)
> > From: Oliver Fromme <[EMAIL PROTECTED]>
> > Subject: Re: A handy utility (at least for me)
>
> > Rick C. Petty wrote:
>
> >  > Mario Lobo wrote:
>
> >  > > My /usr/ports directory was occuping 24 gigs, of which 20
> >  > > was just from the 'work' directories !
>
> > You should type "make clean" more often.  ;-)
>
> And to ensure that 'make clean' in the /usr/ports directory runs
> much faster, be sure to add   NOCLEANDEPENDS=YES in your
> /etc/make.conf.
>
> After you run that on the entire tree besure to comment it out so
> that when you run   make clean   inside a port you clean all the
> dependancies too.

You could always just do make NOCLEANDEPENDS=yes clean from /usr/ports and
then you wouldn't need to worry about setting it in your /etc/make.conf.

>
> Bill
>
> -- 
> Bill Vermillion - bv @ wjv . com
>
Naram Qashat
___
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-29 Thread Bill Vermillion
On Tue, Aug 29, 2006 at 12:00 [EMAIL PROTECTED]
saw "Error reading FAT table? Try SKINNY table?" And promptly
said:

> Date: Mon, 28 Aug 2006 18:18:58 +0200 (CEST)
> From: Oliver Fromme <[EMAIL PROTECTED]>
> Subject: Re: A handy utility (at least for me)

> Rick C. Petty wrote:

>  > Mario Lobo wrote:

>  > > My /usr/ports directory was occuping 24 gigs, of which 20
>  > > was just from the 'work' directories !

> You should type "make clean" more often.  ;-)

And to ensure that 'make clean' in the /usr/ports directory runs
much faster, be sure to add   NOCLEANDEPENDS=YES in your
/etc/make.conf.

After you run that on the entire tree besure to comment it out so
that when you run   make clean   inside a port you clean all the
dependancies too.

Bill

-- 
Bill Vermillion - bv @ wjv . com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-29 Thread Oliver Fromme
Richard Coleman wrote:
 > Oliver Fromme wrote:
 > > The following is probably the most efficient solution.
 > > It doesn't run into all subdirectories (and works with
 > > an arbitrary numebr of subdirectories).
 > > 
 > > cd /usr/ports; echo */*/work | xargs rm -rf
 > 
 > So does this:
 > 
 > find /usr/ports -mindepth 3 -maxdepth 3 -name work -print -delete -prune
 > 
 > I would be surprised if the globbing in most shells was more
 > efficient than find.

Both are mainly disk-bound, so the runtime should be about
the same, I guess.  (I'm too lazy to do any actual bench-
marks with find and various shells.)
 
 > Although as mentioned before, nothing beats putting all the work
 > directories in a single location, and using a single rm command.

Yes, there is something that beats it:  If you put the work
directories on their own filesystem, you can simply umount
and newfs it, which is probably faster than rm -rf.  If you
use a memory filesystem (md device), it's even sufficient
to just umount it.  I think nothing beats that in terms of
speed.  ;-)

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

$ dd if=/dev/urandom of=test.pl count=1
$ file test.pl
test.pl: perl script text executable
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-28 Thread Richard Coleman

Oliver Fromme wrote:

The following is probably the most efficient solution.
It doesn't run into all subdirectories (and works with
an arbitrary numebr of subdirectories).

cd /usr/ports; echo */*/work | xargs rm -rf

Best regards
   Oliver



So does this:

find /usr/ports -mindepth 3 -maxdepth 3 -name work -print -delete -prune

I would be surprised if the globbing in most shells was more efficient than find.  Although as 
mentioned before, nothing beats putting all the work directories in a single location, and using a 
single rm command.


Richard Coleman
[EMAIL PROTECTED]
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-28 Thread Rick C. Petty
On Mon, Aug 28, 2006 at 02:18:48PM -0400, Mike Meyer wrote:
> 
> If echo is a shell built in, then it works just fine, and the xargs
> insures that you don't try passing to many arguments to rm.

Ah!  I was mistaken;  I didn't think about builtins not requiring argument
passing.

> > Also I don't see how your example is any more efficient than find-- you're
> > just making the shell do the work instead of find.
> 
> Find will check *every file* in *every directory* to see if it's named
> "work" or not. The shell version won't make that test on the first two
> levels of directories; it just expands them.

Forgot about those as well.  I retract my previous suggestion, now in favor
of:

find /usr/ports -depth 3 -prune -o -type d -name work -prune -print -delete

This will prevent from going into the files directories.  This method
doesn't have the extra process overhead.

> And now you get into the question of what "efficient" means. Either
> process is going to spend most of it's time waiting on the disk. With
> the find, nothing else is happening while that's going on. With
> multiple processes, there's a possibility that one can be working
> while the other is waiting on the disk, so it might take more CPU time
> while taking less wall clock time. Which is more efficient?  [NB: This
> is grossly oversimplified, but you get the general idea.]

In general I would agree with you.  But in this case, either the shell is
doing a loop over readdir() and applying its glob internally or find is
doing the loop over readdir() and applying its glob via regexec(3).  In
either case, the CPU time should be relatively similar.  In the find case,
a syscall is applied whereas the shell spits this to the xargs process thru
a pipe, who has to malloc/memcpy the lines and start at least one other
process, which then applies the syscall.  To me, this sounds like a lot
more CPU time.

I'm not convinced find would take any longer wallclock time.  It would be
interesting to see some stats on both methods, with and without the
benefit of FreeBSD's filesystem caching mechanisms.

Regardless, the find command is certainly not faster to type for some
people, and really what's important is how much operator time is spent.
One nice thing about unix is that there's more than one way to skin a
cat(1), pardon the pun.  So use what you feel more comfortable using!

Three cheers for free unix,

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-28 Thread Mike Meyer
In <[EMAIL PROTECTED]>, Rick C. Petty <[EMAIL PROTECTED]> typed:
> On Mon, Aug 28, 2006 at 06:18:58PM +0200, Oliver Fromme wrote:
> > Rick C. Petty wrote:
> >  > I find that the following command works just fine for me:
> >  > find /usr/ports -type d -name work -prune -print -delete
> > The following is probably the most efficient solution.
> > It doesn't run into all subdirectories (and works with
> > an arbitrary numebr of subdirectories).
> > cd /usr/ports; echo */*/work | xargs rm -rf
> You might as well just do:
> rm -rf /usr/ports/*/*/work
> because using xargs doesn't gain you anything in this case.  How does your
> example work with an arbitrary number of subdirectories?

If echo is a shell built in, then it works just fine, and the xargs
insures that you don't try passing to many arguments to rm.

> Your example does't work if the number of work directories exceeds the
> maximum number of arguments

That limit is in the kernel exec. If echo is a shell built in, then
the kernel exec doesn't gets involved until after xargs has had a
chance to chop the list of arguments up. If you used "rm" instead of
echo, that isn't the case.

> Also I don't see how your example is any more efficient than find-- you're
> just making the shell do the work instead of find.

Find will check *every file* in *every directory* to see if it's named
"work" or not. The shell version won't make that test on the first two
levels of directories; it just expands them.

> In either case, it's
> just a sequence of opendir()/readdir().  In fact your example would start
> secondary processes to do the directory removal; find has this built in
> and thus doesn't have the overhead of process forking.

And now you get into the question of what "efficient" means. Either
process is going to spend most of it's time waiting on the disk. With
the find, nothing else is happening while that's going on. With
multiple processes, there's a possibility that one can be working
while the other is waiting on the disk, so it might take more CPU time
while taking less wall clock time. Which is more efficient?  [NB: This
is grossly oversimplified, but you get the general idea.]

> Perhaps if on an
> arbitrary directory tree, find may not be as efficient, but the only
> directories deeper than depth of two (in my example) are work directories,
> and they would be pruned.

You forgot the files directories that some ports have. Your version
will look through those for "work", the glob won't.

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-28 Thread Rick C. Petty
On Mon, Aug 28, 2006 at 06:18:58PM +0200, Oliver Fromme wrote:
> Rick C. Petty wrote:
>  > 
>  > I find that the following command works just fine for me:
>  > 
>  > find /usr/ports -type d -name work -prune -print -delete
> 
> The following is probably the most efficient solution.
> It doesn't run into all subdirectories (and works with
> an arbitrary numebr of subdirectories).
> 
> cd /usr/ports; echo */*/work | xargs rm -rf

You might as well just do:

rm -rf /usr/ports/*/*/work

because using xargs doesn't gain you anything in this case.  How does your
example work with an arbitrary number of subdirectories?

Your example does't work if the number of work directories exceeds the
maximum number of arguments (4096 IIRC), which can happen amidst 16,000
ports.  This bit me once so I use find now (granted this was before I was
using portupgrade).

Also I don't see how your example is any more efficient than find-- you're
just making the shell do the work instead of find.  In either case, it's
just a sequence of opendir()/readdir().  In fact your example would start
secondary processes to do the directory removal; find has this built in
and thus doesn't have the overhead of process forking.  Perhaps if on an
arbitrary directory tree, find may not be as efficient, but the only
directories deeper than depth of two (in my example) are work directories,
and they would be pruned.

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-28 Thread Oliver Fromme
Rick C. Petty wrote:
 > Mario Lobo wrote:
 > > My  /usr/ports directory was occuping 24 gigs, of which 20 was just from 
 > > the 
 > > 'work' directories !

You should type "make clean" more often.  ;-)

 > > Removing them one by one was a pain so I wrote this little utility to wipe 
 > > them off.
 > 
 > I find that the following command works just fine for me:
 > 
 > find /usr/ports -type d -name work -prune -print -delete

The following is probably the most efficient solution.
It doesn't run into all subdirectories (and works with
an arbitrary numebr of subdirectories).

cd /usr/ports; echo */*/work | xargs rm -rf

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"I started using PostgreSQL around a month ago, and the feeling is
similar to the switch from Linux to FreeBSD in '96 -- 'wow!'."
-- Oddbjorn Steffensen
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-27 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]>
Dirk Engling <[EMAIL PROTECTED]> writes:
: Rick C. Petty wrote:
: > On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
: >> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from 
the 
: >> 'work' directories !
: >>
: >> Removing them one by one was a pain so I wrote this little utility to wipe 
: >> them off.
: > 
: > I find that the following command works just fine for me:
: > 
: > find /usr/ports -type d -name work -prune -print -delete
: 
: And EVEN cooler is having a
: 
: WRKDIRPREFIX=   /var/ports
: 
: in your /etc/make.conf, that way an "rm -rf /var/ports/*" cleans without
: unnecessary directory recursion.

I just discovered this in my quest to see how hard it would be to get
ports cross building as part of some other work I've been doing...

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-27 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]>
"Rick C. Petty" <[EMAIL PROTECTED]> writes:
: On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
: > 
: > My  /usr/ports directory was occuping 24 gigs, of which 20 was just from 
the 
: > 'work' directories !
: > 
: > Removing them one by one was a pain so I wrote this little utility to wipe 
: > them off.
: 
: I find that the following command works just fine for me:
: 
: find /usr/ports -type d -name work -prune -print -delete

cd /usr/ports ; rm -rf */*/work

seems to run a little faster for me...  So long as I don't have a huge
number of work directories (fewer than thousands).

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Mike Meyer
In <[EMAIL PROTECTED]>, Mario Lobo <[EMAIL PROTECTED]> typed:
> Hi;
> 
> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the 
> 'work' directories !
> 
> Removing them one by one was a pain so I wrote this little utility to wipe 
> them off.

Setting WORDIRPREFIX in /etc/make.conf will cause all the 'work'
directories to be put in that directory. While cleaning them up wasn't
my reason for doing that (I shared /usr/ports across several
platforms), it sures makes cleaing up the work directories easy.

Ditto for DISTDIR, if you want to clean up distfiles.

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Roman Kurakin

albi:

On Sun, 27 Aug 2006 03:12:52 +0400
Roman Kurakin <[EMAIL PROTECTED]> wrote:

  

Rick C. Petty:


On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
  
  

My  /usr/ports directory was occuping 24 gigs, of which 20 was
just from the 'work' directories !

Removing them one by one was a pain so I wrote this little utility
to wipe them off.



I find that the following command works just fine for me:

find /usr/ports -type d -name work -prune -print -delete
  
  

A bit rude, but also works

cd /usr/ports && make clean



guys... please use the official portsclean ! :)
  

In most of cases, you not need it. Portupgrade will clean after itself ;-)

rik

included in the sysutils/portupgrade

 portsclean -h
portsclean 2.0.1 (2006/06/13)

usage: portsclean [-hCDDiLnPPQQq]

-h, --help Show this message
-C, --workcleanClean up working directories
---

  


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Rick C. Petty
On Sun, Aug 27, 2006 at 01:13:19AM +0200, albi wrote:
> 
> > > I find that the following command works just fine for me:
> > >
> > > find /usr/ports -type d -name work -prune -print -delete
> > >   
> > A bit rude, but also works
> > 
> > cd /usr/ports && make clean
> 
> guys... please use the official portsclean ! :)
> 
> included in the sysutils/portupgrade

I was giving an option that works across every system, I didn't mean to
encourage a litany of responses.  =)

I wouldn't call it "official" unless it's in the base system.  Why isn't
portupgrade in the base system?  Oh right, because it uses ruby.  Please
shoot me first before throwing ruby in the base distro.  :-P

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Nicolas Rachinsky
* albi <[EMAIL PROTECTED]> [2006-08-27 01:13 +0200]:
> guys... please use the official portsclean ! :)
> 
> included in the sysutils/portupgrade
> 
>  portsclean -h
> portsclean 2.0.1 (2006/06/13)
> 
> usage: portsclean [-hCDDiLnPPQQq]
> 
> -h, --help Show this message
> -C, --workcleanClean up working directories

I used that, but it gave WRKDIRPREFIX (or some directory below it)
a group ownership and permissions (group writable) I did not like. I
just switched back to rm, so I don't know if you can change this.

Nicolas

-- 
http://www.rachinsky.de/nicolas
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread albi
On Sun, 27 Aug 2006 03:12:52 +0400
Roman Kurakin <[EMAIL PROTECTED]> wrote:

> Rick C. Petty:
> > On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
> >   
> >> My  /usr/ports directory was occuping 24 gigs, of which 20 was
> >> just from the 'work' directories !
> >>
> >> Removing them one by one was a pain so I wrote this little utility
> >> to wipe them off.
> >> 
> >
> > I find that the following command works just fine for me:
> >
> > find /usr/ports -type d -name work -prune -print -delete
> >   
> A bit rude, but also works
> 
> cd /usr/ports && make clean

guys... please use the official portsclean ! :)

included in the sysutils/portupgrade

 portsclean -h
portsclean 2.0.1 (2006/06/13)

usage: portsclean [-hCDDiLnPPQQq]

-h, --help Show this message
-C, --workcleanClean up working directories
---

-- 
grtjs,
albi
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Mario Lobo
> I find that the following command works just fine for me:
>
> > find /usr/ports -type d -name work -prune -print -delete
>
> And EVEN cooler is having a
>
> WRKDIRPREFIX=           /var/ports
>
> in your /etc/make.conf, that way an "rm -rf /var/ports/*" cleans without
> unnecessary directory recursion.

Nothing like being a part of a list o people with true knowledge of OS tools!.

I at least  take comfort in the fact that I exercised my tiny programing 
skills, and that I learned more options from these guys.

big thanks.
-- 
Mario Lobo
http://www.mallavoodoo.com.br
99% rwindows FREE (FBSD not for Pro-Audio YET!!!)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Dirk Engling
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Roman Kurakin wrote:

> A bit rude, but also works
> 
> cd /usr/ports && make clean

This one takes ages, every port is being cleaned which in turn cleans
every dependency, so low level ports will be "make clean"ed thousand
times. Better would be

for port in /usr/ports/*/*/; do cd $port; make NOCLEANDEPENDS=YES clean;
done

Regards

  erdgeist
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFE8NU7ImmQdUyYEgkRAqHTAJ9Q4XFOgg144pkIZ6mPvE5OCNx0NgCgkafL
4aun8IXwJaJSRx1eRVO1dMY=
=f5Mj
-END PGP SIGNATURE-
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Roman Kurakin

Rick C. Petty:

On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
  
My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the 
'work' directories !


Removing them one by one was a pain so I wrote this little utility to wipe 
them off.



I find that the following command works just fine for me:

find /usr/ports -type d -name work -prune -print -delete
  

A bit rude, but also works

cd /usr/ports && make clean

rik

=)

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"
  


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Mario Lobo
On Saturday 26 August 2006 20:01, you wrote:
> Actually, it is a big deal for some people.  Why the GPL?
> You are posting to a FreeBSD list.

You're right, but I build it in kdevelop and it put it there so I felt I 
should leave it there.
-- 
Mario Lobo
http://www.mallavoodoo.com.br
99% rwindows FREE (FBSD not for Pro-Audio YET!!!)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Dirk Engling
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rick C. Petty wrote:
> On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
>> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the 
>> 'work' directories !
>>
>> Removing them one by one was a pain so I wrote this little utility to wipe 
>> them off.
> 
> I find that the following command works just fine for me:
> 
> find /usr/ports -type d -name work -prune -print -delete

And EVEN cooler is having a

WRKDIRPREFIX=   /var/ports

in your /etc/make.conf, that way an "rm -rf /var/ports/*" cleans without
unnecessary directory recursion.

Regards

  erdgeist
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)

iD4DBQFE8NM1ImmQdUyYEgkRAh4OAJ4m2S/EckiXj3N95NDba5TjW+z54gCY8CNp
5xvH4mLR9Kttl9KdB6NGBA==
=F5cq
-END PGP SIGNATURE-
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Daniel Gerzo
Hello Mario,

Sunday, August 27, 2006, 12:19:06 AM, you wrote:

> Hi;

> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the
> 'work' directories !

> Removing them one by one was a pain so I wrote this little utility to wipe
> them off.

try portsclean(1) which IIRC belongs to sysutils/portupgrade.

-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Steve Kargl
On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
> 
> If you find it useful, pass it on. Its not a big deal but thanks for keeping 
> the credits on it.

Actually, it is a big deal for some people.  Why the GPL?
You are posting to a FreeBSD list.

-- 
Steve
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: A handy utility (at least for me)

2006-08-26 Thread Rick C. Petty
On Sat, Aug 26, 2006 at 07:19:06PM -0300, Mario Lobo wrote:
> 
> My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the 
> 'work' directories !
> 
> Removing them one by one was a pain so I wrote this little utility to wipe 
> them off.

I find that the following command works just fine for me:

find /usr/ports -type d -name work -prune -print -delete

=)

-- Rick C. Petty
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


A handy utility (at least for me)

2006-08-26 Thread Mario Lobo
Hi;

My  /usr/ports directory was occuping 24 gigs, of which 20 was just from the 
'work' directories !

Removing them one by one was a pain so I wrote this little utility to wipe 
them off.

If you find it useful, pass it on. Its not a big deal but thanks for keeping 
the credits on it.

Last but not least:

"if any 'member' of your hard disk is caught and killed, the programer will 
deny any knowledge of your actions. This program will NOT self-destruct in 5 
seconds."


CODE SNIP ---

/***
 *   Copyright (C) 2006 by Mario Lobo   
 *   [EMAIL PROTECTED]   
 * 
 *   This program is free software; you can redistribute it and/or modify  
 *   it under the terms of the GNU General Public License as published by  
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version.   
 * 
 *   This program is distributed in the hope that it will be useful,   
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *   GNU General Public License for more details.  
 * 
 *   You should have received a copy of the GNU General Public License 
 *   along with this program; if not, write to the 
 *   Free Software Foundation, Inc.,   
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 *
 *  To compile:   gcc -O2 -o dwork dwork.c
 *
 ***/

#include 
#include 
#include 

char linha[2048],comd[2048];
void clean_it(char *arg);

int main(int argc, char **argv) {

int  k = 1;
char *maindir = "/bin/ls -R /usr/ports/", *pad = " | grep /work:" ;
char arq1[100];


printf("\n\n");
printf("DWORK - /usr/ports/nnn/nnn/'work' directory cleaner. (Mario 
Lobo - 
2006)\n\n");
printf("ex.: dwork (no arguments)  -> Deletes 'work' directories 
from /usr/ports\n");
printf(" dwork multimedia  -> Deletes 'work' directories 
from /usr/ports/multimedia\n");
printf(" dwork multimedia audio-> Deletes 'work' directories 
from /usr/ports/multimedia AND /usr/ports/audio\n");

printf("\n\n");
printf("** Working. Please wait");

if (argc > 1) {

while(k < argc) {

strcpy(comd,maindir);
strcat(comd,argv[k]);
strcat(comd,pad);

strcpy(arq1,"/usr/ports/");
strcat(arq1,argv[k]);

clean_it(arq1);
k++;

}

} else {

strcpy(comd,maindir);
strcat(comd,pad);
clean_it("/usr/ports");

}
printf("\n\n** DONE.\n\n");
}

void clean_it(char *arg) {

char *tmp;
int  c = 0;
FILE *fp;

fp = popen(comd,"r");

printf("\n");

while(!feof(fp)) {

memset(linha,0,1024);
fgets(linha,1024,fp);

if (strlen(linha) < 15) continue;

c = 1;
tmp = strchr(linha,'\n');
*tmp = '\0';
tmp = strchr(linha,':');
*tmp = '\0';

printf("\n++ Removing %s", linha);

strcpy(comd,"/bin/rm -rf ");
strcat(comd,linha);
system(comd);
}
pclose(fp);

if (!c) printf("\n-- NO 'work' directories in %s.",arg);

}

CODE ENDS --

Best wishes,
-- 
Mario Lobo
http://www.mallavoodoo.com.br
99% rwindows FREE (FBSD not for Pro-Audio YET!!!)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"