diff options
Diffstat (limited to 'methods/hd.update')
-rwxr-xr-x | methods/hd.update | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/methods/hd.update b/methods/hd.update new file mode 100755 index 000000000..98bf56b35 --- /dev/null +++ b/methods/hd.update @@ -0,0 +1,37 @@ +# Return associative array of fields from control file $file. +sub slurp +{ + local ($file) = @_; + local (%controlinfo); + local (%ci); + + open (CONTROL, $file) || return 1; + + # Get entire text of control file. + undef $/; $* = 1; $_ = <CONTROL>; + + # Join lines. + s/\n[ \t]+/ /g; + + # Split on fields. + %controlinfo = ('PRESTUFF', split (/^(\S+):\s*/)); + + $/ = "\n"; $* = 0; + foreach $key (keys %controlinfo) + { + $key2 = $key; $key2 =~ y/A-Z/a-z/; + chop ($controlinfo{$key}) if (/\n/); + $ci{$key2} = $controlinfo{$key}; + } + + return %ci; +} + +$file = "/var/lib/dpkg/methods/hd/hd.status"; +%info = slurp($file); +open (IN, "<$info{'avail'}") || die "can't open $info{'avail'}"; +open (OUT, ">/var/lib/dpkg/available") || die "can't open /var/lib/dpkg/available"; +print OUT while (<IN>); +close IN; +close OUT; + |