Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/updatesync
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-02-12 06:07:11 +0000
committerAaron Griffin <aaron@archlinux.org>2007-02-12 06:07:11 +0000
commitf319dc080d73ef7f43b603aae0a32a6e77328303 (patch)
tree4cdca373da2507e51d7f8e2253ba69b60893a2df /scripts/updatesync
parent8a716abfb087f4fab7d0d1be5d9fb3afa944cf51 (diff)
Rewrote updatesync in terms of repo-add and repo-remove
Diffstat (limited to 'scripts/updatesync')
-rwxr-xr-xscripts/updatesync208
1 files changed, 44 insertions, 164 deletions
diff --git a/scripts/updatesync b/scripts/updatesync
index 17722fa3..a4a6847f 100755
--- a/scripts/updatesync
+++ b/scripts/updatesync
@@ -21,7 +21,7 @@
# USA.
#
-myver='2.9.8'
+myver='3.0.0'
usage() {
echo "updatesync $myver"
@@ -47,128 +47,29 @@ usage() {
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 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then
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: