Browse Source

Non-root capabilities now.

master
freesource 23 years ago
parent
commit
6e02dd8da4
  1. 146
      SWIM/Apt.pm
  2. 2
      SWIM/Conf.pm
  3. 6
      SWIM/Global.pm

146
SWIM/Apt.pm

@ -534,14 +534,14 @@ sub ftp {
# to a non-standard dist.
my $localfile = "$default_directory/partial/$the_site" . "_" .
"$distb" . "_dists_" . "$dist" . "_" . "Contents-$arch.gz";
my $home = "$default_directory/$the_site" . "_" . "$distb" .
my $main::home = "$default_directory/$the_site" . "_" . "$distb" .
"_dists_" . "$dist" . "_" . "Contents-$arch.gz";
if (-e "$home") {
if (-e "$main::home") {
my $size =
$ftp->size("$distbase/dists/$dist/Contents-$arch.gz");
my $rmtime =
$ftp->mdtm("$distbase/dists/$dist/Contents-$arch.gz");
my ($lmtime) = (stat($home))[9];
my ($lmtime) = (stat($main::home))[9];
my $file_exist = $ftp->code();
print "swim: $distg[0]/Contents-$arch.gz does not exist on the server\n"
if $file_exist == 550 && $distbase !~ /non-US/ &&
@ -554,13 +554,13 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
elsif ($lmtime == $rmtime) {
$cc++ if $commands->{"onec"};
@ -583,14 +583,14 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
}
@ -600,14 +600,14 @@ sub ftp {
make_dir($place);
my $localfile = "$default_directory/partial/$the_site" . "_" .
"$distb" . "_dists_" . "$dist" . "_" . "Contents-$arch.gz";
my $home = "$place/$the_site" . "_" . "$distb" .
my $main::home = "$place/$the_site" . "_" . "$distb" .
"_dists_" . "$dist" . "_" . "Contents-$arch.gz";
if (-e "$home") {
if (-e "$main::home") {
my $size =
$ftp->size("$distbase/dists/$dist/Contents-$arch.gz");
my $rmtime =
$ftp->mdtm("$distbase/dists/$dist/Contents-$arch.gz");
my ($lmtime) = (stat($home))[9];
my ($lmtime) = (stat($main::home))[9];
my $file_exist = $ftp->code();
print "swim: $distg[0]/Contents-$arch.gz does not exist on the server\n"
if $file_exist == 550 && $distbase !~ /non-US/ &&
@ -620,13 +620,13 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
else {
$cc++ if $commands->{"onec"};
@ -649,14 +649,14 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
}
@ -673,14 +673,14 @@ sub ftp {
!defined $commands->{"Release_only"}) {
my $localfile = "$default_directory/partial/$the_site" . "_" .
"$distb" . "_dists_" . "$dist" . "_" . "Contents-$arch.gz";
my $home = "$default_directory/$the_site" . "_" . "$distb" .
my $main::home = "$default_directory/$the_site" . "_" . "$distb" .
"_dists_" . "$dist" . "_" . "Contents-$arch.gz";
if (-e "$home") {
if (-e "$main::home") {
my $size =
$ftp->size("$distbase/dists/$dist/Contents-$arch.gz");
my $rmtime =
$ftp->mdtm("$distbase/dists/$dist/Contents-$arch.gz");
my ($lmtime) = (stat($home))[9];
my ($lmtime) = (stat($main::home))[9];
my $file_exist = $ftp->code();
print "swim: $dist/Contents-$arch.gz does not exist on the server\n"
if $file_exist == 550 && $distbase !~ /non-US/ &&
@ -693,13 +693,13 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
else {
$cc++ if $commands->{"onec"};
@ -722,14 +722,14 @@ sub ftp {
if ($lsize == $size && $complete == 226) {
print "swim: successful retrieval of $dist/Contents-$arch.gz\n";
$cc++ if $commands->{"onec"};
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/Contents-$arch.gz\n";
}
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
}
@ -744,18 +744,18 @@ sub ftp {
##############
if (defined $commands->{"Packages"}) {
if ($commands->{"Packages"} eq "DF") {
my ($home,$localfile,$release_home,$release_localfile);
my ($main::home,$localfile,$release_home,$release_localfile);
my $nue = (split(m,/,,$dist))[0];
$section ne "single" && $distb !~ /non-US|experimental/
? ($home =
? ($main::home =
"$default_directory/$the_site" . "_" . "$distb" . "_dists_" .
"$dist" . "_" . "$section" . "_" . "binary-$arch" .
"_" . "Packages.gz")
: $nue eq "project"
? ($home =
? ($main::home =
"$default_directory/$the_site" . "_" . "$distb" .
"_" . "Packages.gz")
: ($home =
: ($main::home =
"$default_directory/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
$section ne "single" && $distb !~ /non-US|experimental/
@ -770,10 +770,10 @@ sub ftp {
: ($localfile =
"$default_directory/partial/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
($release_home = $home) =~ s,Packages.gz,Release,;
($release_home = $main::home) =~ s,Packages.gz,Release,;
($release_localfile = $localfile) =~ s,Packages.gz,Release,;
if (-e "$home") {
my ($lmtime) = (stat($home))[9];
if (-e "$main::home") {
my ($lmtime) = (stat($main::home))[9];
my $remotefile;
$section ne "single"
? ($remotefile =
@ -789,9 +789,9 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $lsize = (stat($localfile))[7];
my $complete = $ftp->code();
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
}
else {
@ -809,10 +809,10 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $complete = $ftp->code();
my $lsize = (stat($localfile))[7];
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
###########
@ -858,18 +858,18 @@ sub ftp {
elsif ($commands->{"Packages"} ne "DF") {
my $place = $commands->{"Packages"};
make_dir($place);
my($home,$localfile,$release_home,$release_localfile);
my($main::home,$localfile,$release_home,$release_localfile);
my $nue = (split(m,/,,$dist))[0];
$section ne "single" && $distb !~ /non-US|experimental/
? ($home =
? ($main::home =
"$place/$the_site" . "_" . "$distb" . "_dists_" .
"$dist" . "_" . "$section" . "_" . "binary-$arch" .
"_" . "Packages.gz")
: $nue eq "project"
? ($home =
? ($main::home =
"$place/$the_site" . "_" . "$distb" .
"_" . "Packages.gz")
: ($home =
: ($main::home =
"$place/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
$section ne "single" && $distb !~ /non-US|experimental/
@ -884,10 +884,10 @@ sub ftp {
: ($localfile =
"$default_directory/partial/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
($release_home = $home) =~ s,Packages.gz,Release,;
($release_home = $main::home) =~ s,Packages.gz,Release,;
($release_localfile = $localfile) =~ s,Packages.gz,Release,;
if (-e "$home") {
my ($lmtime) = (stat($home))[9];
if (-e "$main::home") {
my ($lmtime) = (stat($main::home))[9];
my $remotefile;
$section ne "single"
? ($remotefile =
@ -903,9 +903,9 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $lsize = (stat($localfile))[7];
my $complete = $ftp->code();
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
}
else {
@ -923,10 +923,10 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $complete = $ftp->code();
my $lsize = (stat($localfile))[7];
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
###########
@ -976,18 +976,18 @@ sub ftp {
################################
if ((!defined $commands->{"Contents"} &&
!defined $commands->{"Packages"}) || defined $Go_on) {
my ($home,$localfile,$release_home,$release_localfile);
my ($main::home,$localfile,$release_home,$release_localfile);
my $nue = (split(m,/,,$dist))[0];
$section ne "single" && $distb !~ /non-US|experimental/
? ($home =
? ($main::home =
"$default_directory/$the_site" . "_" . "$distb" . "_dists_" .
"$dist" . "_" . "$section" . "_" . "binary-$arch" .
"_" . "Packages.gz")
: $nue eq "project"
? ($home =
? ($main::home =
"$default_directory/$the_site" . "_" . "$distb" .
"_" . "Packages.gz")
: ($home =
: ($main::home =
"$default_directory/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
$section ne "single" && $distb !~ /non-US|experimental/
@ -1002,11 +1002,11 @@ sub ftp {
: ($localfile =
"$default_directory/partial/$the_site" . "_" . "$distb" . "_"
. "$nue" . "_" . "binary-$arch" . "_" . "Packages.gz");
($release_home = $home) =~ s,Packages.gz,Release,;
($release_home = $main::home) =~ s,Packages.gz,Release,;
($release_localfile = $localfile) =~ s,Packages.gz,Release,;
if (-e "$home" && !$commands->{"Release_only"} &&
if (-e "$main::home" && !$commands->{"Release_only"} &&
!defined $Go_on) {
my ($lmtime) = (stat($home))[9];
my ($lmtime) = (stat($main::home))[9];
my $remotefile;
$section ne "single"
? ($remotefile =
@ -1022,12 +1022,12 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $lsize = (stat($localfile))[7];
my $complete = $ftp->code();
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
utime(time,$rmtime,$home);
utime(time,$rmtime,$main::home);
}
}
elsif (!-e "$home" && !$commands->{"Release_only"} &&
elsif (!-e "$main::home" && !$commands->{"Release_only"} &&
!defined $Go_on ) {
my $remotefile;
$section ne "single"
@ -1043,10 +1043,10 @@ sub ftp {
get($ftp,$remotefile,$localfile);
my $complete = $ftp->code();
my $lsize = (stat($localfile))[7];
two26($complete,$size,$lsize,$home,$localfile,
two26($complete,$size,$lsize,$main::home,$localfile,
$section,$arch,$dist,$distb);
if (-e $home) {
utime(time,$rmtime,$home);
if (-e $main::home) {
utime(time,$rmtime,$main::home);
}
}
###########
@ -1155,7 +1155,7 @@ sub download {
# Packages printout for ftp 226 success and the correct size
sub two26 {
my ($complete,$size,$lsize,$home,$localfile,$section,$arch,$dist,$distb)
my ($complete,$size,$lsize,$main::home,$localfile,$section,$arch,$dist,$distb)
= @_;
if ($complete == 226 && $size == $lsize) {
@ -1166,8 +1166,8 @@ sub two26 {
if $section eq "single" && $distb !~ /non-US/;
print "swim: successful retrieval of $distp[0]/non-US/$distp[1]/Packages.gz\n"
if $distb =~ /non-US/ && $section !~ "non-US";
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
my @distp = split(m,/,,$dist);
@ -1185,12 +1185,12 @@ sub two26 {
# check download of Release file
sub two26_r {
my ($complete,$size,$lsize,$home,$localfile,$section,$arch,$dist) = @_;
my ($complete,$size,$lsize,$main::home,$localfile,$section,$arch,$dist) = @_;
if ($complete == 226 && $size == $lsize) {
#print "swim: successful retrieval of $dist/$section/binary-$arch/Packages.gz\n";
rename("$localfile","$home")
or system "$mv", "$localfile", "$home";
rename("$localfile","$main::home")
or system "$mv", "$localfile", "$main::home";
}
else {
print "swim: unsuccessful retrieval of $dist/$section/binary-$arch/Packages.gz\n";

2
SWIM/Conf.pm

@ -370,7 +370,7 @@ $passive = 0;
# files under dpkg are somewhere else (including /info*) , see --dbpath as
# an alternative if you decide to access or make the databases somewhere
# else. I should point out that this program was designed to work with only
# one user .. root.
# one user .. root .. but now I am changing it --freesource
$base = '/var/lib/dpkg';
# --dbpath takes care of this so don't touch.

6
SWIM/Global.pm

@ -17,14 +17,13 @@
package SWIM::Global;
#use strict;
use vars qw(@ISA @EXPORT %EXPORT_TAGS);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(%db $ping %ndb %ib $zing %gb $ging %sb $sing %nsb %commands
$argument $save @stuff @PACKAGES @arg_holder $file_now
$arg_count $aptor_count $aptor_group $swim_version);
$arg_count $aptor_count $aptor_group $main::home);
%EXPORT_TAGS = (
Info => [ qw($argument %db) ]
);
@ -56,7 +55,4 @@ my $file_now; # defined flag for -qlcx & -qglx for file()
$arg_count = 0; # helps in tricky situations
my $aptor_group; # helps when -z is called for groups
# Swim's version
$swim_version = "0.3.6";
1;

Loading…
Cancel
Save