[pacman-dev] [PATCH] ABS - Specify repo or package to download on command-line
This patch fixes the ability to specify which repos to be synced as parameters to abs (e.g "abs core extra"). In addition, single or multiple packages can be requested on the command line (e.g. "abs core/pacman extra/abs") as well as any combination of repos and packages. Signed-off-by: Allan McRae <allan@archlinux.org> --- abs | 50 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 16 deletions(-) diff --git a/abs b/abs index 8f6fd30..a0ae4c7 100755 --- a/abs +++ b/abs @@ -24,7 +24,7 @@ ABS_VERSION="%%ABS_VERSION%%" CONFDIR="%%CONF_DIR%%" SYNCCMD='rsync' -SYNCARGS='-mrtv --no-motd --delete-after --delete-excluded' +SYNCARGS='-mrtv --no-motd --delete-after' BUG_REPORT_EMAIL=pacman-dev@archlinux.org ## @@ -73,15 +73,17 @@ fi ## usage() { echo "Arch Build System $ABS_VERSION -- synchronization utility" - echo "usage: $0 [options] [repository1 [repository2 ...]]" + echo "" + echo "Usage:" + echo "$0 [options] [repository1[/package1] [repository2[/package2] ...]]" echo echo "Options:" echo " -h, --help Display this help message then exit." echo " -V, --version Display version information then exit." echo - echo "abs will synchronize PKGBUILD scripts from the Arch Linux" - echo "repository into $ABSROOT via rsync. If no argument is given, abs" - echo "will synchronize the repositories specified in ${CONFDIR}abs.conf." + echo "abs will synchronize PKGBUILD scripts from the Arch Linux repositories" + echo "into $ABSROOT via rsync. If no argument is given, abs will synchronize" + echo "the repositories specified in ${CONFDIR}abs.conf." echo echo "Report bugs to $BUG_REPORT_EMAIL with [ABS] in the subject" } @@ -92,24 +94,39 @@ version() { echo "Copyright (C) 2002-2008 Judd Vinet <jvinet@zeroflux.org>." echo echo "This is free software; see the source for copying conditions." - echo "There is NO WARRANTY, to the extent permitted by law." + echo "There is NO WARRANTY, to the extent permitted by law." } update() { cd "$ABSROOT" - EXCLUDE="--filter=P_/local/ --filter=P_/README" - - # I want to ensure we only exclude the top-level repo directories - for repo in "${REPOS[@]}"; do - if [ "$repo" != "${repo#!}" ]; then - EXCLUDE="${EXCLUDE} --filter=-_/${repo#!}/" - fi - done + if [ "$CLPARAM" = "" ]; then + # using repos specified in abs.conf + for repo in "${REPOS[@]}"; do + if [ "$repo" != "${repo#!}" ]; then + EXCLUDE="${EXCLUDE} --filter=-_/${repo#!}/" + fi + done + + EXCLUDE="${EXCLUDE} --filter=P_/local/ --filter=P_/README" + SYNCARGS="${SYNCARGS} --delete-excluded" + else + # using repos/packages specified on the command line + for param in "${REPOS[@]}"; do + INCLUDE="${INCLUDE} --include=/${param}" + if [ "$param" != "${param/\/}" ]; then + repo=${param%/*} + INCLUDE="${INCLUDE} --include=/${repo}" + EXCLUDE="${EXCLUDE} --exclude=/${repo}/*" + fi + done + INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ") + EXCLUDE="${EXCLUDE} --exclude=/*" + fi msg "Starting ABS sync..." - $SYNCCMD $SYNCARGS $EXCLUDE ${SYNCSERVER}::abs/${ARCH}/ $ABSROOT -} + $SYNCCMD $SYNCARGS $INCLUDE $EXCLUDE ${SYNCSERVER}::abs/${ARCH}/ $ABSROOT +} ## # Signal Traps @@ -143,6 +160,7 @@ while true; do done if [ "$#" -gt "0" ]; then + CLPARAM=1 REPOS=("$@") fi -- 1.5.6.2
Hi all, I figured I could still send patches for ABS here for people to look at since this is the address listed in --help output... Anyway, I mainly wanted a comment on this line: INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ") which takes $INCLUDE, sorts it and removes duplicate values. Is there a better way to do this? Everything appears to still work if I don't do this but it makes the rsync command much cleaner. Allan
On Fri, Jul 11, 2008 at 6:54 AM, Allan McRae <allan@archlinux.org> wrote:
Hi all,
I figured I could still send patches for ABS here for people to look at since this is the address listed in --help output...
Anyway, I mainly wanted a comment on this line:
INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ")
which takes $INCLUDE, sorts it and removes duplicate values. Is there a better way to do this? Everything appears to still work if I don't do this but it makes the rsync command much cleaner.
In 5 minutes of hacking I can't come up with something better. Is this a concern however? $ echo "-i=core -i=community -i=core/foobar -i=core" | tr " " "\n" | sort -u | tr "\n" " " -i=community -i=core -i=core/foobar -Dan
Dan McGee wrote:
On Fri, Jul 11, 2008 at 6:54 AM, Allan McRae <allan@archlinux.org> wrote:
Hi all,
I figured I could still send patches for ABS here for people to look at since this is the address listed in --help output...
Anyway, I mainly wanted a comment on this line:
INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ")
which takes $INCLUDE, sorts it and removes duplicate values. Is there a better way to do this? Everything appears to still work if I don't do this but it makes the rsync command much cleaner.
In 5 minutes of hacking I can't come up with something better. Is this a concern however?
$ echo "-i=core -i=community -i=core/foobar -i=core" | tr " " "\n" | sort -u | tr "\n" " " -i=community -i=core -i=core/foobar
I don't think so... But then, I am not sure what you are getting at there! That would occur if someone went "abs core extra core/foobar" but that would be stupid given if you are syncing core then you will get core/foobar. I don't think I will work around stupidity until later... :D Allan
On Fri, Jul 11, 2008 at 7:23 AM, Allan McRae <allan@archlinux.org> wrote:
Dan McGee wrote:
On Fri, Jul 11, 2008 at 6:54 AM, Allan McRae <allan@archlinux.org> wrote:
Hi all,
I figured I could still send patches for ABS here for people to look at since this is the address listed in --help output...
Anyway, I mainly wanted a comment on this line:
INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ")
which takes $INCLUDE, sorts it and removes duplicate values. Is there a better way to do this? Everything appears to still work if I don't do this but it makes the rsync command much cleaner.
In 5 minutes of hacking I can't come up with something better. Is this a concern however?
$ echo "-i=core -i=community -i=core/foobar -i=core" | tr " " "\n" | sort -u | tr "\n" " " -i=community -i=core -i=core/foobar
I don't think so... But then, I am not sure what you are getting at there!
That would occur if someone went "abs core extra core/foobar" but that would be stupid given if you are syncing core then you will get core/foobar. I don't think I will work around stupidity until later... :D
Hmm, then I missed the point of removing dupes I guess? When would we ever have a dupe? -Dan
Dan McGee wrote:
On Fri, Jul 11, 2008 at 7:23 AM, Allan McRae <allan@archlinux.org> wrote:
Dan McGee wrote:
On Fri, Jul 11, 2008 at 6:54 AM, Allan McRae <allan@archlinux.org> wrote:
Hi all,
I figured I could still send patches for ABS here for people to look at since this is the address listed in --help output...
Anyway, I mainly wanted a comment on this line:
INCLUDE=$(echo $INCLUDE | tr " " "\n" | sort -u | tr "\n" " ")
which takes $INCLUDE, sorts it and removes duplicate values. Is there a better way to do this? Everything appears to still work if I don't do this but it makes the rsync command much cleaner.
In 5 minutes of hacking I can't come up with something better. Is this a concern however?
$ echo "-i=core -i=community -i=core/foobar -i=core" | tr " " "\n" | sort -u | tr "\n" " " -i=community -i=core -i=core/foobar
I don't think so... But then, I am not sure what you are getting at there!
That would occur if someone went "abs core extra core/foobar" but that would be stupid given if you are syncing core then you will get core/foobar. I don't think I will work around stupidity until later... :D
Hmm, then I missed the point of removing dupes I guess? When would we ever have a dupe?
Running "abs core/base core/pacman" would give something like "-i=core -i=core/base -i=core -i=core/pacman". I think the extra "-i core" does not really matter but there may be an edge case I am missing so that why I wanted to remove the dupes. Allan
participants (2)
-
Allan McRae
-
Dan McGee