3 # Written by Fernando Alegre <alegre@debian.org> 1996
5 # Applied patch by Dimitri Maziuk <emaziuk@curtin.edu.au> 1997
6 # (to handle new tar format)
8 # Modified by Fernando Alegre <alegre@debian.org> 1997
9 # (to handle both new and old tar formats)
11 # Modified by Patrik Rak <prak@post.cz> 1998
12 # (add by Michael Bramer Debian-mc-maintainer <grisu@debian.org>)
13 # (to allow access to package control files)
15 # Modified by Martin Bialasinski <martinb@debian.org> 1999
16 # (deal with change in tar format)
19 # Copyright (C) 1997 Free Software Foundation
24 s/([^\w\/.+-])/\\$1/g;
31 # CAVEAT: Hard links are listed as if they were symlinks
32 # Empty directories do not appear at all
34 local($archivename)=@_;
35 local $qarchivename = quote($archivename);
36 chop($date=`LC_ALL=C date "+%b %d %H:%M"`);
37 chop($info_size=`dpkg -I $qarchivename | wc -c`);
38 $install_size=length($pressinstall);
40 print "dr-xr-xr-x 1 0 0 0 $date CONTENTS\n";
41 print "dr-xr-xr-x 1 0 0 0 $date DEBIAN\n";
42 print "-r--r--r-- 1 0 0 $info_size $date INFO\n";
43 print "-r-xr--r-- 1 0 0 $install_size $date INSTALL\n";
45 if ( open(PIPEIN, "LC_ALL=C dpkg-deb -c $qarchivename |") )
51 $perm=$_[0]; $owgr=$_[1]; $size=$_[2];
52 if($_[3] =~ /^\d\d\d\d\-/) { # New tar format
54 ($year,$mon,$day) = split(/-/,$_[3]);
55 $month = ("Gee","Jan","Feb","Mar","Apr","May","Jun",
56 "Jul","Aug","Sep","Oct","Nov","Dec")[$mon] || "Gee";
61 $mstring='GeeJanFebMarAprMayJunJulAugSepOctNovDec';
63 $mon=index($mstring,$month) / 3;
70 $path=$_[$pathindex++];
73 next if ($path eq '');
74 $arrow=$_[$pathindex++];
75 $link=$_[$pathindex++];
76 $link2=$_[$pathindex++];
81 # report hard links as soft links
82 $arrow='->'; $link="/$link2";
83 substr($perm, 0, 1) = "l";
91 ($thisyear, $thismon) = split(/ /, $now);
92 # show time for files younger than 6 months
93 # but not for files with dates in the future
94 if ($year * 12 + $mon > $thisyear * 12 + $thismon - 6 &&
95 $year * 12 + $mon <= $thisyear * 12 + $thismon) {
96 print "$perm 1 $owgr $size $month $day $time CONTENTS/$path$arrow$link\n";
98 print "$perm 1 $owgr $size $month $day $year CONTENTS/$path$arrow$link\n";
102 if ( open(PIPEIN, "LC_ALL=C dpkg-deb -I $qarchivename |") )
108 last if $size =~ /:/;
109 next if $size !~ /\d+/;
120 print "$perm 1 0 0 $size $date DEBIAN/$name\n";
127 local($archive,$filename,$destfile)=@_;
128 local $qarchive = quote($archive);
129 local $qfilename = quote($filename);
130 local $qdestfile = quote($destfile);
132 if($filename eq "INFO")
134 system("dpkg-deb -I $qarchive > $qdestfile");
136 elsif($filename =~ /^DEBIAN/)
138 $qfilename=~s!^DEBIAN/!!;
139 system("dpkg-deb -I $qarchive $qfilename > $qdestfile");
141 elsif($filename eq "INSTALL")
143 if ( open(FILEOUT,">$destfile") )
145 print FILEOUT $pressinstall;
147 system("chmod a+x $qdestfile");
152 # files can be prepended with ./ or not, depending on the version of tar
153 $qfilename=~s!^CONTENTS/!!;
154 system("dpkg-deb --fsys-tarfile $qarchive | tar xOf - $qfilename ./$qfilename > $qdestfile 2>/dev/null");
160 local($archive,$filename)=@_;
161 local $qarchive = quote($archive);
162 if($filename eq "INSTALL")
164 print "Installing $archive\n";
165 system("dpkg -i $qarchive");
169 use File::Temp qw(mkdtemp);
170 my $template = "/tmp/mcdebfs.run.XXXXXX";
171 $template="$ENV{MC_TMPDIR}/mcdebfs.XXXXXX" if ($ENV{MC_TMPDIR});
172 $tmpdir = mkdtemp($template);
173 $tmpcmd="$tmpdir/run";
174 &mcdebfs_copyout($archive, $filename, $tmpcmd);
175 system("chmod u+x $tmpcmd");
182 $pressinstall=<<EOInstall;
185 Don\'t use this method if you are not willing to reinstall everything...
187 This is not a real file. It is a way to install the package you are browsing.
189 To install this package go back to the panel and press Enter on this file.
191 In Debian systems, a package is automatically upgraded when you install a new
192 version of it. There is no special upgrade option. Install always works.
198 if($ARGV[0] eq "list") { shift; &mcdebfs_list(@ARGV); exit 0; }
199 elsif($ARGV[0] eq "copyout") { shift; &mcdebfs_copyout(@ARGV); exit 0; }
200 elsif($ARGV[0] eq "run") { shift; &mcdebfs_run(@ARGV); exit 0; }