#!/bin/bash

# merge severla file lists into a single one

# Usage: merge-file-lists out_filelist in_filelist...

out=$1
shift

rm -f $out.new
touch $out.new
for list in $* ; do
    grep "^%dir" $list >>$out.new
    for file in `grep -v "^%dir" $list` ; do
	# FIXME: ignore some files that are in the file list but are not
	#        installed (mostly .rdb files)
	# accept invalid symlinks; absolute symlinks are broken because of $DESTDIR
	if test -e $DESTDIR$file -o -L $DESTDIR$file ; then
	    echo "$file" >>$out.new
	else
	    echo "WARNING: Ignoring in the file list: $file"
	fi
    done
    rm -f $list
done
sed -e "s|/./|/|g" $out.new | sort -u  >$out
rm $out.new
