install.pl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. #!/usr/bin/perl
  2. #
  3. # Copyright © 1996 Andy Guy <awpguy@acs.ucalgary.ca>
  4. # Copyright © 1998 Martin Schulze <joey@infodrom.north.de>
  5. # Copyright © 1999, 2009 Raphaël Hertzog <hertzog@debian.org>
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; version 2 of the License.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. use strict;
  19. use warnings;
  20. eval q{
  21. pop @INC if $INC[-1] eq '.';
  22. use Net::FTP;
  23. use File::Path qw(make_path remove_tree);
  24. use File::Basename;
  25. use File::Find;
  26. use Data::Dumper;
  27. };
  28. if ($@) {
  29. warn "Please install the 'perl' package if you want to use the\n" .
  30. "FTP access method of dselect.\n\n";
  31. exit 1;
  32. }
  33. use Dselect::Ftp;
  34. my $ftp;
  35. # exit value
  36. my $exit = 0;
  37. # deal with arguments
  38. my $vardir = $ARGV[0];
  39. my $method = $ARGV[1];
  40. my $option = $ARGV[2];
  41. if ($option eq 'manual') {
  42. print "manual mode not supported yet\n";
  43. exit 1;
  44. }
  45. #print "vardir: $vardir, method: $method, option: $option\n";
  46. my $methdir = "$vardir/methods/ftp";
  47. # get info from control file
  48. read_config("$methdir/vars");
  49. chdir "$methdir";
  50. make_path("$methdir/$CONFIG{dldir}", { mode => 0755 });
  51. #Read md5sums already calculated
  52. my %md5sums;
  53. if (-f "$methdir/md5sums") {
  54. local $/;
  55. open(my $md5sums_fh, '<', "$methdir/md5sums")
  56. or die "couldn't read file $methdir/md5sums";
  57. my $code = <$md5sums_fh>;
  58. close $md5sums_fh;
  59. my $VAR1; ## no critic (Variables::ProhibitUnusedVariables)
  60. my $res = eval $code;
  61. if ($@) {
  62. die "couldn't eval $methdir/md5sums content: $@\n";
  63. }
  64. if (ref($res)) { %md5sums = %{$res} }
  65. }
  66. # get a block
  67. # returns a ref to a hash containing flds->fld contents
  68. # white space from the ends of lines is removed and newlines added
  69. # (no trailing newline).
  70. # die's if something unexpected happens
  71. sub getblk {
  72. my $fh = shift;
  73. my %flds;
  74. my $fld;
  75. while (<$fh>) {
  76. if (length != 0) {
  77. FLDLOOP: while (1) {
  78. if ( /^(\S+):\s*(.*)\s*$/ ) {
  79. $fld = lc($1);
  80. $flds{$fld} = $2;
  81. while (<$fh>) {
  82. if (length == 0) {
  83. return %flds;
  84. } elsif ( /^(\s.*)$/ ) {
  85. $flds{$fld} = $flds{$fld} . "\n" . $1;
  86. } else {
  87. next FLDLOOP;
  88. }
  89. }
  90. return %flds;
  91. } else {
  92. die "expected a start of field line, but got:\n$_";
  93. }
  94. }
  95. }
  96. }
  97. return %flds;
  98. }
  99. # process status file
  100. # create curpkgs hash with version (no version implies not currently installed)
  101. # of packages we want
  102. print "Processing status file...\n";
  103. my %curpkgs;
  104. sub procstatus {
  105. my (%flds, $fld);
  106. open(my $status_fh, '<', "$vardir/status") or
  107. die 'Could not open status file';
  108. while (%flds = getblk($status_fh), %flds) {
  109. if($flds{'status'} =~ /^install ok/) {
  110. my $cs = (split(/ /, $flds{'status'}))[2];
  111. if (($cs eq 'not-installed') ||
  112. ($cs eq 'half-installed') ||
  113. ($cs eq 'config-files')) {
  114. $curpkgs{$flds{'package'}} = '';
  115. } else {
  116. $curpkgs{$flds{'package'}} = $flds{'version'};
  117. }
  118. }
  119. }
  120. close($status_fh);
  121. }
  122. procstatus();
  123. sub dcmpvers {
  124. my($a, $p, $b) = @_;
  125. my ($r);
  126. $r = system('dpkg', '--compare-versions', "$a", "$p", "$b");
  127. $r = $r/256;
  128. if ($r == 0) {
  129. return 1;
  130. } elsif ($r == 1) {
  131. return 0;
  132. }
  133. die "dpkg --compare-versions $a $p $b - failed with $r";
  134. }
  135. # process package files, looking for packages to install
  136. # create a hash of these packages pkgname => version, filenames...
  137. # filename => md5sum, size
  138. # for all packages
  139. my %pkgs;
  140. my %pkgfiles;
  141. sub procpkgfile {
  142. my $fn = shift;
  143. my $site = shift;
  144. my $dist = shift;
  145. my (@files, @sizes, @md5sums, $pkg, $ver, $nfs, $fld);
  146. my(%flds);
  147. open(my $pkgfile_fh, '<', $fn) or die "could not open package file $fn";
  148. while (%flds = getblk($pkgfile_fh), %flds) {
  149. $pkg = $flds{'package'};
  150. $ver = $curpkgs{$pkg};
  151. @files = split(/[\s\n]+/, $flds{'filename'});
  152. @sizes = split(/[\s\n]+/, $flds{'size'});
  153. @md5sums = split(/[\s\n]+/, $flds{'md5sum'});
  154. if (defined($ver) && (($ver eq '') || dcmpvers($ver, 'lt', $flds{'version'}))) {
  155. $pkgs{$pkg} = [ $flds{'version'}, [ @files ], $site ];
  156. $curpkgs{$pkg} = $flds{'version'};
  157. }
  158. $nfs = scalar(@files);
  159. if(($nfs != scalar(@sizes)) || ($nfs != scalar(@md5sums)) ) {
  160. print "Different number of filenames, sizes and md5sums for $flds{'package'}\n";
  161. } else {
  162. my $i = 0;
  163. foreach my $fl (@files) {
  164. $pkgfiles{$fl} = [ $md5sums[$i], $sizes[$i], $site, $dist ];
  165. $i++;
  166. }
  167. }
  168. }
  169. close $pkgfile_fh or die "cannot close package file $fn: $!\n";
  170. }
  171. print "\nProcessing Package files...\n";
  172. my ($fn, $i, $j);
  173. $i = 0;
  174. foreach my $site (@{$CONFIG{site}}) {
  175. $j = 0;
  176. foreach my $dist (@{$site->[2]}) {
  177. $fn = $dist;
  178. $fn =~ tr#/#_#;
  179. $fn = "Packages.$site->[0].$fn";
  180. if (-f $fn) {
  181. print " $site->[0] $dist...\n";
  182. procpkgfile($fn,$i,$j);
  183. } else {
  184. print "Could not find packages file for $site->[0] $dist distribution (re-run Update)\n"
  185. }
  186. $j++;
  187. }
  188. $i++;
  189. }
  190. my $dldir = $CONFIG{dldir};
  191. # md5sum
  192. sub md5sum($) {
  193. my $fn = shift;
  194. my $m = qx(md5sum $fn);
  195. $m = (split(' ', $m))[0];
  196. $md5sums{"$dldir/$fn"} = $m;
  197. return $m;
  198. }
  199. # construct list of files to get
  200. # hash of filenames => size of downloaded part
  201. # query user for each paritial file
  202. print "\nConstructing list of files to get...\n";
  203. my %downloads;
  204. my ($dir, @info, @files, $csize, $size);
  205. my $totsize = 0;
  206. foreach my $pkg (keys(%pkgs)) {
  207. @files = @{$pkgs{$pkg}[1]};
  208. foreach my $fn (@files) {
  209. #Look for a partial file
  210. if (-f "$dldir/$fn.partial") {
  211. rename "$dldir/$fn.partial", "$dldir/$fn";
  212. }
  213. $dir = dirname($fn);
  214. if(! -d "$dldir/$dir") {
  215. make_path("$dldir/$dir", { mode => 0755 });
  216. }
  217. @info = @{$pkgfiles{$fn}};
  218. $csize = int($info[1]/1024)+1;
  219. if(-f "$dldir/$fn") {
  220. $size = -s "$dldir/$fn";
  221. if($info[1] > $size) {
  222. # partial download
  223. if (yesno('y', "continue file: $fn (" . nb($size) . '/' .
  224. nb($info[1]) . ')')) {
  225. $downloads{$fn} = $size;
  226. $totsize += $csize - int($size/1024);
  227. } else {
  228. $downloads{$fn} = 0;
  229. $totsize += $csize;
  230. }
  231. } else {
  232. # check md5sum
  233. if (! exists $md5sums{"$dldir/$fn"}) {
  234. $md5sums{"$dldir/$fn"} = md5sum("$dldir/$fn");
  235. }
  236. if ($md5sums{"$dldir/$fn"} eq $info[0]) {
  237. print "already got: $fn\n";
  238. } else {
  239. print "corrupted: $fn\n";
  240. $downloads{$fn} = 0;
  241. }
  242. }
  243. } else {
  244. my $ffn = $fn;
  245. $ffn =~ s/binary-[^\/]+/.../;
  246. print 'want: ' .
  247. $CONFIG{site}[$pkgfiles{$fn}[2]][0] . " $ffn (${csize}k)\n";
  248. $downloads{$fn} = 0;
  249. $totsize += $csize;
  250. }
  251. }
  252. }
  253. my $avsp = qx(df -Pk $dldir| awk '{ print \$4}' | tail -n 1);
  254. chomp $avsp;
  255. print "\nApproximate total space required: ${totsize}k\n";
  256. print "Available space in $dldir: ${avsp}k\n";
  257. #$avsp = qx(df -k $::dldir| paste -s | awk '{ print \$11});
  258. #chomp $avsp;
  259. if($totsize == 0) {
  260. print 'Nothing to get.';
  261. } else {
  262. if($totsize > $avsp) {
  263. print "Space required is greater than available space,\n";
  264. print "you will need to select which items to get.\n";
  265. }
  266. # ask user which files to get
  267. if (($totsize > $avsp) ||
  268. yesno('n', 'Do you want to select the files to get')) {
  269. $totsize = 0;
  270. my @files = sort(keys(%downloads));
  271. my $def = 'y';
  272. foreach my $fn (@files) {
  273. my @info = @{$pkgfiles{$fn}};
  274. my $csize = int($info[1] / 1024) + 1;
  275. my $rsize = int(($info[1] - $downloads{$fn}) / 1024) + 1;
  276. if ($rsize + $totsize > $avsp) {
  277. print "no room for: $fn\n";
  278. delete $downloads{$fn};
  279. } else {
  280. if(yesno($def, $downloads{$fn}
  281. ? "download: $fn ${rsize}k/${csize}k (total = ${totsize}k)"
  282. : "download: $fn ${rsize}k (total = ${totsize}k)")) {
  283. $def = 'y';
  284. $totsize += $rsize;
  285. } else {
  286. $def = 'n';
  287. delete $downloads{$fn};
  288. }
  289. }
  290. }
  291. }
  292. }
  293. sub download() {
  294. my $i = 0;
  295. foreach my $site (@{$CONFIG{site}}) {
  296. my @getfiles = grep { $pkgfiles{$_}[2] == $i } keys %downloads;
  297. my @pre_dist = (); # Directory to add before $fn
  298. #Scan distributions for looking at "(../)+/dir/dir"
  299. my ($n,$cp);
  300. $cp = -1;
  301. foreach (@{$site->[2]}) {
  302. $cp++;
  303. $pre_dist[$cp] = '';
  304. $n = (s{\.\./}{../}g);
  305. next if (! $n);
  306. if (m<^((?:\.\./){$n}(?:[^/]+/){$n})>) {
  307. $pre_dist[$cp] = $1;
  308. }
  309. }
  310. if (! @getfiles) { $i++; next; }
  311. $ftp = do_connect ($site->[0], #$::ftpsite,
  312. $site->[4], #$::username,
  313. $site->[5], #$::password,
  314. $site->[1], #$::ftpdir,
  315. $site->[3], #$::passive,
  316. $CONFIG{use_auth_proxy},
  317. $CONFIG{proxyhost},
  318. $CONFIG{proxylogname},
  319. $CONFIG{proxypassword});
  320. local $SIG{INT} = sub { die "Interrupted !\n"; };
  321. my ($rsize, $res, $pre);
  322. foreach my $fn (@getfiles) {
  323. $pre = $pre_dist[$pkgfiles{$fn}[3]] || '';
  324. if ($downloads{$fn}) {
  325. $rsize = ${pkgfiles{$fn}}[1] - $downloads{$fn};
  326. print "getting: $pre$fn (" . nb($rsize) . '/' .
  327. nb($pkgfiles{$fn}[1]) . ")\n";
  328. } else {
  329. print "getting: $pre$fn (". nb($pkgfiles{$fn}[1]) . ")\n";
  330. }
  331. $res = $ftp->get("$pre$fn", "$dldir/$fn", $downloads{$fn});
  332. if(! $res) {
  333. my $r = $ftp->code();
  334. print $ftp->message() . "\n";
  335. if (!($r == 550 || $r == 450)) {
  336. return 1;
  337. } else {
  338. #Try to find another file or this package
  339. print "Looking for another version of the package...\n";
  340. my ($dir, $package) = ($fn =~ m{^(.*)/([^/]+)_[^/]+.deb$});
  341. my $list = $ftp->ls("$pre$dir");
  342. if ($ftp->ok() && ref($list)) {
  343. foreach my $file (@{$list}) {
  344. if ($file =~ m/($dir\/\Q$package\E_[^\/]+.deb)/i) {
  345. print "Package found : $file\n";
  346. print "getting: $file (size not known)\n";
  347. $res = $ftp->get($file, "$dldir/$1");
  348. if (! $res) {
  349. $r = $ftp->code();
  350. print $ftp->message() . "\n";
  351. return 1 if ($r != 550 and $r != 450);
  352. }
  353. }
  354. }
  355. }
  356. }
  357. }
  358. # fully got, remove it from list in case we have to re-download
  359. delete $downloads{$fn};
  360. }
  361. $ftp->quit();
  362. $i++;
  363. }
  364. return 0;
  365. }
  366. # download stuff (protect from ^C)
  367. if($totsize != 0) {
  368. if (yesno('y', "\nDo you want to download the required files")) {
  369. DOWNLOAD_TRY: while (1) {
  370. print "Downloading files... use ^C to stop\n";
  371. eval {
  372. if ((download() == 1) &&
  373. yesno('y', "\nDo you want to retry downloading at once")) {
  374. next DOWNLOAD_TRY;
  375. }
  376. };
  377. if($@ =~ /Interrupted|Timeout/i ) {
  378. # close the FTP connection if needed
  379. if ((ref($ftp) =~ /Net::FTP/) and ($@ =~ /Interrupted/i)) {
  380. $ftp->abort();
  381. $ftp->quit();
  382. undef $ftp;
  383. }
  384. print "FTP ERROR\n";
  385. if (yesno('y', "\nDo you want to retry downloading at once")) {
  386. # get the first $fn that foreach would give:
  387. # this is the one that got interrupted.
  388. MY_ITER: foreach my $ffn (keys(%downloads)) {
  389. $fn = $ffn;
  390. last MY_ITER;
  391. }
  392. my $size = -s "$dldir/$fn";
  393. # partial download
  394. if (yesno('y', "continue file: $fn (at $size)")) {
  395. $downloads{$fn} = $size;
  396. } else {
  397. $downloads{$fn} = 0;
  398. }
  399. next DOWNLOAD_TRY;
  400. } else {
  401. $exit = 1;
  402. last DOWNLOAD_TRY;
  403. }
  404. } elsif ($@) {
  405. print "An error occurred ($@) : stopping download\n";
  406. }
  407. last DOWNLOAD_TRY;
  408. }
  409. }
  410. }
  411. # remove duplicate packages (keep latest versions)
  412. # move half downloaded files out of the way
  413. # delete corrupted files
  414. print "\nProcessing downloaded files...(for corrupt/old/partial)\n";
  415. my %vers; # package => version
  416. my %files; # package-version => files...
  417. # check a deb or split deb file
  418. # return 1 if it a deb file, 2 if it is a split deb file
  419. # else 0
  420. sub chkdeb($) {
  421. my ($fn) = @_;
  422. # check to see if it is a .deb file
  423. if(!system("dpkg-deb --info $fn 2>&1 >/dev/null && dpkg-deb --contents $fn 2>&1 >/dev/null")) {
  424. return 1;
  425. } elsif(!system("dpkg-split --info $fn 2>&1 >/dev/null")) {
  426. return 2;
  427. }
  428. return 0;
  429. }
  430. sub getdebinfo($) {
  431. my ($fn) = @_;
  432. my $type = chkdeb($fn);
  433. my ($pkg, $ver);
  434. if($type == 1) {
  435. open(my $pkgfile_fh, '-|', "dpkg-deb --field $fn")
  436. or die "cannot create pipe for 'dpkg-deb --field $fn'";
  437. my %fields = getblk($pkgfile_fh);
  438. close($pkgfile_fh);
  439. $pkg = $fields{'package'};
  440. $ver = $fields{'version'};
  441. return $pkg, $ver;
  442. } elsif ( $type == 2) {
  443. open(my $pkgfile_fh, '-|', "dpkg-split --info $fn")
  444. or die "cannot create pipe for 'dpkg-split --info $fn'";
  445. while (<$pkgfile_fh>) {
  446. /Part of package:\s*(\S+)/ and $pkg = $1;
  447. /\.\.\. version:\s*(\S+)/ and $ver = $1;
  448. }
  449. close($pkgfile_fh);
  450. return $pkg, $ver;
  451. }
  452. print "could not figure out type of $fn\n";
  453. return $pkg, $ver;
  454. }
  455. # process deb file to make sure we only keep latest versions
  456. sub prcdeb($$) {
  457. my ($dir, $fn) = @_;
  458. my ($pkg, $ver) = getdebinfo($fn);
  459. if(!defined($pkg) || !defined($ver)) {
  460. print "could not get package info from file\n";
  461. return 0;
  462. }
  463. if($vers{$pkg}) {
  464. if (dcmpvers($vers{$pkg}, 'eq', $ver)) {
  465. $files{$pkg . $ver} = [ $files{$pkg . $ver }, "$dir/$fn" ];
  466. } elsif (dcmpvers($vers{$pkg}, 'gt', $ver)) {
  467. print "old version\n";
  468. unlink $fn;
  469. } else { # else $ver is gt current version
  470. foreach my $c (@{$files{$pkg . $vers{$pkg}}}) {
  471. print "replaces: $c\n";
  472. unlink "$vardir/methods/ftp/$dldir/$c";
  473. }
  474. $vers{$pkg} = $ver;
  475. $files{$pkg . $ver} = [ "$dir/$fn" ];
  476. }
  477. } else {
  478. $vers{$pkg} = $ver;
  479. $files{$pkg . $ver} = [ "$dir/$fn" ];
  480. }
  481. }
  482. sub prcfile() {
  483. my ($fn) = $_;
  484. if (-f $fn and $fn ne '.') {
  485. my $dir = '.';
  486. if (length($File::Find::dir) > length($dldir)) {
  487. $dir = substr($File::Find::dir, length($dldir)+1);
  488. }
  489. print "$dir/$fn\n";
  490. if(defined($pkgfiles{"$dir/$fn"})) {
  491. my @info = @{$pkgfiles{"$dir/$fn"}};
  492. my $size = -s $fn;
  493. if($size == 0) {
  494. print "zero length file\n";
  495. unlink $fn;
  496. } elsif($size < $info[1]) {
  497. print "partial file\n";
  498. rename $fn, "$fn.partial";
  499. } elsif(( (exists $md5sums{"$dldir/$fn"})
  500. and ($md5sums{"$dldir/$fn"} ne $info[0]) )
  501. or
  502. (md5sum($fn) ne $info[0])) {
  503. print "corrupt file\n";
  504. unlink $fn;
  505. } else {
  506. prcdeb($dir, $fn);
  507. }
  508. } elsif($fn =~ /.deb$/) {
  509. if(chkdeb($fn)) {
  510. prcdeb($dir, $fn);
  511. } else {
  512. print "corrupt file\n";
  513. unlink $fn;
  514. }
  515. } else {
  516. print "non-debian file\n";
  517. }
  518. }
  519. }
  520. find(\&prcfile, "$dldir/");
  521. # install .debs
  522. if (yesno('y', "\nDo you want to install the files fetched")) {
  523. print "Installing files...\n";
  524. #Installing pre-dependent package before !
  525. my (@flds, $package, @filename, $r);
  526. while (@flds = qx(dpkg --predep-package), $? == 0) {
  527. foreach my $field (@flds) {
  528. $field =~ s/\s*\n//;
  529. $package = $field if $field =~ s/^Package: //i;
  530. @filename = split / +/, $field if $field =~ s/^Filename: //i;
  531. }
  532. @filename = map { "$dldir/$_" } @filename;
  533. next if (! @filename);
  534. $r = system('dpkg', '-iB', '--', @filename);
  535. if ($r) { print "DPKG ERROR\n"; $exit = 1; }
  536. }
  537. #Installing other packages after
  538. $r = system('dpkg', '-iGREOB', $dldir);
  539. if($r) {
  540. print "DPKG ERROR\n";
  541. $exit = 1;
  542. }
  543. }
  544. sub removeinstalled {
  545. my $fn = $_;
  546. if (-f $fn and $fn ne '.') {
  547. my $dir = '.';
  548. if (length($File::Find::dir) > length($dldir)) {
  549. $dir = substr($File::Find::dir, length($dldir)+1);
  550. }
  551. if($fn =~ /.deb$/) {
  552. my($pkg, $ver) = getdebinfo($fn);
  553. if(!defined($pkg) || !defined($ver)) {
  554. print "Could not get info for: $dir/$fn\n";
  555. } else {
  556. if ($curpkgs{$pkg} and dcmpvers($ver, 'le', $curpkgs{$pkg})) {
  557. print "deleting: $dir/$fn\n";
  558. unlink $fn;
  559. } else {
  560. print "leaving: $dir/$fn\n";
  561. }
  562. }
  563. } else {
  564. print "non-debian: $dir/$fn\n";
  565. }
  566. }
  567. }
  568. # remove .debs that have been installed (query user)
  569. # first need to reprocess status file
  570. if (yesno('y', "\nDo you wish to delete the installed package (.deb) files?")) {
  571. print "Removing installed files...\n";
  572. %curpkgs = ();
  573. procstatus();
  574. find(\&removeinstalled, "$dldir/");
  575. }
  576. # remove whole ./debian directory if user wants to
  577. if (yesno('n', "\nDo you want to remove $dldir directory?")) {
  578. remove_tree($dldir);
  579. }
  580. #Store useful md5sums
  581. foreach my $file (keys %md5sums) {
  582. next if -f $file;
  583. delete $md5sums{$file};
  584. }
  585. open(my $md5sums_fh, '>', "$methdir/md5sums")
  586. or die "can't open $methdir/md5sums in write mode: $!\n";
  587. print { $md5sums_fh } Dumper(\%md5sums);
  588. close $md5sums_fh;
  589. exit $exit;