[Frugalware-darcs] frugalware-current: testsuite/fpmjunk

VMiklos vmiklos at frugalware.org
Sun Oct 1 01:42:47 CEST 2006


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=frugalware-current;a=darcs_commitdiff;h=20060930234047-e2957-bf631e2c823957cc0bbb25d10b976d17a1318de7.gz;

[testsuite/fpmjunk
VMiklos <vmiklos at frugalware.org>**20060930234047
 rewritten in python, since using alpm searching those old fpms is much more
 faster
] {
addfile ./testsuite/fpmjunk
hunk ./testsuite/fpmjunk 1
+#!/usr/bin/env python
+
+import alpm, os, tempfile, shutil, sys, re
+
+if len(sys.argv) > 1 and sys.argv[1] == "--help":
+	print "finds no longer necessary fpms"
+	sys.exit(0)
+
+for i in os.listdir(".."):
+	if not re.match("^frugalware-", i):
+		continue
+	arch = i[11:]
+	root = tempfile.mkdtemp()
+	alpm.initialize(root)
+	if os.getcwd().split('/')[-2] == "frugalware-current":
+		treename = "frugalware-current"
+	else:
+		treename = "frugalware"
+	db = alpm.db_register(treename)
+	alpm.db_setserver(db, "file://" + os.getcwd() + "/../frugalware-" + arch)
+	alpm.db_update(1, db)
+	fdb = []
+	j = alpm.db_getpkgcache(db)
+	while j:
+		pkg = alpm.void_to_PM_PKG(alpm.list_getdata(j))
+		pkgname = alpm.void_to_char(alpm.pkg_getinfo(pkg, alpm.PKG_NAME))
+		pkgver = alpm.void_to_char(alpm.pkg_getinfo(pkg, alpm.PKG_VERSION))
+		fdb.append("%s-%s-%s.fpm" % (pkgname, pkgver, arch))
+		j = alpm.list_next(j)
+	alpm.release()
+	shutil.rmtree(root)
+	for j in os.listdir(os.getcwd() + "/../frugalware-" + arch):
+		if j not in fdb and j != treename + ".fdb":
+			print "frugalware-" + arch + "/" + j
hunk ./testsuite/fpmjunk.sh 1
-#!/bin/bash
-
-if [ "$#" -lt 3 ]; then
-	echo "searches for old fpm files"
-	echo "usage: $0 [--remove] <startdir> <repomane> <arch>"
-	exit 1
-fi
-
-# fake variable for fwmakepkg
-CHROOT=1
-
-. functions
-. /usr/lib/frugalware/fwmakepkg
-
-if [ "$1" == "--remove" ]; then
-	remove="y"
-	shift
-fi
-startdir=$1
-reponame=$2
-arch=$3
-
-newfpms=`mktemp`
-allfpms=`mktemp`
-fdbfpms=`mktemp`
-
-echo $reponame.fdb >$newfpms
-cd $startdir
-for i in `find source -maxdepth 5 -name FrugalBuild`
-do
-	cd `dirname $i` || continue
-	unset pkgname pkgver pkgrel nobuild options archs
-	unset subpkgs suboptions subarchs
-	source FrugalBuild || echo "errors parsing the FrugalBuild (`pwd`/FrugalBuild)"
-	if [ ! -z "$pkgname" -a ! -z "$pkgver" -a ! -z "$pkgrel" ]; then
-		if in_array $arch ${archs[@]} && [ ! "$nobuild" -a ! "`check_option NOBUILD`" ]; then
-			echo "$pkgname-$pkgver-$pkgrel-$arch.fpm" >>$newfpms
-		fi
-	fi
-	if [ ! -z "$pkgver" -a ! -z "$pkgrel" -a ! -z "$subpkgs" ] && [ ! "$nobuild" -a ! "`check_option NOBUILD`" ]; then
-		j=0
-		for subpkg in "${subpkgs[@]}"
-		do
-			unset archs
-			archs="${subarchs[$j]}"
-			if in_array $arch ${archs[@]}; then
-				echo "$subpkg-$pkgver-$pkgrel-$arch.fpm" >>$newfpms
-			fi
-			j=$(($j+1))
-		done
-	fi
-	cd - >/dev/null
-done
-
-tar tzf frugalware-$arch/$reponame.fdb|grep /$|sed "s|/$|-$arch.fpm|" >$fdbfpms
-
-cat $newfpms |sort >$newfpms.sorted
-mv -f $newfpms.sorted $newfpms
-cd frugalware-$arch
-ls >$allfpms
-for i in `diff -u $allfpms $newfpms |grep ^-[^-] |sed 's/^-//'`
-do
-	# check if the fpm is in the fdb. if yes, then do not remove this fpm
-	# it's outdated, but there isn't any newer version for this arch
-	if ! grep -q $i $fdbfpms; then
-		[ -z "$remove" ] && echo $i || rm -v $i
-	fi
-done
-rm -f $allfpms $newfpms $fdbfpms
rmfile ./testsuite/fpmjunk.sh
hunk ./testsuite/fpmjunkall.sh 1
-#!/bin/bash
-
-if [ "$#" -lt "1" ]; then
-	echo "$0: calls fpmjunks.sh for each repo & arch"
-	echo "usage: $0 <startdir> [--remove]"
-	exit 1
-fi
-
-startdir=$1
-
-archs=('i686' 'x86_64' 'ppc')
-
-cd $startdir
-for i in "${archs[@]}"
-do
-	if [ -e ../frugalware-$i/frugalware-current.fdb ]; then
-		sh fpmjunk.sh $2 .. frugalware-current $i
-	fi
-	if [ -e ../extra/frugalware-$i/extra-current.fdb ]; then
-		sh fpmjunk.sh $2 ../extra extra-current $i
-	fi
-done
rmfile ./testsuite/fpmjunkall.sh
}


More information about the Frugalware-darcs mailing list