#!/bin/awk -f
BEGIN {
	FS="\t"
}

$2 == "program-start" {
	emerge_count = 0;
	unmerge_count = 0;
	start_ts = $1;
	delete started;
}

$2 == "emerge-start" {
	started[$3]=$1;
}

$2 == "emerge-finish" {
	delete started[$3];
	emerge_count += 1;
}

$2 == "unmerge-finish" {
	unmerge_count += 1;
}

END {
	print "started: " start_ts " installed: " emerge_count " uninstalled: " unmerge_count
	for(cpv in started) {
		print started[cpv] "\t" cpv
	}
}