xargs-friendly repoutil commands?

69 views
Skip to first unread message

Jim Zajkowski

unread,
Feb 15, 2012, 2:00:22 PM2/15/12
to repo...@googlegroups.com
I end up having to write this kind of thing a lot:

./repoutil --products | grep -v testing | grep -v Deprec | awk '{print $1}' | xargs -I % ./repoutil --add-product % testing

which runs slowly because (this) version of xargs doesn't want to expand more than one argument in place. Could a future repoutil update take arguments such that the "list" part is at the end, rather than in the middle?

Maybe a reasonable workaround would be something like "repoutil --with-branch testing --add 012-3456 034-1234 ..." If I were to submit a patch that added that, would that be acceptable?

--Jim

Greg Neagle

unread,
Feb 15, 2012, 2:06:38 PM2/15/12
to repo...@googlegroups.com
I'm curious why you have to buik-add a lot of products to a branch "a lot".

I've been running Reposado for almost a year now. Apart from the initial setup, I find I rarely add more than a handful of updates to a branch at any one time.

Would people expect to be able to do this, though?

repoutil --with-branch testing --add-product foo bar --remove-product ipsum lorum?

-Greg

>
> --Jim
>

Jim Zajkowski

unread,
Feb 15, 2012, 2:30:59 PM2/15/12
to repo...@googlegroups.com
I use that command-line construction because I don't like to copy/paste or retype the product numbers, and we're often not super fast about updating our repos, so when we do the updates there tend to be a lot. For example, for classrooms we don't alter the repo until we're forced to by a hardware changeover.

Either way, the "list part at the end" is a common unixy thing.

As to the other construct, I suppose someone could expect to do that, but I'm a bit surprised you can add and remove at the same time as it is.

--Jim

Greg Neagle

unread,
Feb 15, 2012, 2:37:44 PM2/15/12
to repo...@googlegroups.com
"I'm a bit surprised you can add and remove at the same time as it is"

You currently can't, or at least, it's not properly supported.

-Greg

Jim Zajkowski

unread,
Feb 15, 2012, 2:41:37 PM2/15/12
to repo...@googlegroups.com
Interesting, the code from github seems to (it runs twice, once for the adds, the again for the removes, in whatever argument order).

Greg Neagle

unread,
Feb 15, 2012, 2:46:11 PM2/15/12
to repo...@googlegroups.com
That scares me. Not convinced it will always do the right thing.

repoutil --remove-product xxx-yyyy testing --add-product www-zzzz production

Might do the right thing, but:

repoutil --remove-product xxx-yyyy www-zzzz testing --add-product aaa-bbbb production

Might not. I should review the code.

-Greg

Jim Zajkowski

unread,
Feb 15, 2012, 2:55:03 PM2/15/12
to repo...@googlegroups.com
In any event, what about the --with-branch (or more accurately any way to put the package list on the end, rather than the middle) idea?

Greg Neagle

unread,
Feb 15, 2012, 3:08:29 PM2/15/12
to repo...@googlegroups.com
I'm fine with that if it can be implemented without breaking the current syntax. (not that I think the current syntax is the best, but now that Reposado is incorporated in other projects like JAMF's NetSUS, backwards compatibility is important).

-Greg

A.E. van Bochoven

unread,
Feb 15, 2012, 3:11:31 PM2/15/12
to repo...@googlegroups.com
As I wrote in another post, you can use awk inside backticks, which expands the entire list:

repoutil --add-product `repoutil --products | grep -v testing | grep - i -v deprecated |awk '{printf "%s ",$1}'` testing

This processes much faster

grz

Arjen

Reply all
Reply to author
Forward
0 new messages