#!/bin/sh
sqlite3 "$REPOCOP_TEST_TMPDIR/tmp.db" <<EOSQL
attach database '$REPOCOP_TEST_DBDIR/rpm.db' as rpm;
attach database '$REPOCOP_TEST_DBDIR/rpm-ext.db' as rpmext;
.mode tabs
.output $REPOCOP_TEST_TMPDIR/msg
-- filedir conflict
-- http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/pkgformat.html
-- only direct name conflicts; not good
-- note: 580 is RPMFILE_DONOTUSE (1 << 2) + RPMFILE_GHOST (1 << 6) + RPMFILE_EXCLUDE (1 << 9)
-- a.FILENAME, 
select distinct a.pkgid, b.pkgid FROM rpm_files as a LEFT JOIN rpm as c ON a.pkgid=c.pkgid, rpm_files as b  LEFT JOIN rpm as d ON b.pkgid=d.pkgid WHERE a.pkgid<>b.pkgid and a.filename=b.filename and a.fileflag & 580 = 0 and b.fileflag & 580 = 0 and a.filemode & 61440 = 32768 and b.filemode & 61440 = 32768 and (a.filemode & 4095 <> b.filemode & 4095 or a.FILEUSERNAME<>b.FILEUSERNAME OR a.FILEGROUPNAME<>b.FILEGROUPNAME or a.FILESIZE <> b.FILESIZE) AND   c.name <> d.name AND a.pkgid NOT IN (select conflictee FROM explicit_conflict WHERE conflicter=b.pkgid) AND b.pkgid NOT IN (select conflictee FROM explicit_conflict WHERE conflicter=a.pkgid) AND a.pkgid NOT IN (select obsoletee FROM explicit_obsolete WHERE obsoleter=b.pkgid) AND b.pkgid NOT IN (select obsoletee FROM explicit_obsolete WHERE obsoleter=a.pkgid);
EOSQL
#perl -ne 'chomp;@a=split /\t/;system(qw/repocop-test-info -k/,$a[0], "file $a[1] conflicts with the same file in a file in the package $a[2]. Moreover, the packages have no explicit conflicts with each other. You should add explicit conflicts, or, if conflicts are avoidable, consider using alternatives.")' $REPOCOP_TEST_TMPDIR/msg
perl -ne 'chomp;@a=split /\t/;system(qw/repocop-test-warn -k/,$a[0], "There are file conflicts with the package $a[1]. Moreover, the packages have no explicit conflicts with each other. You should add explicit conflicts, or, if conflicts are avoidable, consider using alternatives.")' $REPOCOP_TEST_TMPDIR/msg
rm $REPOCOP_TEST_TMPDIR/*
