#!/bin/sh
PKGDIRS="/mnt/raid_amd64/ALT/branches/Sisyphus-branch-3.0/files/noarch/RPMS:/mnt/raid_amd64/ALT/branches/Sisyphus-branch-3.0/files/i386/RPMS:/mnt/raid_amd64/ALT/branches/Sisyphus-branch-3.0/files/i586/RPMS"
DSTDR=/tmp/tmp-menu-files
TMPDR=/tmp/tmp-menu

rm -rf $DSTDR; mkdir -p $DSTDR
rm -rf $TMPDR; mkdir -p $TMPDR
echo "$PKGDIRS" | sed "s|:|\n|g" | \
while read d
do
    pushd $d
    ls -1 | \
    while read p
    do
	if rpm -qpl $p| grep -e^/usr/lib/menu >/dev/null
	then
	    echo $p
	    pushd $TMPDR > /dev/null
		rm -rf $TMPDR/*
		rpm2cpio ${d}/${p} > pkg.cpio
		cat pkg.cpio |cpio -i --make-directories >/dev/null 2>&1
		mv -f usr/lib/menu/* $DSTDR ||:
		chmod -R a+rwx $TMPDR/*
		rm -rf $TMPDR/*
	    popd > /dev/null
	fi
    done
done

rm -rf rm -rf $TMPDR
echo "Menu files may be found in $DSTDR"
