OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Thomas Lotterer
  Root:   /v/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-registry                 Date:   29-Nov-2005 17:35:18
  Branch: HEAD                             Handle: 2005112916351800

  Modified files:
    openpkg-registry        register.sh rpm.sh

  Log:
    move registration detection and URL rewrite logic from rpm.sh into
    rewrite.sh, making it available to other scripts

  Summary:
    Revision    Changes     Path
    1.13        +72 -3      openpkg-registry/register.sh
    1.5         +5  -46     openpkg-registry/rpm.sh
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-registry/register.sh
  ============================================================================
  $ cvs diff -u -r1.12 -r1.13 register.sh
  --- openpkg-registry/register.sh      29 Nov 2005 16:19:27 -0000      1.12
  +++ openpkg-registry/register.sh      29 Nov 2005 16:35:18 -0000      1.13
  @@ -66,12 +66,28 @@
   
   readconf()
   {
  -    [ ".$conf" = . ] && error "missing information conf"
  +    [ ".$conf" = . ] && return
       if [ -r "$conf" ]; then
         sanitycheck "$conf" && . "$conf"
       fi
   }
   
  +readuuid()
  +{
  +    [ ".$REGISTRY_UUID" = . ] && return
  +    if [ -r "$REGISTRY_UUID" ]; then
  +      sanitycheck "$REGISTRY_UUID" && . "$REGISTRY_UUID"
  +    fi
  +}
  +
  +readutil()
  +{
  +    [ ".$REGISTRY_UTIL" = . ] && return
  +    if [ -r "$REGISTRY_UTIL" ]; then
  +      sanitycheck "$REGISTRY_UTIL" && . "$REGISTRY_UTIL"
  +    fi
  +}
  +
   ##
   ##  command line option parsing
   ##
  @@ -103,6 +119,8 @@
   help="no"
   
   #   iterate over argument line
  +declare -a a
  +declare -i i=0
   while [ $# -gt 0 ]; do
       opt=$1
       case $opt in
  @@ -119,6 +137,10 @@
           -C|--convenience ) op="convenience" ;;
           -I|--interaction ) op="interaction" ;;
   
  +        # Additional features
  +        -S|--printstatus ) op="printstatus" ;;
  +        -R|--rewriteurls ) op="rewriteurls" ;;
  +
           # Standard options
           -c|--conf )
             if [ ".$arg" = . ]; then shift; arg="$1"; fi
  @@ -183,9 +205,14 @@
           -h|--help    ) help="Usage"  ;;
           -*           ) help="Invalid option \`$opt'"; break ;;
   
  +        # Optional arguments
  +        * ) a[$i]="$opt"
  +            i=i+1
       esac
       shift
   done
  +set -- "[EMAIL PROTECTED]"
  +unset i a
   
   #   display error or usage message
   if [ ".$help" != .no ]; then
  @@ -196,9 +223,13 @@
             [-v|--verbose] [-h|--help]
             [-P|--preparation] [-T|--transaction] [-U|--utilization] 
[-C|--convenience] [-I|--interaction]
             [-c|--conf=<file>]
  -          -m|--mode=<mode> [-a|--args=<args>] -u|--user=<user> 
[-d|--desc=<text>]
  +          -m|--mode=fake|post|wipe [-a|--args=<args>] -u|--user=<user> 
[-d|--desc=<text>]
             [--uuid=<file>] [--prep=<file>] [--tran=<file>] [--util=<file>]
             [--plat=<text>] [--orel=<text>]
  +          Usage: $progname :
  +          -S|--printstatus
  +          Usage: $progname :
  +          -R|--rewriteurls [[url]...]]
             " 1>&2
   
       if [ ".$help" != ".Usage" ]; then
  @@ -454,6 +485,44 @@
   }
   
   ##
  +##  Additional feature printstatus
  +##
  +printstatus()
  +{
  +    rc=0
  +    readconf || error "problem reading conf"
  +    readuuid || error "problem reading uuid"
  +    readutil || error "problem reading util"
  +    if [ ".$REGISTRY_DONE" = .yes ]; then
  +        cat "$REGISTRY_UTIL"
  +        return 0
  +    fi
  +    return 1
  +}
  +
  +##
  +##  Additional feature rewriteurls
  +##
  +rewriteurls()
  +{
  +    readconf && readuuid && readutil || return $?
  +    if [ ".$REGISTRY_DONE" = .yes ]; then
  +        #   URL rewriting
  +        while [ ".$1" != . ]; do
  +            printf '%s\n' "$1" | sed \
  +            -e "s;^\(ftp\)://\(ftp.openpkg.com\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;" \
  +            -e "s;^\(ftp\)://\(ftp.openpkg.org\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;" \
  +            -e "s;^\(ftp\)://\(ftp.openpkg.net\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;"
  +            shift
  +        done
  +        return 0
  +    else
  +        #   stealth mode
  +        return 1
  +    fi
  +}
  +
  +##
   ##  automatical pick interaction or convenience
   ##
   automatical()
  @@ -487,5 +556,5 @@
   ##
   ##  primary operation switch
   ##
  -eval $op
  +eval $op "\"[EMAIL PROTECTED]""
   
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-registry/rpm.sh
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 rpm.sh
  --- openpkg-registry/rpm.sh   28 Nov 2005 07:12:08 -0000      1.4
  +++ openpkg-registry/rpm.sh   29 Nov 2005 16:35:18 -0000      1.5
  @@ -34,59 +34,18 @@
   oldnanewbin="$PREFIX/lib/openpkg/rpm"     # old n/a, new binary rpm
   if [ -x $oldbinnewsh -a -x $oldnanewbin ]; then exec $oldnanewbin "$@"; fi
   
  -##
  -##  read configuration unless already done during option parsing
  -##
  -sanitycheck()
  -{
  -    if [ ".$1" != . -a -r "$1" ]; then
  -        cat <"$1" | awk '
  -            BEGIN { rc=0 }
  -            !/^([A-Z][A-Z0-9_]+[A-Z0-9]="[ !#$%&(-_a-~]+")? *(#.*)?$/ { rc=1 
}
  -            END { exit rc }' && return 0
  -    fi
  -    return 1
  -}
  -
  -readconf()
  -{
  -    [ ".$conf" = . ] && return
  -    if [ -r "$conf" ]; then
  -      sanitycheck "$conf" && . "$conf"
  -    fi
  -}
  -
  -readuuid()
  -{
  -    [ ".$REGISTRY_UUID" = . ] && return
  -    if [ -r "$REGISTRY_UUID" ]; then
  -      sanitycheck "$REGISTRY_UUID" && . "$REGISTRY_UUID"
  -    fi
  -}
  -
  -readutil()
  -{
  -    [ ".$REGISTRY_UTIL" = . ] && return
  -    if [ -r "$REGISTRY_UTIL" ]; then
  -      sanitycheck "$REGISTRY_UTIL" && . "$REGISTRY_UTIL"
  -    fi
  -}
  -
  -#   Configuration file default and read attempt
  -conf="$PREFIX/etc/openpkg/register.conf"; readconf; readuuid; readutil
  +#   determine wheter URL rewriting is active
  +rewrite=0
  +$PREFIX/bin/openpkg register --printstatus >/dev/null 2>&1 && rewrite=1
   
   #   main
  -if [ ".$REGISTRY_DONE" = .yes ]; then
  +if [ $rewrite == 1 ]; then
       #   URL rewriting
       declare -a a
       declare -i i=0
       while [ ".$1" != . ]; do
           arg="$1"
  -        arg=`printf '%s\n' "$arg" | sed \
  -        -e "s;^\(ftp\)://\(ftp.openpkg.com\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;" \
  -        -e "s;^\(ftp\)://\(ftp.openpkg.org\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;" \
  -        -e "s;^\(ftp\)://\(ftp.openpkg.net\)/;\1://$UUID_REGISTRY:[EMAIL 
PROTECTED]/;" \
  -        `
  +        printf '%s\n' "$arg" | grep :// && arg=`$PREFIX/bin/openpkg register 
--rewriteurls "$arg"`
           a[$i]="$arg"
           i=i+1
           shift
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     openpkg-cvs@openpkg.org

Reply via email to