#!/usr/bin/perl

=pod

=head1 Name

emrecent - Inspect recent Emdebian builds and automate uploads

=cut

=head1 Copyright and Licence

 Copyright (C) 2008  Neil Williams <codehelp@debian.org>

 This package is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

=cut

use Cwd;
use Config::Auto;
use File::HomeDir;
use File::Basename;
use File::Spec;
use Emdebian::Tools;
use Debian::DpkgCross;
use Dpkg::Version qw(compare_versions);
use Term::ANSIColor qw(:constants);
use strict;
use warnings;
use vars qw/$workdir $msg $changes $arch $progname $our_version
 $timelimit $whiptail $skip $title $text $cmd @list $pbuild 
 $exclude $respawn %seen %seentdeb $autobuild $dput_cfg /;

$progname = basename($0);
$our_version = &tools_version();
$pbuild = 0;
$exclude = 0;
%seen = ();
$respawn = 0;
$dput_cfg="";
&read_config();
$arch = &get_architecture();
$timelimit = 7;

sub usageversion {
	print(STDERR <<END)
$progname version $our_version

Usage:
$progname [-a|--arch ARCH] [-s|--skip-check] [-t|--time DAYS]
$progname [-a|--arch ARCH] [-s|--skip-check] FILENAME
$progname [-a|--arch ARCH] --noninteractive [--dput-cfg FILE] [FILENAME]
$progname -?|-h|--help|--version

Options:
 -a|--arch ARCH:      Set architecture (default: defined by dpkg-cross)
 -t|--time DAYS:      Number of days to consider as 'recent'.
 -s|--skip:           Skip the emdebcheck (use with care).
 -w|--whiptail:       Use whiptail even if zenity is installed.
 -p|--pbuilder:       Inspect the pbuilder result directories.
    --noninteractive: Autobuilder mode.
    --dput-cfg FILE:  Alternative dput config file to make a noninteractive
                       upload.
 -x|--exclude-error:  Exclude packages that have existing emrecent error logs.
 -r|--respawn:        Reload emrecent with the same options at the end
                       of the upload.

$progname is a simple helper to check for recently modified .changes files
that have not been uploaded, view the details of the build using zenity
(a GNOME dialog utility) and deb-gview (a .deb file viewer for GNOME) then
sign the .changes file and upload if you consider the build is usable.

To check a single .changes file, specify the file on the command line.
$progname will only offer this package for viewing and possible upload.

If zenity is not installed, whiptail can be used instead.

Errors detected when viewing the build data are logged in emrecent_error.log
in the trunk directory of the build. Details of the error are reported via
'emsource --status \$package'. Packages with $progname error logs cannot be
uploaded by $progname until the log file is removed.

If --time is not specified, any .changes file beneath your Emdebian working
directory that has been modified in the last 7 days but which is not
accompanied by a .upload file will be listed by $progname.

$progname needs 'dput' to be properly configured in order to make the
final upload. See http://wiki.debian.org/Embedded_Debian_packaging_infrastructure

See emrecent.1 for information on noninteractive mode.

END
		or die "$0: failed to write usage: $!\n";
}

while( @ARGV ) {
	$_= shift( @ARGV );
	last if m/^--$/;
	if (!/^-/) {
		unshift(@ARGV,$_);
		last;
	}
	elsif (/^(-\?|-h|--help|--version)$/) {
		&usageversion();
		exit (0);
	}
	elsif (/^(-a|--arch)$/) {
		$arch = shift(@ARGV);
	}
	elsif (/^(-w|--whiptail)$/) {
		$whiptail = 1;
	}
	elsif (/^(-t|--time)$/) {
		$timelimit = shift(@ARGV);
	}
	elsif (/^(-s|--skip)$/) {
		$skip = 1;
	}
	elsif (/^(-p|--pbuild)$/) {
		$pbuild = 1;
	}
	elsif (/^(-x|--exclude)$/) {
		$exclude = 1;
	}
	elsif (/^(-r|--respawn)$/) {
		$respawn = 1;
	}
	elsif (/^(--noninteractive)$/) {
		$autobuild = 1;
		$pbuild = 1;
	}
	elsif (/^(--dput-cfg)$/) {
		$dput_cfg = shift (@ARGV);
		die ("Unable to use '$dput_cfg' - no such file.\n")
			if (! -f "$dput_cfg");
		$dput_cfg = "-c $dput_cfg";
	}
	else
	{
		&usageversion();
		die "unrecognised option:  $_.\n";
	}
}

