makedist/obsoleted/gen_target_lists.sh
2011-05-04 02:30:35 +02:00

64 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# gen_target_lists.sh
#
# Generates the lists of files of a given target
#
# Copyright (c) 2004-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# %1 - %n: Makefile targets
#
function expand_rpm_names() {
local f
for f in $1; do
find $RPMSDIR -regex ".*/${f//+/\\+}-[^-]*-[^-]*" -printf "%f " || echo "Warning: missing RPM file for $f"
done
}
function expand_srpm_names() {
local f
for f in $1; do
find $SRPMSDIR -regex ".*/${f//+/\\+}-[^-]*-[^-]*" -printf "%f " || echo "Warning: missing SRPM file for $f"
done
}
MAKEFILEDIR=/var/makedist/SOURCE/utils
RPMSDIR=/var/makedist/SOURCE/RPMS/i586/
SRPMSDIR=/var/makedist/SOURCE/SRPMS/
OUTDIR=/var/makedist/SOURCE
RPMOUT=$OUTDIR/rpms-list
SRPMOUT=$OUTDIR/srpms-list
#alltargets=`sed -n '/^qilinux-[^ ]*:/{s/:.*//g;p}' $MAKEFILEDIR/Makefile`
#echo $alltargets
#read
toinstall=`make -C $MAKEFILEDIR $@ -s 2>/dev/null`
#echo $toinstall
[ $? -ne 0 ] && { echo "Error in Makefile"; exit 1; }
rpms=`expand_rpm_names "$toinstall"`
srpms=`expand_srpm_names "$toinstall"`
rpmsfilesum=0
> $RPMOUT
for rpm in $rpms; do
filesize=`du -b $RPMSDIR$rpm | gawk '{ print $1 }'`
echo $rpm $filesize >> $RPMOUT
rpmsfilesum=`expr $rpmsfilesum + $filesize`
done
srpmsfilesum=0
> $SRPMOUT
for srpm in $srpms; do
filesize=`du -b $SRPMSDIR$srpm | gawk '{ print $1 }'`
echo $srpm $filesize >> $SRPMOUT
srpmsfilesum=`expr $srpmsfilesum + $filesize`
done
echo "Total: RPMS=$rpmsfilesum bytes SRPMS=$srpmsfilesum bytes"
#(cd $RPMSDIR && du -c -h $rpms | tail -n 1)