Date: Monday, February 12, 2007 @ 01:07:11 Author: aaron Path: /home/cvs-pacman/pacman-lib/scripts Modified: gensync (1.12 -> 1.13) updatesync (1.8 -> 1.9) Rewrote updatesync in terms of repo-add and repo-remove ------------+ gensync | 2 updatesync | 208 ++++++++++++----------------------------------------------- 2 files changed, 45 insertions(+), 165 deletions(-) Index: pacman-lib/scripts/gensync diff -u pacman-lib/scripts/gensync:1.12 pacman-lib/scripts/gensync:1.13 --- pacman-lib/scripts/gensync:1.12 Mon Feb 12 00:49:45 2007 +++ pacman-lib/scripts/gensync Mon Feb 12 01:07:11 2007 @@ -119,7 +119,7 @@ fi done -echo "successfuly found all packages, creating repo DB..." +echo "creating repo DB..." # we'll trim the output just a tad, as gensync may be used on large repos repo-add $destfile $pkgs --force $force_pkgs \ Index: pacman-lib/scripts/updatesync diff -u pacman-lib/scripts/updatesync:1.8 pacman-lib/scripts/updatesync:1.9 --- pacman-lib/scripts/updatesync:1.8 Wed Dec 20 20:53:41 2006 +++ pacman-lib/scripts/updatesync Mon Feb 12 01:07:11 2007 @@ -21,7 +21,7 @@ # USA. # -myver='2.9.8' +myver='3.0.0' usage() { echo "updatesync $myver" @@ -47,128 +47,29 @@ exit 0 } -die() -{ - echo "updatesync: $*" >&2 - rm -rf $ustmpdir - exit 1 -} +BUILDSCRIPT="PKGBUILD" +PKGEXT="pkg.tar.gz" -check_option() { - local i - for i in ${options[@]}; do - local uc=`echo $i | tr [:lower:] [:upper:]` - local lc=`echo $i | tr [:upper:] [:lower:]` - if [ "$uc" = "$1" -o "$lc" = "$1" ]; then - echo $1 - return - fi - done -} +source /etc/makepkg.conf -get_md5checksum() -{ - if [ "$pkgdir" != "" ]; then - pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" - else - pkgfile="$destdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" - fi - if [ -f $pkgfile ]; then - md5line=`md5sum $pkgfile` - [ ! -z "$md5line" ] && pkgmd5sum=${md5line% *} - echo $pkgmd5sum - fi - return 0 +error () { + echo "==> ERROR: $*" >&2 } -db_write_entry() -{ - unset pkgname pkgver pkgrel pkgdesc force - unset groups replaces provides depends conflicts options - source $1 || return 1 - cd $ustmpdir - mkdir $pkgname-$pkgver-$pkgrel || return 1 - cd $pkgname-$pkgver-$pkgrel - # desc - : >desc - echo "%NAME%" >>desc - echo "$pkgname" >>desc - echo "" >>desc - echo "%VERSION%" >>desc - echo "$pkgver-$pkgrel" >>desc - echo "" >>desc - if [ -n "$pkgdesc" ]; then - echo "%DESC%" >>$entry - echo "$pkgdesc" >>$entry - echo "" >>$entry - fi - if [ ${#groups[*]} -gt 0 ]; then - echo "%GROUPS%" >>$entry - for it in "${groups[@]}"; do - echo "$it" >>$entry - done - echo "" >>$entry - fi - if [ -n $csize ]; then - echo "%CSIZE%" >>$entry - echo "$csize" >>$entry - echo "" >>$entry - fi - if [ ! -z $pkgmd5sum ]; then - echo "%MD5SUM%" >>$entry - echo "$pkgmd5sum" >>$entry - echo "" >>$entry - fi - if [ ${#replaces[*]} -gt 0 ]; then - echo "%REPLACES%" >>desc - for it in "${replaces[@]}"; do - echo "$it" >>desc - done - echo "" >>desc - fi - if [ "$force" = "y" -o "$force" = "Y" -o "`check_option FORCE`" ]; then - echo "%FORCE%" >>desc - echo "" >>desc - fi - # depends - : >depends - if [ ${#depends[*]} -gt 0 ]; then - echo "%DEPENDS%" >>depends - for it in "${depends[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi - if [ ${#conflicts[*]} -gt 0 ]; then - echo "%CONFLICTS%" >>depends - for it in "${conflicts[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi - if [ ${#provides[*]} -gt 0 ]; then - echo "%PROVIDES%" >>depends - for it in "${provides[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi +die () { + error $* + exit 1 } -delete_entry() -{ - echo $1 | grep PKGBUILD 2>&1 >/dev/null - if [ $? -eq 0 ]; then - source $1 - else - pkgname=$1 - fi - for i in *; do - if [ "${i%-*-*}" = "$pkgname" ]; then - echo "updatesync: deleting $i" >&2 - rm -rf $i +check_force () { + local i + for i in ${options[@]}; do + local lc=$(echo $i | tr [:upper:] [:lower:]) + if [ "$lc" = "force" ]; then + true fi done + false } if [ $# -lt 3 ]; then @@ -181,71 +82,50 @@ exit 0 fi +if [ "$1" != "upd" -a "$1" != "del" ]; then + usage + exit 1 +fi + action=$1 pkgdb=$2 option=$3 -curdir="`pwd`" -pkgdir=$curdir +pkgdir="$(pwd)" if [ "$4" != "" ]; then - pkgdir=$4 + pkgdir="$4" fi +opt_force="" -if [ "$action" != "upd" -a "$action" != "del" ]; then - usage - exit 1 +if [ ! -f "$option" ]; then + die "$option not found" fi -ustmpdir=$(mktemp -d /tmp/updatesync.XXXXXXXXXX) || exit 1 +if [ "$action" = "upd" ]; then # INSERT / UPDATE + unset pkgname pkgver pkgrel options -cd $ustmpdir -if [ ! -f $pkgdb ]; then - if [ ! -f $curdir/$pkgdb ]; then - echo "updatesync: $pkgdb not found" - exit 1 - fi - pkgdb=$curdir/$pkgdb -fi + source $option || die "failed to parse $option" + pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT" -if [ "$action" = "upd" -a ! -f $option ]; then - if [ ! -f $curdir/$option ]; then - echo "updatesync: $option not found" - exit 1 + if [ ! -f "$pkgfile" ]; then + die "could not find $pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT - aborting" fi - option=$curdir/$option -fi -echo "updatesync: uncompressing to $ustmpdir..." >&2 -tar -xzf $pkgdb || die "error uncompressing $pkgdb" -if [ "$action" = "upd" ]; then - # INSERT / UPDATE - delete_entry $option - - source $option || die "errors parsing $option" - if [ "$pkgdir" != "" ]; then - pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" - else - pkgfile="$destdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" + if check_force; then + opt_force="--force" fi - if [ -f $pkgfile ]; then - csize=`du -b $pkgfile | cut -f1` - pkgmd5sum=`get_md5checksum $pkgfile` - [ -z $pkgmd5sum ] && die "error generating checksum for $pkgfile" - echo "updatesync: creating entry for $option" >&2 - db_write_entry $option || die "error writing entry for $option" + + repo-add "$pkgdb" $opt_force "$pkgfile" +else # DELETE + fname="$(basename $option)" + if [ "$fname" = "PKGBUILD" ]; then + unset pkgname pkgver pkgrel options + source $option else - echo "updatesync: missing package: $pkgfile" >&2 + pkgname=$1 fi -else - # DELETE - delete_entry $option -fi -echo "updatesync: compressing to $pkgdb..." >&2 -cd $ustmpdir -tar c * | gzip -9 >$pkgdb || die "error writing to $pkgdb" - -cd $curdir -rm -rf $ustmpdir + repo-remove "$pkgdb" "$pkgname" +fi exit 0 # vim: set ts=2 sw=2 noet: