hd.update 830 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Return associative array of fields from control file $file.
  2. sub slurp
  3. {
  4. local ($file) = @_;
  5. local (%controlinfo);
  6. local (%ci);
  7. open (CONTROL, $file) || return 1;
  8. # Get entire text of control file.
  9. undef $/; $* = 1; $_ = <CONTROL>;
  10. # Join lines.
  11. s/\n[ \t]+/ /g;
  12. # Split on fields.
  13. %controlinfo = ('PRESTUFF', split (/^(\S+):\s*/));
  14. $/ = "\n"; $* = 0;
  15. foreach $key (keys %controlinfo)
  16. {
  17. $key2 = $key; $key2 =~ y/A-Z/a-z/;
  18. chop ($controlinfo{$key}) if (/\n/);
  19. $ci{$key2} = $controlinfo{$key};
  20. }
  21. return %ci;
  22. }
  23. $file = "/var/lib/dpkg/methods/hd/hd.status";
  24. %info = slurp($file);
  25. open (IN, "<$info{'avail'}") || die "can't open $info{'avail'}";
  26. open (OUT, ">/var/lib/dpkg/available") || die "can't open /var/lib/dpkg/available";
  27. print OUT while (<IN>);
  28. close IN;
  29. close OUT;