Browse Source

Now non-root users can create databases to access knowledge from swim.

master
freesource 23 years ago
parent
commit
ba483f7247
  1. 33
      SWIM/DB.pm
  2. 168
      SWIM/DB_Init.pm
  3. 104
      SWIM/DB_Library.pm
  4. 6
      SWIM/MD.pm
  5. 12
      SWIM/NDB.pm
  6. 174
      SWIM/NDB_Init.pm
  7. 32
      SWIM/Search.pm
  8. 67
      swim

33
SWIM/DB.pm

@ -28,7 +28,6 @@ use Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(db rebuildflatdb);
# --db --rebuildflatdb db() rebuildflatdb()
# The goal here is to save some time by just updating the database rather
@ -225,15 +224,15 @@ sub db {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/searchindex.deb") {
unlink("$parent$library/searchindex.deb.gz");
unlink("$parent$library/dirindex.deb.gz");
if (-e "$main::home$parent$library/searchindex.deb") {
unlink("$main::home$parent$library/searchindex.deb.gz");
unlink("$main::home$parent$library/dirindex.deb.gz");
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/searchindex.deb") {
unlink("$parent$base/searchindex.deb.gz");
unlink("$parent$base/dirindex.deb.gz");
if (-e "$main::home$parent$base/searchindex.deb") {
unlink("$main::home$parent$base/searchindex.deb.gz");
unlink("$main::home$parent$base/dirindex.deb.gz");
}
}
}
@ -815,10 +814,10 @@ sub db {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
open(SEARCHINDEX,">>$parent$library/searchindex.deb");
open(SEARCHINDEX,">>$main::home$parent$library/searchindex.deb");
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
open(SEARCHINDEX,">>$parent$base/searchindex.deb");
open(SEARCHINDEX,">>$main::home$parent$base/searchindex.deb");
}
if (!-d) {
print SEARCHINDEX "$_\n";
@ -826,10 +825,10 @@ sub db {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
open(DIRINDEX,">>$parent$library/dirindex.deb");
open(DIRINDEX,">>$main::home$parent$library/dirindex.deb");
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
open(DIRINDEX,">>$parent$base/dirindex.deb");
open(DIRINDEX,">>$main::home$parent$base/dirindex.deb");
}
if (-d) {
print DIRINDEX "$_\n";
@ -890,9 +889,9 @@ sub rebuildflatdb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
!($commands->{"dbpath"} && $commands->{"root"})) {
if (-e "$parent$library/searchindex.deb") {
$dir = "$parent$library/dirindex.deb";
$file = "$parent$library/searchindex.deb";
if (-e "$main::home$parent$library/searchindex.deb") {
$dir = "$main::home$parent$library/dirindex.deb";
$file = "$main::home$parent$library/searchindex.deb";
unlink($file);
unlink("$file.gz") if -e "$file.gz";
unlink($dir);
@ -904,9 +903,9 @@ sub rebuildflatdb {
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/searchindex.deb") {
$file = "$parent$base/searchindex.deb";
$dir = "$parent$base/dirindex.deb";
if (-e "$main::home$parent$base/searchindex.deb") {
$file = "$main::home$parent$base/searchindex.deb";
$dir = "$main::home$parent$base/dirindex.deb";
unlink($file);
unlink("$file.gz") if -e "$file.gz";
unlink($dir);

168
SWIM/DB_Init.pm

@ -19,7 +19,7 @@
package SWIM::DB_Init;
use strict;
use SWIM::Conf qw(:Path $fastswim $imswim $slowswim $sort);
#use SWIM::Global;
use SWIM::Global;
use SWIM::Format;
use SWIM::MD;
use DB_File;
@ -106,53 +106,53 @@ sub database {
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if ($commands->{"initdb"}) {
if (-e "$parent$library/packages.deb" &&
-e "$parent$library/fileindex.deb") {
if (-e "$main::home$parent$library/packages.deb" &&
-e "$main::home$parent$library/fileindex.deb") {
print "swim: use --rebuilddb\n";
exit;
}
else {
# if a database happens to be missing
if (-e "$parent$library/packages.deb") {
unlink("$parent$library/packages.deb");
if (-e "$main::home$parent$library/packages.deb") {
unlink("$main::home$parent$library/packages.deb");
}
if (-e "$parent$library/fileindex.deb") {
unlink("$parent$library/fileindex.deb");
if (-e "$main::home$parent$library/fileindex.deb") {
unlink("$main::home$parent$library/fileindex.deb");
}
if (-e "$parent$library/groupindex.deb") {
unlink("$parent$library/groupindex.deb");
if (-e "$main::home$parent$library/groupindex.deb") {
unlink("$main::home$parent$library/groupindex.deb");
}
if (-e "$parent$library/statusindex.deb") {
unlink("$parent$library/statusindex.deb");
if (-e "$main::home$parent$library/statusindex.deb") {
unlink("$main::home$parent$library/statusindex.deb");
}
if (-e "$parent$library/searchindex.deb") {
unlink("$parent$library/searchindex.deb");
if (-e "$main::home$parent$library/searchindex.deb") {
unlink("$main::home$parent$library/searchindex.deb");
}
if (-e "$parent$library/searchindex.deb.gz") {
unlink("$parent$library/searchindex.deb.gz");
if (-e "$main::home$parent$library/searchindex.deb.gz") {
unlink("$main::home$parent$library/searchindex.deb.gz");
}
if (-e "$parent$library/dirindex.deb") {
unlink("$parent$library/dirindex.deb");
if (-e "$main::home$parent$library/dirindex.deb") {
unlink("$main::home$parent$library/dirindex.deb");
}
if (-e "$parent$library/dirindex.deb.gz") {
unlink("$parent$library/dirindex.deb.gz");
if (-e "$main::home$parent$library/dirindex.deb.gz") {
unlink("$main::home$parent$library/dirindex.deb.gz");
}
}
}
# this only works if all databases exist.
elsif ($commands->{"rebuilddb"}) {
if (-e "$parent$library/packages.deb" &&
-e "$parent$library/fileindex.deb") {
unlink("$parent$library/packages.deb");
unlink("$parent$library/fileindex.deb");
unlink("$parent$library/groupindex.deb");
unlink("$parent$library/statusindex.deb");
unlink("$parent$library/searchindex.deb");
unlink("$parent$library/searchindex.deb")
if -e "$parent$library/searchindex.deb";
unlink("$parent$library/dirindex.deb");
unlink("$parent$library/dirindex.deb")
if -e "$parent$library/dirindex.deb.gz";
if (-e "$main::home$parent$library/packages.deb" &&
-e "$main::home$parent$library/fileindex.deb") {
unlink("$main::home$parent$library/packages.deb");
unlink("$main::home$parent$library/fileindex.deb");
unlink("$main::home$parent$library/groupindex.deb");
unlink("$main::home$parent$library/statusindex.deb");
unlink("$main::home$parent$library/searchindex.deb");
unlink("$main::home$parent$library/searchindex.deb")
if -e "$main::home$parent$library/searchindex.deb";
unlink("$main::home$parent$library/dirindex.deb");
unlink("$main::home$parent$library/dirindex.deb")
if -e "$main::home$parent$library/dirindex.deb.gz";
}
else {
print "swim: use --initdb to create databases\n";
@ -162,53 +162,53 @@ sub database {
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if ($commands->{"initdb"}) {
if (-e "$parent$base/packages.deb" &&
-e "$parent$base/fileindex.deb") {
if (-e "$main::home$parent$base/packages.deb" &&
-e "$main::home$parent$base/fileindex.deb") {
print "swim: use --rebuilddb\n";
exit;
}
else {
# if a database happens to be missing
if (-e "$parent$base/packages.deb") {
unlink("$parent$base/packages.deb");
if (-e "$main::home$parent$base/packages.deb") {
unlink("$main::home$parent$base/packages.deb");
}
if (-e "$parent$base/fileindex.deb") {
unlink("$parent$base/fileindex.deb");
if (-e "$main::home$parent$base/fileindex.deb") {
unlink("$main::home$parent$base/fileindex.deb");
}
if (-e "$parent$base/groupindex.deb") {
unlink("$parent$base/groupindex.deb");
if (-e "$main::home$parent$base/groupindex.deb") {
unlink("$main::home$parent$base/groupindex.deb");
}
if (-e "$parent$library/statusindex.deb") {
unlink("$parent$library/statusindex.deb");
if (-e "$main::home$parent$library/statusindex.deb") {
unlink("$main::home$parent$library/statusindex.deb");
}
if (-e "$parent$library/searchindex.deb") {
unlink("$parent$library/searchindex.deb");
if (-e "$main::home$parent$library/searchindex.deb") {
unlink("$main::home$parent$library/searchindex.deb");
}
if (-e "$parent$library/searchindex.deb.gz") {
unlink("$parent$library/searchindex.deb.gz");
if (-e "$main::home$parent$library/searchindex.deb.gz") {
unlink("$main::home$parent$library/searchindex.deb.gz");
}
if (-e "$parent$library/dirindex.deb") {
unlink("$parent$library/dirindex.deb");
if (-e "$main::home$parent$library/dirindex.deb") {
unlink("$main::home$parent$library/dirindex.deb");
}
if (-e "$parent$library/dirindex.deb.gz") {
unlink("$parent$library/dirindex.deb.gz");
if (-e "$main::home$parent$library/dirindex.deb.gz") {
unlink("$main::home$parent$library/dirindex.deb.gz");
}
}
}
# this only works if all databases exist.
elsif ($commands->{"rebuilddb"}) {
if (-e "$parent$base/packages.deb" &&
-e "$parent$base/fileindex.deb") {
unlink("$parent$base/packages.deb");
unlink("$parent$base/fileindex.deb");
unlink("$parent$base/groupindex.deb");
unlink("$parent$base/statusindex.deb");
unlink("$parent$library/searchindex.deb");
unlink("$parent$library/searchindex.deb")
if -e "$parent$library/searchindex.deb";
unlink("$parent$library/dirindex.deb");
unlink("$parent$library/dirindex.deb")
if -e "$parent$library/dirindex.deb.gz";
if (-e "$main::home$parent$base/packages.deb" &&
-e "$main::home$parent$base/fileindex.deb") {
unlink("$main::home$parent$base/packages.deb");
unlink("$main::home$parent$base/fileindex.deb");
unlink("$main::home$parent$base/groupindex.deb");
unlink("$main::home$parent$base/statusindex.deb");
unlink("$main::home$parent$library/searchindex.deb");
unlink("$main::home$parent$library/searchindex.deb")
if -e "$main::home$parent$library/searchindex.deb";
unlink("$main::home$parent$library/dirindex.deb");
unlink("$main::home$parent$library/dirindex.deb")
if -e "$main::home$parent$library/dirindex.deb.gz";
}
else {
print "swim: use --initdb to create databases\n";
@ -223,22 +223,22 @@ sub database {
# this won't cause problems because everything is rebuilt, there may
# just be some lingering small files in backup.
# Seems like both approaches are about the same speed.
#use File::Copy;
print "Making backups of *.list\n";
if (!-d "$parent$base/info/backup") {
mkdir("$parent$base/info/backup",0666);
}
opendir(COPY,"$parent$base/info");
foreach (sort grep(/\.list$/, readdir(COPY))) {
#copy ("$parent$base/info/$_","$parent$base/info/backup/$_.bk");
open(FILENAME,"$parent$base/info/$_");
open(CP,">$parent$base/info/backup/$_.bk");
while (<FILENAME>) {
print CP $_;
}
}
closedir(COPY);
# Seems like both approaches are about the same speed.
#use File::Copy;
print "Making backups of *.list\n";
if (!-d "$main::home$parent$base/info/backup") {
system "mkdir $main::home$parent$base/info/backup";
}
opendir(COPY,"$parent$base/info") or die "Sorry Charlie: $!\n";
foreach (sort grep(/\.list$/, readdir(COPY))) {
open(FILENAME,"$parent$base/info/$_");
open(CP,">$main::home$parent$base/info/backup/$_.bk");
while (<FILENAME>) {
print CP $_;
}
}
closedir(COPY);
print "Description Database is being made\n";
@ -542,10 +542,10 @@ sub database {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %gb, 'DB_File', "$parent$library/groupindex.deb" or die "DB_File: $!";
tie %gb, 'DB_File', "$main::home$parent$library/groupindex.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %gb, 'DB_File', "$parent$base/groupindex.deb" or die "DB_File: $!";
tie %gb, 'DB_File', "$main::home$parent$base/groupindex.deb" or die "DB_File: $!";
}
%gb = %group;
@ -559,10 +559,10 @@ sub database {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %sb, 'DB_File', "$parent$library/statusindex.deb" or die "DB_File: $!";
tie %sb, 'DB_File', "$main::home$parent$library/statusindex.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %sb, 'DB_File', "$parent$base/statusindex.deb" or die "DB_File: $!";
tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb" or die "DB_File: $!";
}
%sb = @status;
@ -575,10 +575,10 @@ sub database {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %db, 'DB_File', "$parent$library/packages.deb" or die "DB_File: $!";
tie %db, 'DB_File', "$main::home$parent$library/packages.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %db, 'DB_File', "$parent$base/packages.deb" or die "DB_File: $!";
tie %db, 'DB_File', "$main::home$parent$base/packages.deb" or die "DB_File: $!";
}
%db = (@name,@Tdescription,@conf,@REPLACE);
@ -609,7 +609,7 @@ sub md {
unless (-e "$parent$base/info") {
die 'This program requires the /var/lib/dpkg/info directory set-up by dpkg';
die 'This program requires the $parent$base/info directory set-up by dpkg';
}
# Put all file/dir(*.list)->package_name(s) into an massive array.

104
SWIM/DB_Library.pm

@ -50,13 +50,13 @@ sub ib {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/fileindex.deb") {
tie %ib, 'DB_File', "$parent$library/fileindex.deb" or die "DB_File: $!";
if (-e "$main::home$parent$library/fileindex.deb") {
tie %ib, 'DB_File', "$main::home$parent$library/fileindex.deb" or die "DB_File: $!";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/fileindex.deb") {
tie %ib, 'DB_File', "$parent$base/fileindex.deb" or die "DB_File: $!";
if (-e "$main::home$parent$base/fileindex.deb") {
tie %ib, 'DB_File', "$main::home$parent$base/fileindex.deb" or die "DB_File: $!";
}
}
} # end sub ib
@ -68,15 +68,15 @@ sub dbi {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/packages.deb" ||
if (-e "$main::home$parent$library/packages.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %db, 'DB_File', "$parent$library/packages.deb" or die "DB_File: $!";
tie %db, 'DB_File', "$main::home$parent$library/packages.deb" or die "DB_File: $!";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/packages.deb" ||
if (-e "$main::home$parent$base/packages.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %db, 'DB_File', "$parent$base/packages.deb" or die "DB_File: $!";
tie %db, 'DB_File', "$main::home$parent$base/packages.deb" or die "DB_File: $!";
}
}
} # end sub dbi
@ -92,16 +92,16 @@ sub nib {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (!-e "$parent$library/nfileindex$arch$dist.deb") {
if (!-e "$main::home$parent$library/nfileindex$arch$dist.deb") {
return;
}
tie %ib, 'DB_File', "$parent$library/nfileindex$arch$dist.deb" or die "DB_File: $!";
tie %ib, 'DB_File', "$main::home$parent$library/nfileindex$arch$dist.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (!-e "$parent$base/nfileindex$arch$dist.deb") {
if (!-e "$main::home$parent$base/nfileindex$arch$dist.deb") {
return;
}
tie %ib, 'DB_File', "$parent$base/nfileindex$arch$dist.deb" or die "DB_File: $!";
tie %ib, 'DB_File', "$main::home$parent$base/nfileindex$arch$dist.deb" or die "DB_File: $!";
}
} # end sub nib
@ -115,18 +115,18 @@ sub ndb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/npackages$arch$dist.deb" ||
if (-e "$main::home$parent$library/npackages$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"} ||
$commands->{"ndb"})) {
tie %db, 'DB_File', "$parent$library/npackages$arch$dist.deb"
tie %db, 'DB_File', "$main::home$parent$library/npackages$arch$dist.deb"
or die "swim: use pre-existing databases for this option";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/npackages$arch$dist.deb" ||
if (-e "$main::home$parent$base/npackages$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"} ||
$commands->{"ndb"})) {
tie %db, 'DB_File', "$parent$base/npackages$arch$dist.deb"
tie %db, 'DB_File', "$main::home$parent$base/npackages$arch$dist.deb"
or die "swim: use pre-existing databases for this option";
}
}
@ -141,8 +141,8 @@ sub sb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/statusindex.deb") {
tie %sb, 'DB_File', "$parent$library/statusindex.deb"
if (-e "$main::home$parent$library/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$library/statusindex.deb"
or die "DB_File: $!";
}
else {
@ -150,8 +150,8 @@ sub sb {
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$parent$base/statusindex.deb"
if (-e "$main::home$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb"
or die "DB_File: $!";
}
else {
@ -174,19 +174,19 @@ sub exist_sb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/statusindex.deb") {
if (-e "$main::home$parent$library/statusindex.deb") {
$yep = "yes";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/statusindex.deb") {
if (-e "$main::home$parent$base/statusindex.deb") {
$yep = "yes";
}
}
if (!defined $yep) {
if (-e "$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$parent$base/statusindex.deb"
if (-e "$main::home$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb"
or die "DB_File: $!";
return "yes";
}
@ -210,18 +210,18 @@ sub nsb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/nstatusindex$arch$dist.deb" ||
if (-e "$main::home$parent$library/nstatusindex$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"} ||
$commands->{"ndb"})) {
tie %nsb, 'DB_File', "$parent$library/nstatusindex$arch$dist.deb"
tie %nsb, 'DB_File', "$main::home$parent$library/nstatusindex$arch$dist.deb"
or die "swim: use pre-existing databases for this option";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/nstatusindex$arch$dist.deb" ||
if (-e "$main::home$parent$base/nstatusindex$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"} ||
$commands->{"ndb"})) {
tie %nsb, 'DB_File', "$parent$base/nstatusindex$arch$dist.deb" or die
tie %nsb, 'DB_File', "$main::home$parent$base/nstatusindex$arch$dist.deb" or die
or die "swim: use pre-existing databases for this option";
}
}
@ -234,10 +234,10 @@ sub ping {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$ping = tie %db, 'DB_File', "$parent$library/packages.deb" or die "DB_File: $!";
$ping = tie %db, 'DB_File', "$main::home$parent$library/packages.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$ping = tie %db, 'DB_File', "$parent$base/packages.deb" or die "DB_File: $!";
$ping = tie %db, 'DB_File', "$main::home$parent$base/packages.deb" or die "DB_File: $!";
}
}
@ -250,11 +250,11 @@ sub nping {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$ping = tie %db, 'DB_File', "$parent$library/npackages$arch$dist.deb"
$ping = tie %db, 'DB_File', "$main::home$parent$library/npackages$arch$dist.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$ping = tie %db, 'DB_File', "$parent$base/npackages$arch$dist.deb"
$ping = tie %db, 'DB_File', "$main::home$parent$base/npackages$arch$dist.deb"
or die "DB_File: $!";
}
} # end sub nping
@ -267,11 +267,11 @@ sub zing {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$zing = tie %ib, 'DB_File', "$parent$library/fileindex.deb"
$zing = tie %ib, 'DB_File', "$main::home$parent$library/fileindex.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$zing = tie %ib, 'DB_File', "$parent$base/fileindex.deb"
$zing = tie %ib, 'DB_File', "$main::home$parent$base/fileindex.deb"
or die "DB_File: $!";
}
} # end sub zing
@ -285,11 +285,11 @@ sub nzing {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$zing = tie %ib, 'DB_File', "$parent$library/nfileindex$arch$dist.deb"
$zing = tie %ib, 'DB_File', "$main::home$parent$library/nfileindex$arch$dist.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$zing = tie %ib, 'DB_File', "$parent$base/nfileindex$arch$dist.deb"
$zing = tie %ib, 'DB_File', "$main::home$parent$base/nfileindex$arch$dist.deb"
or die "DB_File: $!";
}
} # end sub nzing
@ -302,10 +302,10 @@ sub ging {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$ging = tie %gb, 'DB_File', "$parent$library/groupindex.deb" or die "DB_File: $!";
$ging = tie %gb, 'DB_File', "$main::home$parent$library/groupindex.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$ging = tie %gb, 'DB_File', "$parent$base/groupindex.deb" or die "DB_File: $!";
$ging = tie %gb, 'DB_File', "$main::home$parent$base/groupindex.deb" or die "DB_File: $!";
}
} #end sub ging
@ -319,11 +319,11 @@ sub nging {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$ging = tie %gb, 'DB_File',"$parent$library/ngroupindex$arch$dist.deb"
$ging = tie %gb, 'DB_File',"$main::home$parent$library/ngroupindex$arch$dist.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$ging = tie %gb, 'DB_File', "$parent$base/ngroupindex$arch$dist.deb"
$ging = tie %gb, 'DB_File', "$main::home$parent$base/ngroupindex$arch$dist.deb"
or die "DB_File: $!";
}
} # end sub nging
@ -336,15 +336,15 @@ sub gb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/groupindex.deb" ||
if (-e "$main::home$parent$library/groupindex.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %gb, 'DB_File', "$parent$library/groupindex.deb" or die "DB_File: $!";
tie %gb, 'DB_File', "$main::home$parent$library/groupindex.deb" or die "DB_File: $!";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/groupindex.deb" ||
if (-e "$main::home$parent$base/groupindex.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %gb, 'DB_File', "$parent$base/groupindex.deb" or die "DB_File: $!";
tie %gb, 'DB_File', "$main::home$parent$base/groupindex.deb" or die "DB_File: $!";
}
}
}
@ -358,16 +358,16 @@ sub ngb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/ngroupindex$arch$dist.deb" ||
if (-e "$main::home$parent$library/ngroupindex$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %gb, 'DB_File', "$parent$library/ngroupindex$arch$dist.deb"
tie %gb, 'DB_File', "$main::home$parent$library/ngroupindex$arch$dist.deb"
or die "DB_File: $!";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/ngroupindex$arch$dist.deb" ||
if (-e "$main::home$parent$base/ngroupindex$arch$dist.deb" ||
($commands->{"initndb"} || $commands->{"rebuildndb"})) {
tie %gb, 'DB_File', "$parent$base/ngroupindex$arch$dist.deb"
tie %gb, 'DB_File', "$main::home$parent$base/ngroupindex$arch$dist.deb"
or die "DB_File: $!";
}
}
@ -380,11 +380,11 @@ sub sing {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sing = tie %sb, 'DB_File', "$parent$library/statusindex.deb"
$sing = tie %sb, 'DB_File', "$main::home$parent$library/statusindex.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sing = tie %sb, 'DB_File', "$parent$base/statusindex.deb" or die "DB_File: $!";
$sing = tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb" or die "DB_File: $!";
}
} # sub sing
@ -397,11 +397,11 @@ sub nsing {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sing = tie %nsb, 'DB_File', "$parent$library/nstatusindex$arch$dist.deb"
$sing = tie %nsb, 'DB_File', "$main::home$parent$library/nstatusindex$arch$dist.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sing = tie %nsb, 'DB_File', "$parent$base/nstatusindex$arch$dist.deb"
$sing = tie %nsb, 'DB_File', "$main::home$parent$base/nstatusindex$arch$dist.deb"
or die "DB_File: $!";
}
} # end sub nsing

6
SWIM/MD.pm

@ -54,6 +54,7 @@ sub process_md {
my $count1 = 1;
my($place) = finddb(\%commands);
$place = "$main::home$place";
# Let's determine what architecture and distribution this person is
# interested in.
@ -105,11 +106,11 @@ sub process_md {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$zing = tie %md, 'DB_File',"$parent$library/$fileindex$arch$dist.deb"
$zing = tie %md, 'DB_File',"$main::home$parent$library/$fileindex$arch$dist.deb"
or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$zing = tie %md, 'DB_File',"$parent$base/$fileindex$arch$dist.deb"
$zing = tie %md, 'DB_File',"$main::home$parent$base/$fileindex$arch$dist.deb"
or die "DB_File: $!";
}
while ($count <= $#mi) {
@ -220,6 +221,7 @@ sub process_md {
my @statusindex = split(/\s/,$nsb{"/."});
if ($#fileindex < $#statusindex) {
my $place = finddb(\%commands);
$place = "$main::home$place";
open(DIFF, ">$place/.packagesdiff$arch$dist.deb")
or warn "couldn't create diff file\n";
my %uniques;

12
SWIM/NDB.pm

@ -1779,9 +1779,9 @@ sub rebuildflatndb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
!($commands->{"dbpath"} && $commands->{"root"})) {
if (-e "$parent$library/nsearchindex$arch$dist.deb") {
$dir = "$parent$library/ndirindex$arch$dist.deb";
$file = "$parent$library/nsearchindex$arch$dist.deb";
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb") {
$dir = "$main::home$parent$library/ndirindex$arch$dist.deb";
$file = "$main::home$parent$library/nsearchindex$arch$dist.deb";
unlink($file);
unlink("$file.gz") if -e "$file.gz";
unlink($dir);
@ -1793,9 +1793,9 @@ sub rebuildflatndb {
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/nsearchindex$arch$dist.deb") {
$file = "$parent$base/nsearchindex$arch$dist.deb";
$dir = "$parent$base/ndirindex$arch$dist.deb";
if (-e "$main::home$parent$base/nsearchindex$arch$dist.deb") {
$file = "$main::home$parent$base/nsearchindex$arch$dist.deb";
$dir = "$main::home$parent$base/ndirindex$arch$dist.deb";
unlink($file);
unlink("$file.gz") if -e "$file.gz";
unlink($dir);

174
SWIM/NDB_Init.pm

@ -24,7 +24,7 @@ use SWIM::Format;
use SWIM::Conf qw(:Path $default_directory $apt_cache @user_defined_section
$distribution $pwd $sort $gzip $architecture $slowswim
$longswim $apt_sources $alt);
use SWIM::Global qw(%sb $argument);
use SWIM::Global qw(%sb $argument $main::home);
use SWIM::Dir;
use SWIM::Compare;
use SWIM::MD;
@ -1097,68 +1097,68 @@ sub not_installed {
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if ($commands->{"initndb"}) {
if (-e "$parent$library/npackages$arch$dist.deb") {
if (-e "$main::home$parent$library/npackages$arch$dist.deb") {
print "swim: use --rebuildndb\n";
exit;
}
else {
# if a database happens to be missing
if (-e "$parent$library/npackages$arch$dist.deb") {
unlink("$parent$library/npackages$arch$dist.deb");
if (-e "$main::home$parent$library/npackages$arch$dist.deb") {
unlink("$main::home$parent$library/npackages$arch$dist.deb");
}
if (-e "$parent$library/nfileindex$arch$dist.deb") {
unlink("$parent$library/nfileindex$arch$dist.deb");
if (-e "$main::home$parent$library/nfileindex$arch$dist.deb") {
unlink("$main::home$parent$library/nfileindex$arch$dist.deb");
}
if (-e "$parent$library/ngroupindex$arch$dist.deb") {
unlink("$parent$library/ngroupindex$arch$dist.deb");
if (-e "$main::home$parent$library/ngroupindex$arch$dist.deb") {
unlink("$main::home$parent$library/ngroupindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$parent$library/ncontentsindex$arch$dist.deb");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$parent$library/ncontentsindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb.gz");
}
# might as well delete these to free some room
if (-e "$parent$library/nsearchindex$arch$dist.deb") {
unlink("$parent$library/nsearchindex$arch$dist.deb");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb");
}
if (-e "$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$parent$library/nsearchindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb.gz");
}
if (-e "$parent$library/ndirindex$arch$dist.deb") {
unlink("$parent$library/ndirindex$arch$dist.deb");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb");
}
if (-e "$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$parent$library/ndirindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb.gz");
}
}
}
# this only works if all databases exist.
elsif ($commands->{"rebuildndb"}) {
if (-e "$parent$library/npackages$arch$dist.deb") {
unlink("$parent$library/npackages$arch$dist.deb");
unlink("$parent$library/nfileindex$arch$dist.deb");
unlink("$parent$library/ngroupindex$arch$dist.deb");
unlink("$parent$library/nstatusindex$arch$dist.deb");
if (-e "$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$parent$library/ncontentsindex$arch$dist.deb");
if (-e "$main::home$parent$library/npackages$arch$dist.deb") {
unlink("$main::home$parent$library/npackages$arch$dist.deb");
unlink("$main::home$parent$library/nfileindex$arch$dist.deb");
unlink("$main::home$parent$library/ngroupindex$arch$dist.deb");
unlink("$main::home$parent$library/nstatusindex$arch$dist.deb");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$parent$library/ncontentsindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb.gz");
}
# might as well delete these to free some room
if (-e "$parent$library/nsearchindex$arch$dist.deb") {
unlink("$parent$library/nsearchindex$arch$dist.deb");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb");
}
if (-e "$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$parent$library/nsearchindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb.gz");
}
if (-e "$parent$library/ndirindex$arch$dist.deb") {
unlink("$parent$library/ndirindex$arch$dist.deb");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb");
}
if (-e "$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$parent$library/ndirindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb.gz");
}
}
else {
@ -1169,67 +1169,67 @@ sub not_installed {
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if ($commands->{"initndb"}) {
if (-e "$parent$base/npackages$arch$dist.deb") {
if (-e "$main::home$parent$base/npackages$arch$dist.deb") {
print "swim: use --rebuildndb\n";
exit;
}
else {
# if a database happens to be missing
if (-e "$parent$base/npackages$arch$dist.deb") {
unlink("$parent$base/npackages$arch$dist.deb");
if (-e "$main::home$parent$base/npackages$arch$dist.deb") {
unlink("$main::home$parent$base/npackages$arch$dist.deb");
}
if (-e "$parent$base/nfileindex$arch$dist.deb") {
unlink("$parent$base/nfileindex$arch$dist.deb");
if (-e "$main::home$parent$base/nfileindex$arch$dist.deb") {
unlink("$main::home$parent$base/nfileindex$arch$dist.deb");
}
if (-e "$parent$library/ngroupindex$arch$dist.deb") {
unlink("$parent$base/ngroupindex$arch$dist.deb");
if (-e "$main::home$parent$library/ngroupindex$arch$dist.deb") {
unlink("$main::home$parent$base/ngroupindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$parent$library/ncontentsindex$arch$dist.deb");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$parent$library/ncontentsindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb.gz");
}
# might as well delete these to free some room
if (-e "$parent$library/nsearchindex$arch$dist.deb") {
unlink("$parent$base/nsearchindex$arch$dist.deb");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb") {
unlink("$main::home$parent$base/nsearchindex$arch$dist.deb");
}
if (-e "$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$parent$base/nsearchindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$main::home$parent$base/nsearchindex$arch$dist.deb.gz");
}
if (-e "$parent$library/ndirindex$arch$dist.deb") {
unlink("$parent$library/ndirindex$arch$dist.deb");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb");
}
if (-e "$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$parent$library/ndirindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb.gz");
}
}
}
# this only works if all databases exist.
elsif ($commands->{"rebuildndb"}) {
if (-e "$parent$base/npackages$arch$dist.deb") {
unlink("$parent$base/npackages$arch$dist.deb");
unlink("$parent$base/nfileindex$arch$dist.deb");
unlink("$parent$base/ngroupindex$arch$dist.deb");
unlink("$parent$base/nstatusindex$arch$dist.deb");
if (-e "$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$parent$library/ncontentsindex$arch$dist.deb");
if (-e "$main::home$parent$base/npackages$arch$dist.deb") {
unlink("$main::home$parent$base/npackages$arch$dist.deb");
unlink("$main::home$parent$base/nfileindex$arch$dist.deb");
unlink("$main::home$parent$base/ngroupindex$arch$dist.deb");
unlink("$main::home$parent$base/nstatusindex$arch$dist.deb");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb");
}
if (-e "$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$parent$library/ncontentsindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ncontentsindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ncontentsindex$arch$dist.deb.gz");
}
# might as well delete these to free some room
if (-e "$parent$library/nsearchindex$arch$dist.deb") {
unlink("$parent$library/nsearchindex$arch$dist.deb");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb");
}
if (-e "$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$parent$library/nsearchindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/nsearchindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/nsearchindex$arch$dist.deb.gz");
}
if (-e "$parent$library/ndirindex$arch$dist.deb") {
unlink("$parent$library/ndirindex$arch$dist.deb");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb");
}
if (-e "$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$parent$library/ndirindex$arch$dist.deb.gz");
if (-e "$main::home$parent$library/ndirindex$arch$dist.deb.gz") {
unlink("$main::home$parent$library/ndirindex$arch$dist.deb.gz");
}
}
else {
@ -2168,10 +2168,10 @@ sub not_installed {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %ngb, 'DB_File', "$parent$library/ngroupindex$arch$dist.deb" or die "DB_File: $!";
tie %ngb, 'DB_File', "$main::home$parent$library/ngroupindex$arch$dist.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %ngb, 'DB_File', "$parent$base/ngroupindex$arch$dist.deb" or die "DB_File: $!";
tie %ngb, 'DB_File', "$main::home$parent$base/ngroupindex$arch$dist.deb" or die "DB_File: $!";
}
# assigning to HUMM solves a strange problem. semi-panic: attempt to dup
@ -2189,10 +2189,10 @@ sub not_installed {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %nsb, 'DB_File', "$parent$library/nstatusindex$arch$dist.deb" or die "DB_File: $!";
tie %nsb, 'DB_File', "$main::home$parent$library/nstatusindex$arch$dist.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %nsb, 'DB_File', "$parent$base/nstatusindex$arch$dist.deb" or die "DB_File: $!";
tie %nsb, 'DB_File', "$main::home$parent$base/nstatusindex$arch$dist.deb" or die "DB_File: $!";
}
push(@status,"/.");
@ -2212,10 +2212,10 @@ sub not_installed {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
tie %ndb, 'DB_File', "$parent$library/npackages$arch$dist.deb" or die "DB_File: $!";
tie %ndb, 'DB_File', "$main::home$parent$library/npackages$arch$dist.deb" or die "DB_File: $!";
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
tie %ndb, 'DB_File', "$parent$base/npackages$arch$dist.deb" or die "DB_File: $!";
tie %ndb, 'DB_File', "$main::home$parent$base/npackages$arch$dist.deb" or die "DB_File: $!";
}
%ndb = (@name,@Tdescription,@conf,@REPLACE,@FILENAME,@MD5SUM,@revision);
@ -2246,19 +2246,19 @@ sub exist_sb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/statusindex.deb") {
if (-e "$main::home$parent$library/statusindex.deb") {
$yep = "yes";
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/statusindex.deb") {
if (-e "$main::home$parent$base/statusindex.deb") {
$yep = "yes";
}
}
if (!defined $yep) {
if (-e "$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$parent$base/statusindex.deb"
if (-e "$main::home$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb"
or die "DB_File: $!";
return "yes";
}
@ -2281,8 +2281,8 @@ sub sb {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
if (-e "$parent$library/statusindex.deb") {
tie %sb, 'DB_File', "$parent$library/statusindex.deb"
if (-e "$main::home$parent$library/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$library/statusindex.deb"
or die "DB_File: $!";
}
else {
@ -2290,8 +2290,8 @@ sub sb {
}
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
if (-e "$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$parent$base/statusindex.deb"
if (-e "$main::home$parent$base/statusindex.deb") {
tie %sb, 'DB_File', "$main::home$parent$base/statusindex.deb"
or die "DB_File: $!";
}
else {

32
SWIM/Search.pm

@ -741,13 +741,13 @@ sub searchdf {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sfile = "$parent$library/searchindex.deb";
$sdir = "$parent$library/dirindex.deb";
$sfile = "$main::home$parent$library/searchindex.deb";
$sdir = "$main::home$parent$library/dirindex.deb";
return ($sfile,$sdir);
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sfile = "$parent$base/searchindex.deb";
$sdir = "$parent$base/dirindex.deb";
$sfile = "$main::home$parent$base/searchindex.deb";
$sdir = "$main::home$parent$base/dirindex.deb";
return ($sfile,$sdir);
}
}
@ -755,8 +755,8 @@ sub searchdf {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sfile = "$parent$library/dramdisk/searchindex.deb.gz";
$sdir = "$parent$library/dramdisk/dirindex.deb.gz";
$sfile = "$main::home$parent$library/dramdisk/searchindex.deb.gz";
$sdir = "$main::home$parent$library/dramdisk/dirindex.deb.gz";
if (!-e $sdir && !-e $sfile) {
print "swim: found wrong database(s), use --ramdiskoff\n";
exit;
@ -764,8 +764,8 @@ sub searchdf {
return ($sfile,$sdir);
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sfile = "$parent$base/dramdisk/searchindex.deb.gz";
$sdir = "$parent$base/dramdisk/dirindex.deb.gz";
$sfile = "$main::home$parent$base/dramdisk/searchindex.deb.gz";
$sdir = "$main::home$parent$base/dramdisk/dirindex.deb.gz";
if (!-e $sdir && !-e $sfile) {
print "swim: found wrong database(s), use --ramdiskoff\n";
exit;
@ -781,13 +781,13 @@ sub searchdf {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sfile = "$parent$library/nsearchindex$arch$dist.deb";
$sdir = "$parent$library/ndirindex$arch$dist.deb";
$sfile = "$main::home$parent$library/nsearchindex$arch$dist.deb";
$sdir = "$main::home$parent$library/ndirindex$arch$dist.deb";
return ($sfile,$sdir);
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sfile = "$parent$base/nsearchindex$arch$dist.deb";
$sdir = "$parent$base/ndirindex$arch$dist.deb";
$sfile = "$main::home$parent$base/nsearchindex$arch$dist.deb";
$sdir = "$main::home$parent$base/ndirindex$arch$dist.deb";
return ($sfile,$sdir);
}
}
@ -795,8 +795,8 @@ sub searchdf {
if (($commands->{"dbpath"} && $commands->{"root"}) ||
($commands->{"dbpath"} && !$commands->{"root"}) ||
(!$commands->{"dbpath"} && !$commands->{"root"})) {
$sfile = "$parent$library/dramdisk/nsearchindex$arch$dist.deb.gz";
$sdir = "$parent$library/dramdisk/ndirindex$arch$dist.deb.gz";
$sfile = "$main::home$parent$library/dramdisk/nsearchindex$arch$dist.deb.gz";
$sdir = "$main::home$parent$library/dramdisk/ndirindex$arch$dist.deb.gz";
if (!-e $sdir && !-e $sfile) {
print "swim: found wrong database(s), use --ramdiskoff\n";
exit;
@ -804,8 +804,8 @@ sub searchdf {
return ($sfile,$sdir);
}
elsif (!$commands->{"dbpath"} && $commands->{"root"}) {
$sfile = "$parent$base/dramdisk/nsearchindex$arch$dist.deb.gz";
$sdir = "$parent$base/dramdisk/ndirindex$arch$dist.deb.gz";
$sfile = "$main::home$parent$base/dramdisk/nsearchindex$arch$dist.deb.gz";
$sdir = "$main::home$parent$base/dramdisk/ndirindex$arch$dist.deb.gz";
if (!-e $sdir && !-e $sfile) {
print "swim: found wrong database(s), use --ramdiskoff\n";
exit;

67
swim

@ -6,7 +6,7 @@ use Getopt::Long;
use SWIM::Conf;
use SWIM::Global;
use SWIM::Library;
my $version = "0.3.7";
############################################################################
#
@ -89,8 +89,6 @@ anyone, find the program to do the job easily.
# The MAIN
# First let's determine what options are being used.
my $home = $ENV{'HOME'};
Getopt::Long::config("bundling","no_auto_abbrev"); # will use pass_through
@ -208,7 +206,6 @@ command();
sub command {
# test
if ($commands{"testmenu"}) {
menuindex();
@ -272,7 +269,7 @@ sub command {
# version of the program
if ($commands{"version"}) {
print "SWIM version $swim_version\n";
print "SWIM version $version\n";
}
@ -329,7 +326,13 @@ sub command {
exit;
}
# this will handle options with arguments
$main::home = $ENV{'HOME'};
home_builder("$main::home$parent$base/info");
if ($Getopt::Long::error == 1 || $commands{"root"} ||
$commands{"dbpath"}) {
# If two options are used
@ -341,8 +344,10 @@ sub command {
exit;
}
}
# Check whether a different filesystem is being used with --root
# Check whether a different filesystem is being used with --root
my($arch, $dist) = which_archdist(\%commands);
if ($commands{"root"} &&
!$commands{"dbpath"}) {
@ -364,10 +369,10 @@ sub command {
$commands{"rebuildndb"} ||
$commands{"p"} ||
$commands{"ndb"})) {
$root = "$parent$base/packages.deb";
$root = "$main::home$parent$base/packages.deb";
}
else {
$root = "$parent$base/npackages$arch$dist.deb";
$root = "$main::home$parent$base/npackages$arch$dist.deb";
}
if (!-e $root && !-f $root) {
print "failed to open $root\n\n";
@ -428,10 +433,10 @@ sub command {
$commands{"rebuildndb"} ||
$commands{"p"} ||
$commands{"ndb"})) {
$dbpath = "$library/packages.deb";
$dbpath = "$main::home$library/packages.deb";
}
else {
$dbpath = "$library/npackages$arch$dist.deb";
$dbpath = "$main::home$library/npackages$arch$dist.deb";
}
if (!-e $dbpath && !-f $dbpath) {
print "failed to open $dbpath\n\n";
@ -502,10 +507,10 @@ sub command {
$commands{"rebuildndb"} ||
$commands{"p"} ||
$commands{"ndb"})) {
$dbpath = "$parent$library/packages.deb";
$dbpath = "$main::home$parent$library/packages.deb";
}
else {
$dbpath = "$parent$library/npackages$arch$dist.deb";
$dbpath = "$main::home$parent$library/npackages$arch$dist.deb";
}
if (!-e $dbpath && !-f $dbpath) {
print "failed to open $dbpath\n\n";
@ -1624,11 +1629,11 @@ sub usage {
# Shameless publication of the ThE_* Project, and also shameless self
# agrandizing....
print "SWIM version $swim_version
print "SWIM version $version
Copyright (C) 2000 - by Jonathan Rosenbaum for ThE_* Project
This may be freely redistributed under the terms of the GNU General Public License\n";
$save = "SWIM version $swim_version
$save = "SWIM version $version
Copyright (C) 2000 - by Jonathan Rosenbaum for ThE_* Project
This may be freely redistributed under the terms of the GNU General Public License
@ -1723,7 +1728,7 @@ Quit?:press q here\n";
# nusage
sub nusage {
$save = "SWIM version $swim_version
$save = "SWIM version $version
Copyright (C) 2000 - by Jonathan Rosenbaum for ThE_* Project
This may be freely redistributed under the terms of the GNU General Public License
@ -1816,7 +1821,7 @@ Hints: Searches - equiv. negated [^...]
# differnces between swim and rpm.
sub help {
$save = "SWIM version $swim_version
$save = "SWIM version $version
Copyright (C) 2000 - by Jonathan Rosenbaum for ThE_* Project
This may be freely redistributed under the terms of the GNU General Public License
@ -2053,3 +2058,31 @@ sub pager {
print PAGER $text;
close PAGER;
} # end sub pager
# Pulled this from *_pkg from the gbootroot project.
sub home_builder {
my ($home_builder) = @_;
if (!-d $home_builder) {
if (-e $home_builder) {
print "ERROR: A file exists where $home_builder should be.\n";
}
else {
my @directory_parts = split(m,/,,$home_builder);
my $placement = "/";
for (1 .. $#directory_parts) {
$_ == 1 ? ($placement = "/$directory_parts[$_]")
: ($placement = $placement . "/" . $directory_parts[$_]);
-d $placement or mkdir $placement;
}
}
}
} # end home_builder

Loading…
Cancel
Save