This file is indexed.

/usr/bin/adt-testreport-onepackage is in autopkgtest 2.0.1ubuntu4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/bin/bash

set -e

salt=''
tmp=tmp
var=var
rsync=rsync
disable=true
interactive=true
target=source
suppressrepeatedemails=false
arch=`dpkg --print-architecture`
logheadmaxbytes=32768
logtailmaxbytes=32768
upload_src=false

for config in "$@"; do
	case "$config" in
	*=*)	eval "$config"	;;
	*)	. "$config"	;;
	esac
done

if $disable; then
	echo >&2 'disabled because config inadequate (no disable=false)'
	exit 1
fi

: ${destdirtail:=$distro-$target}
: ${destdirfin:="$destdircommon$destdirtail"}

case $target in
source)
	sources=Sources
	descx=''
	;;
binary-*)
	sources=Packages
	descx="${target#binary-}"
	;;
*)
	echo >&2 'target must be source or binary-*'
	exit 1
esac

exec 3>&1
printf >&3 "starting "

rm -rf "$tmp"
mkdir "$tmp"

>"$tmp"/_log_raw

if $interactive; then
	echo '(log diverted to stdout)' >>"$tmp"/_log_raw
else
	exec >>"$tmp"/_log_raw
fi
exec 4>&1

progress () {
	echo "++++++ $1 ++++++"
}

gurl () {
	progress "fetching $1"
	curl -fsS "$1" >"$2"
}

gurl "$mirror/dists/$distro/$suite/$target/$sources.gz" "$tmp"/_$sources.gz
zcat "$tmp"/_$sources.gz >"$tmp"/_$sources-in

lastinfo="$var"/lastinfo-$target
: "${scorelog:="$var"/scores-$target}"

now=`date +%s`
>>"$lastinfo"

progress selecting

if test $target = source; then
	blacklist="$blacklistsourcepackages"
else
	blacklist="$blacklistbinarypackages"
fi

if [ "x$pkg" = x ]; then
 pkg="`perl -e '
	use IO::Handle;

	$pre= "[-+.0-9a-z]+";
	$vre= "[-+.0-9a-zA-Z:~]+";

	sub f1() { $fn=shift @ARGV; open F, $fn or die "$fn $!"; }
	sub f2() { F->error and die "$fn $!"; close F or die "$fn $!"; }

	$scorelog= "'"$scorelog"'";
	if (length $scorelog) { open SCORE, "> $scorelog.new" or die $!; }
	sub pscore ($;$) {
		return unless length $scorelog;
		printf SCORE "%$_[1]s", $_[0] or die $!;
	}

	sub readpkglist ($$) {
		my ($arrayref, $filename) = @_;
		return unless length $filename;
		unshift @ARGV, $filename; f1();
		while (<F>) {
			next if m/^\#/ or !m/\S/;
			die unless m/^($pre)(?:\S.*)?\s*$/;
			$arrayref->{$1}= 1;
		}
		f2();
	}
	readpkglist(\%suppress, "'"$suppresspackages"'");
	readpkglist(\%blacklist, "'"$blacklist"'");

	f1();
	while (<F>) {
		die unless m/^($pre) ($vre) (\d+)( .*)?$/;
		$lastver{$1}= $2;
		$lasttime{$1}= $3;
		$extras{$1}= $4." ";
	}
	f2();
	f1();
	$best_score= -2e9;
	sub scorepackage () {
		return if length $skip;
		return if $blacklist{$package};
		return if $score < $best_score
		     or ($score==$best_score and \
			 $package gt $best_package);
#printf STDERR " <----- best score=%s best_score=%s\n", $score, $best_score;
		pscore(" (best)");
		$best_score= $score;
		$best_package= $package;
	}
	sub endpackage () {
		return unless (defined $package
				or defined $version
				or defined $skip
				or defined $source);
		die unless defined $package;
		die unless defined $version;
		$source= $package if !defined $source;

		$score= '$now' - $lasttime{$package};
		pscore("$package ",-30);
		pscore("$source ",-25);
		pscore("$score",10);

		if ($score>1e7) {
			$score= 1e7;
			$scorechars.='c';
		}
		pscore(" $lastver{$package}",-25);
		pscore(" $version ",-25);
		$scorechars= "";
		if ($lastver{$package} ne $version) {
			$score *= 5;
			$scorechars.="U";
		}
		if ($extras{$package} =~ m/ nt /) {
			$scorechars.="n";
		} else {
			$score *= 10;
		}
		if ($suppress{$source}) {
			$score -= 2e7;
			$scorechars.="s";
		}
		$scorechars.="[$skip]" if length $skip;

		pscore("-$scorechars",-7);
		pscore("$score",10);

#print STDERR "SCORE package=$package score $score source=$source\n";
		scorepackage();
		pscore("\n");
		undef $package;
		undef $version;
		undef $skip;
		undef $source;
	}
	while (<F>) {
		if (m/^Package: ($pre)$/) {
			die if defined $package;
			$package= $1;
		} elsif (m/^Version: ($vre)$/) {
			die if defined $version;
			$version= $1;
		} elsif (m/^Source: ($pre)$/) {
			die if defined $source;
			$source= $1;
		} elsif (m/^Architecture:.*/ &&
			 !m/\s(?:'$arch'|all|any)\s/) {
#printf STDERR " <----- skip %s %s\n", $&, "'$arch'";
			$skip .= 'a';
		} elsif (m/^$/) {
			endpackage();
		}
	}
	f2();
	endpackage();
	if (length $scorelog) {
		close SCORE or die $!;
		rename "$scorelog.new","$scorelog" or die $!;
	}
	die unless length $best_package;
	open L, ">&4" or die $!;
	printf L "selected %s (age %s, score %d)\n",
		$best_package,
		exists($lastime{$best_package})
		? '$now' - $lasttime{$best_package}
		: "<never-yet>",
		$best_score;
	print "$best_package\n" or die $!;
 ' "$lastinfo" "$tmp"/_$sources-in`"
else
	printf >&4 "package forced: %s\n" "$pkg"
fi

sed -n "/^Package: $pkg\$/,/^\$/p" \
 <"$tmp"/_$sources-in >"$tmp"/_this-stanza

echo
cat "$tmp"/_this-stanza

getfield () {
	eval 'p'$1'="`
		sed -n '\''s/^'$1': //p'\'' \
		 <"$tmp"/_this-stanza
	`"'
}

printf >&3 "selected \"%s\" " $pkg

tp="$tmp/$pkg"
mkdir "$tp" "$tp/src" "$tp/tmp" "$tp/out"

getfield Version

getfield Source
if [ "x$pSource" != x ]; then
	src="$pSource"
else
	src="$pkg"
fi

if test $target = source; then
	getfield Directory
	leafnames="`
		sed -n '/^Files:/,/^([^ ].*)?$/{ /^ /{
			s/^ [0-9a-z][0-9a-z]*  *[0-9][0-9]* //; p
			}}' \
		 <"$tmp"/_this-stanza
	`"
	for leafname in $leafnames; do
		df="$tp/src/$leafname"
		case "$leafname" in
		*/*|.*)	echo >&2 "bad leafname: $leafname"; exit 1;;
		*.dsc) fot="$df";;
		esac
		gurl "$mirror/$pDirectory/$leafname" "$df"
	done
	testmode=--source
	testmode2=''
	desc="$pkg"
	: ${upload_if_ok:=true}
	email_package_header="$email_sourcepackage_header"
else
	getfield Filename
	fot="$tp/src/$pkg.deb"
	gurl "$mirror/$pFilename" "$fot"
	testmode='--binaries=install --binary'
	testmode2=--instantiate
	desc="$pkg $descx"
	: ${upload_if_ok:=false}
	email_package_header="$email_binarypackage_header"
fi

if [ "x$maintainer_email_override" = x ]; then
	getfield Maintainer
	maintainer_email=pMaintainer
else
	maintainer_email=maintainer_email_override
fi

printf >&3 "adt-run "

progress "starting test"

xrc () {
	printf "+ %s\n" "$*"
	set +e
	"$@"
	rc=$?
	set -e
}

echo 'fatal: adt-run did not start properly' >"$tmp"/_summary

xrc adt-run --tmp-dir "$tp"/tmp				\
	--output-dir "$tp"/out				\
	--log-file "$tp"/log 				\
	--summary "$tmp"/_summary 			\
	$adtrun_extra_opts				\
	$testmode "$fot" $testmode2			\
 ---							\
 adt-virt-xenlvm					\
	$adtvirt_extra_opts				\
	--distro="$distro"				\
 --							\
 2>&1 3>&- 4>&-

printf >&3 "%s " $rc

ourx=0
upload=true
: ${upload_if_notests:=false}
extras=''

case "$rc" in
0)	summary='all OK';			email=''
					upload=$upload_if_ok		;;
2)	summary='OK (some skipped)';		email=''
					upload=$upload_if_ok		;;
8)	summary='package declares no tests';	email=''
				upload=$upload_if_notests; extras='nt'	;;
4|6)	summary='test(s) failed!';	email="$maintainer_email"	;;
12)	summary='erroneous package!';	email="$maintainer_email"	;;
16)	summary='testbed failed!';	email="administrator_email"	;;
*)	summary='unexpected failure!';	email="administrator_email"; ourx=20;;
esac

progress "RESULTS $summary"

if  [ "x$suppresspackages" != x ] \
 && grep -x "$src" "$suppresspackages" >/dev/null; then
	printf >&3 "email-suppressed "
	email=''
fi

if $upload; then
	progress "bundling"
	printf "\n%s\n" "$summary" >>"$tmp"/_summary

	edest=${email%_email}
	esummary="$var"/emailed/last-$pkg,$edest
	if [ "x$edest" = x ]; then
		printf >&3 "email-none "
		rm -f "$var"/emailed/last-$pkg,*
		esummary=''
	elif $suppressrepeatedemails \
	  && [ -f "$esummary" ] \
	  && diff -u "$esummary" "$tmp"/_summary >"$var"/emailed/diff-$pkg; then
		printf >&3 "email-same $email "
		email=''
		esummary=''
	else
		cp "$tmp"/_summary "$esummary".new
	fi

	ln -f "$tmp"/_summary "$tp"/summary

	for odir in tmp out; do
		if test -d "$tp"/$odir; then
			GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
			rm -r "$tp"/$odir
		fi
	done

	if ! $upload_src; then
		rm -r "$tp"/src
	fi

	progress "uploading"
	printf >&3 "uploading"
	$rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirfin/"
	printf >&3 " "
fi

if [ "x$email" != x ]; then
	progress "contacting $email"
	eval "email_addr=\$$email"
	printf >&3 "email \"%s\" " "$email_addr"
	cat >"$tmp"/_email_header <<END
From: $from
To: $email_addr
Subject: autopkgtest $distro $desc: $summary

END

	email_package_header="${email_package_header//@p/$pkg}"
	email_package_header="${email_package_header//@s/$src}"
	email_package_header="${email_package_header//@v/$pVersion}"
	email_package_header="${email_package_header//@_/@}"
	printf >"$tmp"/_email "%s" "$email_package_header"

	cat >>"$tmp"/_email <<END
 Test executed for:  $distro  $target  $pkg
 Outcome: $summary
END
	sed -e 's/^/  /' "$tmp"/_summary >>"$tmp"/_email
	cat >>"$tmp"/_email <<END

This message is automatically generated by the autopkgtest package
testing system.  You are receiving it because:
END
	case "$email" in
		pMaintainer)
			cat >>"$tmp"/_email <<END
 You are listed in the Maintainer field of the $pkg package in $distro
 and the test results appear to indicate a problem with the package.
END
			;;
		maintainer_email_override)
			cat >>"$tmp"/_email <<END
 The test results appear to indicate a problem with the package
 and reports for package maintainers for $distro are being directed to
 $maintainer_email_override
END
			;;
		administrator_email)
			cat >>"$tmp"/_email <<END
 You are the administrator for the autopkgtest installation.
END
			;;
		*)
			echo >&2 "huh email $email is what why?"
			exit 1
			;;
	esac
	cat >>"$tmp/_email" <<END

The top and tail of the test log, which is intended to be sufficient
to diagnose most failures, can be found below.  However, in case this
is not sufficient, a complete log can be found along with output
files, saved temporary files, and so on, at:
 $desthttphead/$destdirfin/
$email_extra_info
If you have any questions about this service please contact me at:
 $from

Regards,
$salutation

-8<-
END
fi

printf >>"$var"/log "%s=%s rc=%s emailed='%s'\n" \
	"$target" "$pkg" $rc "$email_addr"

if [ "x$ourx" = x0 ]; then
	sed -e "/^$pkg /d" <"$lastinfo" >"$lastinfo".new
	printf "%s %s %s %s\n" "$pkg" "$pVersion" "$now" "$extras" \
		>>"$lastinfo".new
	mv "$lastinfo".new "$lastinfo"
	progress "tested."
else
	progress "fault ($ourx)."
fi

perl <"$tmp"/_log_raw >"$tmp"/_log -ne '
	s/[^\012\040-\133\135-\176]/
		$& eq "\t" ? "\\t" :
		$& eq "\r" ? "\\r" :
		$& eq "\b" ? "\\b" :
		$& eq "\\" ? "\\\\" :
		sprintf "\\x%02x", ord $&
	/ge;

	if (!$middle) {
		$headlen += length;
		$middle=1 if $headlen > '"$logheadmaxbytes"';
	}
	if (!$middle) {
		print or die $!;
	} else {
		$taillen += length;
		push @tail, $_;
		while ($taillen > '"$logtailmaxbytes"') {
			$taillen -= length shift @tail;
			$some_dropped= 1;
		}
	}
	END {
		print "...\n" or die $! if $some_dropped;
		print @tail or die $!;
	}
'

if [ "x$email" = x ]; then
	if $interactive; then
		cat "$tmp"/_log >&2
	fi
else
	cat >>"$tmp"/_email 2>&1 "$tmp"/_log ||:

	if [ "x$email_signing_key" != x ]; then
		printf >&3 "signing "
		echo >>"$tmp/_email"
		gpg -u"$email_signing_key" --clearsign \
			<"$tmp/_email" >"$tmp/_email.asc"
		mv -f "$tmp/_email.asc" "$tmp/_email"
	fi
	cat "$tmp/_email_header" "$tmp/_email" >"$tmp/_email.new"
	mv -f "$tmp/_email.new" "$tmp/_email"

	if $interactive; then
		cat "$tmp"/_email >&2
	else
		sendmail -odi -oem -t -oi <"$tmp"/_email
		if [ "x$esummary" != x ]; then
			printf >&3 "email-recorded "
			mv "$esummary".new "esummary"
		fi
	fi
fi

printf >&3 "done %s.\n" $ourx
exit $ourx