#!/bin/bash
# Version: 0.0.1
# Copyright (c) 2017:
#   Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# diff_tagfiles - display the differences between two tagfile sets, ignoring priorities.
#

if [ $# -ne 2 ]; then
  echo "Usage: $0 <old dir> <new dir>"
  exit 1
fi

if [ ! -d "$1" -o ! -d "$2" ]; then
  echo "Directory doesn't exist."
  exit 1
fi

for D in a ap d e f k kde kdei l n t tcl x xap xfce y; do
  # Get the package lists without any priorities included.
  cat $1/$D/tagfile | cut -d: -f1 >/tmp/t.old.$$
  cat $2/$D/tagfile | cut -d: -f1 >/tmp/t.new.$$

  # Diff them.
  diff -u /tmp/t.old.$$ /tmp/t.new.$$ | \
    sed -e "s:/tmp/t\.old\.$$:$1/$D/tagfile:g" -e "s:/tmp/t\.new\.$$:$2/$D/tagfile:g"
done