# read emsource config file.
$workdir = &get_workdir;
$workdir = "/" if ($workdir eq "");
if ($pbuild > 0)
{
	$workdir .= "/pbuilder/result/";
	die (RED, "Unable to find any empdebuild results!",RESET,"\n")
		unless (-d $workdir);
	print GREEN, "Locating recent .changes files in your empdebuild results directory....\n",
		RESET if (not defined $autobuild);
}
else
{
	$workdir.= "/trunk/";
	$msg = &check_workdir($workdir);
	die RED, $msg, RESET, "\n" if ($msg ne "");
	print GREEN, "Locating recent .changes files in your Emdebian working directory....\n", RESET;
}
$workdir =~ s://:/:;

$title = "Unable to find zenity, falling back to whiptail.";
$text = "$title\nIf zenity is installed, $progname will use that instead.";
$cmd = qq/whiptail --backtitle "$title" --clear --msgbox "$text" 10 50/;
if ((! -x "/usr/bin/zenity") and (not defined $autobuild))
{
	$whiptail=1;
	system ("$cmd");
}

$text = "$progname is unable to use dialog for interactive mode, please install
whiptail or zenity to use $progname.";
die ("$text\n") if ((! -x "/usr/bin/whiptail") and (defined $whiptail)
	and (not defined $autobuild));

