diff options
Diffstat (limited to 'pkgdb')
-rwxr-xr-x | pkgdb | 158 |
1 files changed, 0 insertions, 158 deletions
@@ -1,158 +0,0 @@ -#!/bin/bash - -tl=`pwd` - -repoid=$1 -# we use this instead of mktemp cuz the RH server's mktemp is broken :( -uid=`id -u` -TMPFILE="/tmp/.mysqltmp.$uid.$repoid.1" -TMPFILE2="/tmp/.mysqltmp.$uid.$repoid.2" - -dbuser='archweb' -dbname='archweb' -dbpass='YWkrOjqm' - -if [ "$repoid" = "" ]; then - me=`basename $0` - echo "usage: $me <repoid>" - exit 1 -fi - -deletepkg() -{ - echo "Deleting $pkgname" - mysql -u $dbuser -p$dbpass $dbname <<_EOF -DELETE FROM packages WHERE id='$id'; -_EOF - mysql -u $dbuser -p$dbpass $dbname <<_EOF -DELETE FROM todolist_pkgs WHERE pkgid='$id'; -_EOF -} - -updatepkg() -{ - echo "Updating $pkgname" - mysql -u $dbuser -p$dbpass $dbname <<_EOF -UPDATE packages SET categoryid='$categoryid',pkgname='$pkgname',pkgver='$pkgver', -pkgrel='$pkgrel',pkgdesc='$pkgdesc',url='$url',sources='$sources', -depends='$deplist',needupdate=0,lastupdate=NOW() WHERE id='$id'; -_EOF - mysql -u $dbuser -p$dbpass $dbname <<_EOF -UPDATE todolist_pkgs SET complete=1 WHERE pkgid='$id'; -_EOF -} - -insertpkg() -{ - echo "Inserting $pkgname" - mysql -u $dbuser -p$dbpass $dbname <<_EOF -INSERT INTO packages (id,repoid,categoryid,pkgname,pkgver,pkgrel, -pkgdesc,url,sources,depends,lastupdate) VALUES (NULL,$repoid, -'$categoryid','$pkgname','$pkgver','$pkgrel','$pkgdesc','$url', -'$sources','$deplist',NOW()); -_EOF -} - -process() { - pkg=$1 - - id=`echo $pkg | awk '{print $1}'` - pkgname=`echo $pkg | awk '{print $2}'` - oldver=`echo $pkg | awk '{print $3}'` - oldrel=`echo $pkg | awk '{print $4}'` - [ "$pkgname" = "" ] && return; - cd $tl - pkgdir=`find . -maxdepth 2 -mindepth 1 -type d -name "$pkgname" | head -1` - if [ "$pkgdir" = "" ]; then - deletepkg - else - cd $pkgdir - if [ ! -f PKGBUILD ]; then - echo "WARNING: missing PKGBUILD in `pwd`" >&2 - else - unset depends source deplist sources - unset pkgname pkgver pkgrel pkgdesc url - . PKGBUILD - # tag it - touch .tag - category=`pwd | sed "s|$tl/||" | sed 's|/.*$||'` - mysql --skip-column-names -u $dbuser -p$dbpass $dbname >$TMPFILE2 <<_EOF -SELECT id FROM categories WHERE category='$category'; -_EOF - categoryid=`cat $TMPFILE2 | awk '{print $1}'` - if [ "$categoryid" = "" ]; then - echo "WARNING: no categoryid found for '$category'" >&2 - fi - cd - &>/dev/null - deplist=${depends[@]} - deplist=`php -r "echo addslashes(\"$deplist\");"` - sources=${source[@]} - sources=`php -r "echo addslashes(\"$sources\");"` - pkgname=`php -r "echo addslashes(\"$pkgname\");"` - pkgver=`php -r "echo addslashes(\"$pkgver\");"` - pkgrel=`php -r "echo addslashes(\"$pkgrel\");"` - pkgdesc=`php -r "echo addslashes(\"$pkgdesc\");"` - url=`php -r "echo addslashes(\"$url\");"` - - if [ "$oldver" != "$pkgver" -o "$oldrel" != "$pkgrel" ]; then - updatepkg - fi - fi - fi -} - -echo "==> Updating Package Entries in Database..." -mysql --skip-column-names -u $dbuser -p$dbpass $dbname >$TMPFILE <<_EOF -SELECT id,pkgname,pkgver,pkgrel FROM packages WHERE repoid='$repoid'; -_EOF - -echo " -> Scanning for Updated/Deleted packages..." -cat $TMPFILE | ( \ - ln='a' - while [ "$ln" != "" ]; do - read ln - process "$ln" - done -) - -echo " -> Scanning for New packages..." -cd $tl -for category in `find . -maxdepth 1 -type d | grep -v CVS | grep -v "^extra" | grep -v "^unstable"`; do - category=`echo $category | sed 's|./||'` - if [ "$category" = "." ]; then - continue - fi - mysql --skip-column-names -u $dbuser -p$dbpass $dbname >$TMPFILE <<_EOF -SELECT id FROM categories WHERE category='$category'; -_EOF - categoryid=`cat $TMPFILE | awk '{print $1}'` - if [ "$categoryid" = "" ]; then - echo "WARNING: no categoryid found for '$category'" >&2 - fi - for pkg in `ls $category | sort`; do - cd $tl/$category/$pkg - if [ -f .tag ]; then - # already processed - rm -f .tag - else - if [ -f PKGBUILD ]; then - . PKGBUILD - deplist=${depends[@]} - deplist=`php -r "echo addslashes(\"$deplist\");"` - sources=${source[@]} - sources=`php -r "echo addslashes(\"$sources\");"` - pkgname=`php -r "echo addslashes(\"$pkgname\");"` - pkgver=`php -r "echo addslashes(\"$pkgver\");"` - pkgrel=`php -r "echo addslashes(\"$pkgrel\");"` - pkgdesc=`php -r "echo addslashes(\"$pkgdesc\");"` - url=`php -r "echo addslashes(\"$url\");"` - insertpkg - fi - fi - cd $tl - done -done - -rm -f $TMPFILE -exit 0 - |