#!/usr/bin/perl -w

=head1 NAME

dh_germinate_clean - clean up files left by germinate-update-metapackage

=cut

use strict;

use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_germinate_clean> [S<B<debhelper options>>]

=head1 DESCRIPTION

dh_germinate_clean is a debhelper program that cleans up some files created
by C<germinate-update-metapackage> that are useful for debugging but that
should not appear in source packages. It removes any C<*.old> files that
match defined seeds (as listed in the C<metapackage-map> file by a previous
run of C<germinate-update-metapackage>), and the C<debootstrap-dir> file.

=head1 EXAMPLES

dh_germinate_clean is usually called indirectly in a rules file via the dh
command.

	%:
		dh $@ --with germinate

You must build-depend on at least debhelper (>= 7.0.8) to use this form, and
in any case you must build-depend on at least germinate (>= 1.18) to use
this program at all.

It can also be called directly in the clean target at any time before
dh_clean.

	clean:
		dh_testdir
		dh_germinate_clean
		dh_clean

=cut

init();

open MAP, 'metapackage-map' or die "Can't open metapackage-map: $!";
while (<MAP>) {
	chomp;
	my ($seed, $metapackage) = split;
	complex_doit("rm -f $seed-*.old");
}
close MAP;

doit("rm", "-f", "debootstrap-dir");

=head1 SEE ALSO

L<debhelper(7)>, L<germinate-update-metapackage(1)>

This program is a part of germinate.

=head1 AUTHOR

Colin Watson <cjwatson@ubuntu.com>

Copyright (C) 2009 Canonical Ltd., licensed under the GNU GPL v2 or later.

=cut