my $limit = "-$timelimit";
$title="Inspect build results";
$text="Select one .changes file from this list of recent builds\n";
$text.="in $workdir.\n";
$text.="Packages with existing error logs are indicated." if ($exclude == 0);
$cmd = qq/find "$workdir" -maxdepth 4 -mtime $limit -a -name "*.changes"/;
if (@ARGV) { push @list, @ARGV; }
else { @list = `$cmd`; }
my %select=();
my %index=();
my %tdebs=();
# just offer the filenames.
foreach my $file (sort @list)
{
	chomp($file);
	$changes = (File::Spec->file_name_is_absolute($file)) ? $changes = $file :
		$changes = File::Spec->rel2abs($file);
	open (CHANGES, "$changes") or die ("Cannot read $changes. $!");
	my @data=<CHANGES>;
	close (CHANGES);
	my $content = join("\n", @data);
	$content =~ s/Version: GnuPG v1.4.6//;
	$content =~ /Version:\s+(.*)/;
	my $vers = $1;
	$content = join("", @data);
	my $pkg;
	if ($content =~ /Source:\s+/)
	{
		$content =~ /Source:\s+(.*)/;
		$pkg = $1;
	}
	next if (not defined $pkg);
	my $dir = dirname($changes);
	my $file = basename($changes);
	if ((defined $seen{$pkg}) and ($vers !~ /tdeb/))
	{
		next if (&compare_versions($seen{$pkg}, '>=', $vers) ? 1 : 0);
		$seen{$pkg} = $vers;
		$select{$pkg}='';
	}
	# compare tdeb versions separately
	if ((defined $seentdeb{$pkg}) and ($vers =~ /tdeb/))
	{
		next if (&compare_versions($seentdeb{$pkg}, '>=', $vers) ? 1 : 0);
		$seentdeb{$pkg} = $vers;
		$select{"${pkg}_tdeb"}='';
	}
	my $sans_epoch = $vers;
	$sans_epoch =~ s/[0-9]://;
	next if (-f "$dir/${pkg}_${sans_epoch}_$arch.upload");
	next if ((-f "$dir/${pkg}_${vers}.upload") and ($vers =~ /tdeb/));
	# in autobuild mode, (noninteractive), target and tdeb .changes files
	# are handled at the same time (target first). If target fails,
	# the TDeb .changes is not processed so ignore the -Error suffix.
	$file = "${pkg}_${vers}-Error" 
		if ((-f "$dir/${progname}_error.log") and (not defined $autobuild));
	next if ((-f "$dir/${progname}_error.log") and ($exclude > 0));
	$select{$pkg}=$file if $vers !~ /tdeb/;
	$select{"${pkg}_tdeb"}=$file if $vers =~ /tdeb/;
	$seen{$pkg} = $vers if $vers !~ /tdeb/;
	$seentdeb{$pkg} = $vers if $vers =~ /tdeb/;
	$tdebs{$file}=$dir if $vers =~ /tdeb/;
	$index{$file}=$dir;
}
&noninteractive if (defined $autobuild);
exit unless (keys %select);
my $str;
my $select;
if (defined $whiptail)
{
	my @short=();
	$title =~ s/\n/\\n/g;
	$text =~ s/\n/\\n/g;
	my $i = 14;
	my @list = values %select;
	$i = scalar @list if (scalar @list < 14);
	for (my $c=0; $c < $i; $c++)
	{
		my $t = $list[$c];
		my $l = "";
		$l = "-locale" if ($t =~ /tdeb/);
		$t =~ s/_.*//;
		push @short, $list[$c] . " $t$l";
	}
	$str = join(" ", @short);
	# even the cpan module creates a temporary file to get the menu selection.
	my $file = `mktemp -t whiptailXXXXXX` or die ("unable to create temp file.\n");
	chomp($file);
	my $h = $i + 10;
	$cmd = qq/whiptail --title "$title" --menu "$text" $h 60 $i/;
	system("$cmd $str 2> $file");
	my $ret;
	open (TEMP, "$file") or die ("Cannot open $file: $!\n");
	$select=<TEMP>;
	close TEMP;
	unlink ($file);
	exit unless (defined $select);
}
else
{
	$cmd = qq/zenity --list --title "$title" --text "$text" --column "Files"/;
	my @l = values %select;
	$str = join(" ", sort @l);
	$select = `$cmd $str`;
	chomp($select);
	exit if ($select eq "");
}
die "error: unable to find packages" unless (defined($index{$select}));
chdir($index{$select});
&report_log if ($select =~ /Error/);
$select =~ /(.*)_.*_$arch.changes$/;
my $pkg = $1;
if (defined $whiptail)
{
	$title = "Running lintian on the .changes file";
	$cmd = qq/whiptail --gauge "$title" 10 40 10/;
	open (GAUGE, "|$cmd");
}
else { print "Running lintian on the .changes file . . . \n"; }
$str = `lintian --allow-root -oC em $select`;
close GAUGE if (defined $whiptail);
if ($? != 0)
{
	$title = "lintian errors have been found for $pkg";
	&write_report ($title, "You can add your own notes to the error log.\n",$str);
	exit (1);
}
if ($str ne "")
{
	$title = "Lintian warnings found for $pkg.";
	$text = "lintian found Emdebian-specific warnings that are not ";
	$text .= "related to any existing Debian warnings:\n";
	my @lines = split("\n", $str);
	my $i = (scalar @lines < 12) ? scalar @lines : 12;
	for (my $c=0; $c < $i; $c++)
	{
		$text .= pop(@lines)."\n";
	}
	$text .= "Do you want to continue despite the warning?";
	$text .= "Click OK or press Enter to accept, click Cancel or press Esc to exit.";
	if (defined $whiptail)
	{
		$cmd = qq/whiptail --title "$title" --yesno "$text" 20 60/;
	}
	else
	{
		$cmd = qq/zenity --question --title "$title" --text "$text"/;
	}
	my $dgv = system("$cmd");
	if ($dgv != 0)
	{
		$title = "lintian warnings have been found in $pkg";
		&write_report ($title, "You can add your own notes to the error log.\n",$str);
		die ("\n");
	}
}

# use deb-gview to see inside the packaged files.
if ((-x "/usr/bin/deb-gview") and (not defined $whiptail))
{
	$title="Use deb-gview?";
	$text="Do you want to view $pkg with deb-gview?\n";
	$text.="deb-gview allows you to view each package as well as the\n";
	$text.= "contents of packaged text files, one window for each .deb.\n";
	$text.="(This can be particularly useful for configuration files,";
	$text.=" generated content and maintainer scripts.)\n";
	$text.="$progname will continue only once you close all deb-gview ";
	$text.="windows opened from $select.\n";
	$cmd = qq/zenity --question --title "$title" --text "$text"/;
	my $dgv = system("$cmd");
	if ($dgv == 0)
	{
		system("deb-gview ./$select");
	}
}
# still recommended to view the debc output prior to upload
$title="debc -a $arch $select";
$str=`debc -a $arch ./$select 2>/dev/null`;
my $file = `mktemp -t zenityXXXXXX` or die ("unable to create temp file.\n");
chomp($file);
open (TEMP, ">$file") or die ("Cannot open $file: $!\n");
print TEMP $str;
close TEMP;
$title="Please verify the contents of the built packages...";
if (defined $whiptail)
{
	$cmd = qq/whiptail --scrolltext --title "$title" --textbox "$file" 20 70/;
}
else
{
	$cmd = qq/zenity --text-info --title "$title" --width=540 --height=400 --filename $file/;
}
system ("$cmd");
unlink ($file);
$title="Is $pkg ready for upload?";
$text="Is $select ready for upload?\n";
my @filelist = `dcmd ls $select`;
chomp(@filelist);

if (scalar @filelist > 10)
{
	my @tmp = ();
	@tmp = @filelist;
	my @short = splice (@filelist, 0, 9);
	push @short, "...\n";
	$text.=join("\n", @short);
	@filelist = ();
	@filelist = @tmp;
}
else
{
	$text.=join("\n", @filelist);
}
$text.="Click OK or press Enter to accept, click Cancel or press Esc to skip";
if (defined $whiptail)
{
	$cmd = qq/whiptail --title "$title" --yesno "$text" 20 60/;
}
else
{
	$cmd = qq/zenity --question --title "$title" --text "$text"/;
}

my $sign = system("$cmd");
die "Aborting...\n" if ($sign != 0);
# check contents of .changes file with edos-debcheck.

if ((not defined $tdebs{$select}) and (not defined $skip))
{
	my @paths = ();
	foreach my $deb (@filelist)
	{
		# skip -dev packages.
		if ($deb =~ /-dev_/)
		{
			print RED, "skipping -dev package: '$deb'\n", RESET;
			next;
		}
		if ($deb !~ /\.deb$/)
		{
			print RED, "skipping '$deb'\n", RESET;
			next;
		}
		push @paths, $deb;
	}
	my $str = join(" ", @paths);
	my $res = system ("emdebcheck $str");
	&report_log if ($res);
}

if ( -e "/usr/bin/gpg")
{
	my $sig = `gpg --verify $select 2>/dev/null`;
	system ("debsign $select") if (( $? != 0)and (-f $select));
	if (! -x "/usr/bin/dput")
	{
		$title = "Cannot execute dput";
		$text = qq%Please install dput and configure %;
		$text .= qq% ~/.dput.cf for the emdebian repositories.\n%;
		$text .= qq%sudo apt-get install dput%;
		if (defined $whiptail)
		{
			$cmd = qq%whiptail --title "$title" --msgbox "$text" 20 60%;
		}
		else
		{
			$cmd = qq%zenity --error --title="$title" %;
			$cmd .= qq% --text=""%;
		}
		system ("$cmd");
		exit;
	}
	my $dputlist = `dput -H`;
	if (($dputlist =~ /emdebian-locale/) and ($dputlist =~ /emdebian-target/)
		and (-f $select))
	{
		if (defined $tdebs{$select})
		{
			print "Uploading $select to emdebian-locale\n";
			system ("dput emdebian-locale $select");
		}
		else
		{
			print "Uploading $select to emdebian-target\n";
			system ("dput emdebian-target $select");
		}
		exit if ($? != 0);
		# need the package name here.
		system ("embug -r -p $pkg") if (not defined $tdebs{$select});
		exit if ($respawn == 0);
		my $spawn = "$0 -a $arch ";
		$spawn .= "-w " if (defined $whiptail);
		$spawn .= "-t $timelimit ";
		$spawn .= "-p " if ($pbuild > 0);
		$spawn .= "-x " if ($exclude > 0);
		$spawn .= "-r";
		exec ("$spawn");
	}
	else
	{
		$title = "dput is not configured for Emdebian.";
		$text = qq%Please install dput and configure %;
		$text .= qq% ~/.dput.cf for the Emdebian repositories.\n%;
		$text .= qq%See http://wiki.debian.org/Embedded_Debian_packaging_infrastructure"%;
		if (defined $whiptail)
		{
			$cmd = qq%whiptail  --title "$title" --msgbox "$text" 20 60%;
		}
		else
		{
			$cmd = qq%zenity --error --title="$title" --text="$text"%;
		}
		system ("$cmd");
		exit;
	}
}
else
{
	&write_report ("Details for the error log", "Add a log entry for $pkg", "");
}

# Only supports running one changes file at a time
# so that errors can be traced back to the right package.
# Exits with non-zero upon any failure.
# 2 == lintian
# 4 == edos-debcheck
# other values may come from dput.
# All output is added to the LOGFILE for the package.
sub noninteractive
{
	my $retval = 0;
	my @t = keys (%select);
	my $chg = $t[0];
	my @paths = ();
	my $file = $index{$select{$chg}}.'/'.$select{$chg};
	exit ($retval) if ($file =~ /-Error$/);
	$str = `lintian --allow-root -oC em $file`;
	if ($str ne "")
	{
		# Add the standard embug report message to the build log.
		# i.e. only use --quiet for the flag removal.
		system ("embug -q -r -p $chg");
		system ("embug --lintian -p $chg");
		exit (2);
	}
	my @filelist = `dcmd ls $file`;
	chomp(@filelist);
	foreach my $deb (@filelist)
	{
		# skip -dev packages.
		next if ($deb =~ /-dev_/);
		next if ($deb !~ /\.deb$/);
		push @paths, $deb;
	}
	$str = join(" ", @paths);
	my $res = system ("emdebcheck -q $str");
	if ($res > 0)
	{
		# Add the standard embug report message to the build log.
		system ("embug -q -r -p $chg");
		system ("embug -w -p $chg");
		exit (4);
	}
	# upload with dput -u to avoid need for gpg key
	# still need an SSH key and a bespoke config.
	$retval = system ("dput $dput_cfg -u emdebian-locale $file") 
		if (defined $tdebs{$file});
	$retval = system ("dput $dput_cfg -u emdebian-target $file")
		if (not defined $tdebs{$file});
	$retval = $retval >> 8 if ($retval != 0);
	system ("embug -q -r -p $chg") if ($retval == 0);
	exit ($retval);
}

sub write_report
{
	$title = shift;
	$text = shift;
	my $extra = shift;
	if (defined $whiptail)
	{
		my $file = `mktemp -t whiptailXXXXXX` or die ("unable to create temp file.\n");
		chomp($file);
		$cmd = qq/whiptail --title "$title" --inputbox "$text\n$extra" 30 60/;
		system("$cmd 2> $file");
		my $ret;
		open (TEMP, "$file") or die ("Cannot open $file: $!\n");
		$extra=<TEMP>;
		close TEMP;
		unlink ($file);
	}
	else
	{
		$cmd = qq/zenity --entry --title="$title" --height=200 /;
		$cmd .= qq/--width=300 --text="$text\n$extra"/;
		$extra .= `$cmd`;
	}
	my $default;
	if (! -f "${progname}_error.log")
	{
		$default = "There could be a problem with this build.\n";
		$default .= "$progname was used to view the build but upload was refused.\n";
		$default .= "Explanation follows, (if entered):\n";
	}
	open (FLAG, ">>${progname}_error.log") or die ("Cannot create log file");
	print FLAG $default if (defined $default);
	print FLAG $extra;
	print FLAG `date`;
	close FLAG;
}

sub report_log
{
	$title="$progname error log found :";
	open (LOG, "./${progname}_error.log") or die ("Cannot open error log. $!\n");
	my @log=<LOG>;
	close (LOG);
	my $name = "\nRemove " . $index{$select} . "/${progname}_error.log\n when the error ".
		"has been fixed.";
	push @log, $name;
	$text = join(" ", @log);
	$text =~ s/\n/\\n/g;
	if (defined $whiptail)
	{
		$cmd = qq/whiptail --title "$title" --msgbox "$text" 20 60/;
	}
	else
	{
		$cmd = qq/zenity --error --no-wrap --title="$title" --text="$text"/;
	}
	system("$cmd");
	# whiptail users can miss this bit, so repeat at the end.
	print "\nRemove " . $index{$select} . "/${progname}_error.log\n when the error ".
		"has been fixed.\n\n" if (defined $whiptail);
	exit;
}

=head1 Usage

 emrecent [-a|--arch ARCH] [-s|--skip-check] [-t|--time DAYS] [-p|--pbuilder]
  [-x|--exclude-error] [-r|--respawn]
 emrecent [-a|--arch ARCH] [-s|--skip-check] FILENAME
 emrecent [-a|--arch ARCH] [-p|--pbuilder] --noninteractive [--dput-cfg FILE]
 emrecent -?|-h|--help|--version

=cut

=head1 Options

 -a|--arch ARCH:      Set architecture (default: defined by dpkg-cross)
 -t|--time DAYS:      Number of days to consider as 'recent'.
 -s|--skip:           Skip the emdebcheck (use with care).
 -w|--whiptail:       Use whiptail even if zenity is installed.
 -p|--pbuilder:       Inspect the pbuilder result directories.
    --noninteractive: Autobuilder mode.
    --dput-cfg FILE:  Alternative dput config file to make a noninteractive
                       upload.
 -x|--exclude-error:  Exclude packages that have existing emrecent error logs.
 -r|--respawn:        Reload emrecent with the same options at the end
                       of the upload.

=cut

=head1 Description

emrecent is a simple helper to check for recently modified .changes files
that have not been uploaded, view the details of the build using zenity
(a GNOME dialog utility) and deb-gview (a .deb file viewer for GNOME) then
sign the .changes file and upload if you consider the build is usable.

To check a single .changes file, specify the file on the command line.
emrecent will only offer this package for viewing and possible upload
(regardless of any timelimit setting).

Errors detected when viewing the build data are logged in emrecent_error.log
in the trunk directory of the build. Details of the error are reported via
'emsource --status $package'. Packages with emrecent error logs cannot be
uploaded by emrecent until the log file is removed.

If --time is not specified, any .changes file beneath your Emdebian working
directory that has been modified in the last 7 days but which is not
accompanied by a .upload file will be listed by emrecent.

emrecent needs 'dput' to be properly configured in order to make the
final upload. See http://wiki.debian.org/Embedded_Debian_packaging_infrastructure

By default, emrecent runs emdebcheck on each package listed in the .changes
file (except locale packages which have no dependencies) and reports an
emrecent error if emdebcheck fails. It may be a simple case of uploading
the dependency package first, it may be a case of fixing a broken package
before uploading the fix for the current package.

This is an important check to preserve archive integrity but sometimes a
build contains some good packages and some that would be expected to fail.
emrecent always skips -dev packages as these are unlikely to ever be installable
(and certainly not usable) on an embedded system without a compiler and
also skips all tdeb packages. If emrecent reports an error from emdebcheck,
view the emrecent error log and/or run emdebcheck manually to verify whether
the error affects a package that is likely to be installed on the embedded
device. Then remove the emrecent error log file and pass the -s option to
emrecent to skip the edos-debcheck.

Under certain circumstances, it may be necessary to use emrecent with
packages built with empdebuild in a build chroot. The '-p|--pbuilder' option
allows emrecent to scan the 'pbuilder/result' directory tree. Note that
when using 'emrecent -p', error logs are put into the same 'pbuilder/result/'
directory tree, as are .upload files. Wherever possible, packages should be
buildable inside and outside a chroot so do try to fix the package. (You can
also pass a single filename to emrecent.)

=cut

=head1 Options

 -x|--exclude-error:  Exclude packages that have existing emrecent error logs.

Allow emrecent to ignore existing emrecent error logs if you have a lot
of packages to view and upload.

 -r|--respawn:        Reload emrecent with the same options at the end
                       of the upload.

If everything appeared to work for the previous upload, restart emrecent
with the same options to allow you to make a series of uploads.

Note that --skip is automatically reset when using --respawn because
--skip should be used only for specific packages.

Care is needed not to cause unnecessary errors in respawn mode - the order
in which you review packages is the order in which they are uploaded which
can mean that viable packages gets tagged with emrecent errors simply because
that package was reviewed before all the dependencies were uploaded. (The
data used for edos-debcheck is refreshed each time emrecent respawns.)

Remember to keep an eye on the controlling terminal - there are too many
messages generated during an upload to put the entire content in a zenity
or whiptail interface.

Try not to upload the tdeb before the package of the same version.

=cut

=head1 Noninteractive mode

Noninteractive mode is currently experimental and may well change again.
The main intention is for noninteractive mode to only support autobuilders.
emrecent tries to be as quiet as possible (although apt downloads for
emdebcheck do tend to be noisy) and lintian errors or emdebcheck failures
cannot be skipped.

For noninteractive mode, a different SSH key or different connection method
may be necessary - so an alternate dput.cfg file is explicitly supported
for this mode. The dput config should support uploading hosts called:

 emdebian-target - the application and library packages
 emdebian-locale - the TDebs.

These are just labels - you are free to use the label to refer to any
upload destination, not exclusively www.emdebian.org.

Configuring SSH and dput are beyond the scope of this manpage. See
the ssh, dput and dput.cf manpages for more information.

=cut

=head1 See Also

emdebcheck (1), emsource (1), embug (1), emdebian-tools (1),
em_autobuild (1), dput (1), dput.cf (5), ssh (1), ssh-keygen (1).

=cut
