Update of /cvsroot/fink/scripts/pdb
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv5779
Modified Files:
Tag: redesign_pdb
dump
Log Message:
(This log message was meant for 1.8.2.7 of schema.sql as well)
- Allow 'dump' to run without db connection (needs correct 'rel_id' field
in that case)
- Remove 'latest_pkg' table, since a better sql is coming up no longer
needing this cache table
- Remove pacakge priority, since only one package version per rel/dist is
available in the pdb.
Index: dump
===================================================================
RCS file: /cvsroot/fink/scripts/pdb/dump,v
retrieving revision 1.32.2.6
retrieving revision 1.32.2.7
diff -u -d -r1.32.2.6 -r1.32.2.7
--- dump 8 Feb 2007 04:49:06 -0000 1.32.2.6
+++ dump 17 Feb 2007 19:12:09 -0000 1.32.2.7
@@ -35,16 +35,15 @@
use Getopt::Long;
-use DBI;
-
### get parameters
-my ($distribution, $release, $architecture, $wanthelp);
+my ($distribution, $release, $architecture, $rel_id, $tree, $wanthelp, $q);
# process command-line
GetOptions(
'distribution:s' => \$distribution,
'release:s' => \$release,
'architecture:s' => \$architecture,
+ 'rel_id:s' => \$rel_id,
'help' => \$wanthelp,
) or &die_with_usage;
&die_with_usage if $wanthelp;
@@ -55,7 +54,18 @@
### connect to database
-my ($dbh, $sth, $q, $rel, $mysql_datafile, $mysql_data);
+if (not eval { require DBI }) {
+ print "\nWARNING: Unable to connect to DB (DBI Perl module not found!)\n\n";
+ if ((not defined $rel_id) || (not $rel_id =~ m/^[0-9]+$/)) {
+ die("Call with '--rel_id=...' to specify the corresponing release id.
Stopped");
+ }
+ $tree = $release if (defined $release);
+ $tree = 'stable' if (defined $tree && $release =~ m/^[0-9.]{3,}$/);
+} else {
+
+### Try to connect to DB
+
+my ($dbh, $sth, $rel, $mysql_datafile, $mysql_data);
$mysql_datafile = $ENV{HOME}."/.finkdbi";
chomp($mysql_data = `cat $mysql_datafile`);
$dbh = DBI->connect(split(/\|/, $mysql_data));
@@ -84,7 +94,6 @@
$sth = $dbh->prepare($q);
$sth->execute();
my $numRows = $sth->rows;
-my ($tree, $rel_id);
if ($numRows < 1) {
print "No matching releases found!\n";
} else {
@@ -115,6 +124,12 @@
&die_with_usage if ($numRows != 1); # nothing to do
+} # if (eval { require DBI })
+
+
+&die_with_usage if (not defined $distribution);
+&die_with_usage if (not defined $release);
+&die_with_usage if (not defined $architecture);
### set default config
@@ -252,31 +267,6 @@
print "$q\n";
}
-### Refresh the table to find the latest package for each name
-### (this table exists to speed up the search in browse.php)
-print <<LATESETPKG;
-DELETE FROM latest_pkg;
-INSERT INTO latest_pkg
-SELECT pkg_id FROM (
- SELECT p.pkg_id, (d.priority*10000 + r.priority*100 + p.priority) AS pri,
p2.abspriority
- FROM package p, distribution_releases r, distribution d, (
- SELECT p.name, max(d1.priority*10000 + r1.priority*100 + p.priority) AS
abspriority
- FROM distribution d1, distribution_releases r1, package p
- WHERE p.rel_id = r1.rel_id
- AND r1.dist_id = d1.dist_id
- GROUP BY p.name
- ) AS p2
- WHERE p.name = p2.name
- AND p.rel_id = r.rel_id
- AND r.dist_id = d.dist_id
- HAVING pri = p2.abspriority
-) AS p
-ORDER BY p.pkg_id;
-LATESETPKG
-print "COMMIT;\n";
-print "OPTIMIZE TABLE package;\n";
-print "OPTIMIZE TABLE latest_pkg;\n";
-
if (defined $treelink) {
rm_f $treelink or print "Could not remove $treelink\n";
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits