File: emrecent

package info (click to toggle)
emdebian-tools 1.4.3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,112 kB
  • ctags: 274
  • sloc: perl: 6,297; xml: 4,828; sh: 1,902; php: 406; ansic: 189; makefile: 15
file content (760 lines) | stat: -rwxr-xr-x 23,804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
#!/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