diff options
author | eric <eric> | 2004-07-01 22:20:09 +0000 |
---|---|---|
committer | eric <eric> | 2004-07-01 22:20:09 +0000 |
commit | 993fcb7811d763368a6940730d3870b0013623c0 (patch) | |
tree | 4665a7a5abc964b4877ffebed626835a83789773 | |
parent | ab6afc990ccfca02e3c027be2b97ded6c9f51ad6 (diff) |
still working on pkgsearch.php::do_Details
-rw-r--r-- | support/schema/aur-schema.sql | 19 | ||||
-rw-r--r-- | support/schema/dummy-data.sql.bz2 | bin | 687908 -> 782756 bytes | |||
-rwxr-xr-x | support/schema/gendummydata.py | 38 | ||||
-rw-r--r-- | web/lib/aur.inc | 18 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc | 102 |
5 files changed, 174 insertions, 3 deletions
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index dd02310..fde8b95 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -108,7 +108,6 @@ CREATE TABLE Packages ( CategoryID TINYINT UNSIGNED NOT NULL, Description CHAR(128) NOT NULL DEFAULT "An Arch Package", URL CHAR(255) NOT NULL DEFAULT "http://www.archlinux.org", - Source CHAR(255) NOT NULL DEFAULT "/dev/null", LocationID TINYINT UNSIGNED NOT NULL, NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0, OutOfDate TINYINT UNSIGNED DEFAULT 0, @@ -133,6 +132,24 @@ CREATE TABLE Packages ( ); +-- Track which dependencies a package has +-- +CREATE TABLE PackageDepends ( + PackageID INTEGER UNSIGNED NOT NULL, + DepPkgID INTEGER UNSIGNED NOT NULL, + INDEX (PackageID) +); + + +-- Track which sources a package has +-- +CREATE TABLE PackageSources ( + PackageID INTEGER UNSIGNED NOT NULL, + Source CHAR(255) NOT NULL DEFAULT "/dev/null", + INDEX (PackageID) +); + + -- Track votes for packages -- CREATE TABLE PackageVotes ( diff --git a/support/schema/dummy-data.sql.bz2 b/support/schema/dummy-data.sql.bz2 Binary files differindex 6a502a0..7f34228 100644 --- a/support/schema/dummy-data.sql.bz2 +++ b/support/schema/dummy-data.sql.bz2 diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py index 917b569..32e202d 100755 --- a/support/schema/gendummydata.py +++ b/support/schema/gendummydata.py @@ -20,6 +20,8 @@ MAX_DEVS = .1 # what percentage of MAX_USERS are Developers MAX_TUS = .2 # what percentage of MAX_USERS are Trusted Users MAX_PKGS = 2500 # how many packages to load PKG_FILES = (8, 30) # min/max number of files in a package +PKG_DEPS = (1, 5) # min/max depends a package has +PKG_SRC = (1, 3) # min/max sources a package has VOTING = (0, .30) # percentage range for package voting RANDOM_PATHS = [ # random path locations for package files "/usr/bin", "/usr/lib", "/etc", "/etc/rc.d", "/usr/share", "/lib", @@ -27,6 +29,10 @@ RANDOM_PATHS = [ # random path locations for package files "/usr/X11R6/lib", "/usr/libexec", "/usr/man/man1", "/usr/man/man3", "/usr/man/man5", "/usr/X11R6/man/man1", "/etc/profile.d" ] +RANDOM_TLDS = ["edu", "com", "org", "net", "tw", "ru", "pl", "de", "es"] +RANDOM_URL = ["http://www.", "ftp://ftp.", "http://", "ftp://"] +RANDOM_LOCS = ["pub", "release", "files", "downloads", "src"] + import random import time @@ -327,6 +333,38 @@ for p in track_votes.keys(): s = "UPDATE Packages SET NumVotes = %d WHERE ID = %d;\n" % (track_votes[p], p) out.write(s) +# Create package dependencies and sources +# +if DBUG: print "."; print "Creating statements for package depends/sources.", +count = 0 +for p in seen_pkgs.keys(): + num_deps = random.randrange(PKG_DEPS[0], PKG_DEPS[1]) + this_deps = {} + i = 0 + while i != num_deps: + dep = random.randrange(0, len(seen_pkgs)) + if not this_deps.has_key(dep): + s = "INSERT INTO PackageDepends VALUES (%d, %d);\n" % (seen_pkgs[p], dep) + out.write(s) + i += 1 + + num_sources = random.randrange(PKG_SRC[0], PKG_SRC[1]) + for i in range(num_sources): + src_file = user_keys[random.randrange(0, len(user_keys))] + src = "%s%s.%s/%s/%s-%s.tar.gz" % ( + RANDOM_URL[random.randrange(0,len(RANDOM_URL))], + p, RANDOM_TLDS[random.randrange(0,len(RANDOM_TLDS))], + RANDOM_LOCS[random.randrange(0,len(RANDOM_LOCS))], + src_file, genVersion()) + s = "INSERT INTO PackageSources VALUES (%d, '%s');\n" % ( + seen_pkgs[p], src) + out.write(s) + + if count % 100 == 0: + if DBUG: print ".", + count += 1 + + # close output file # out.write("\n") diff --git a/web/lib/aur.inc b/web/lib/aur.inc index f97a131..bdec643 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -140,6 +140,24 @@ function new_sid() { } +# obtain the username if given their Users.ID +# +function username_from_id($id="") { + if (!$id) { + return ""; + } + $dbh = db_connect(); + $q = "SELECT Username FROM Users WHERE ID = " . mysql_escape_string($id); + $result = db_query($q, $dbh); + if (!$result) { + return "None"; + } + $row = mysql_fetch_row($result); + + return $row[0]; +} + + # obtain the username if given their current SID # function username_from_sid($sid="") { diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 8894d3c..0c2e868 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -33,10 +33,51 @@ function pkgLocations() { return $locs; } +# grab package dependencies +# +function package_dependencies($pkgid=0) { + $deps = array(); + if ($pkgid) { + $dbh = db_connect(); + $q = "SELECT DepPkgID, Name FROM PackageDepends, Packages "; + $q.= "WHERE PackageDepends.DepPkgID = Packages.ID "; + $q.= "AND PackageDepends.PackageID = ".mysql_escape_string($pkgid); + $q.= " ORDER BY Name"; + $result = db_query($q, $dbh); + if (!$result) {return array();} + while ($row = mysql_fetch_row($result)) { + $deps[] = $row; + } + } + return $deps; +} + +# grab package sources +# +function package_sources($pkgid=0) { + $sources = array(); + if ($pkgid) { + $dbh = db_connect(); + $q = "SELECT Source FROM PackageSources "; + $q.= "WHERE PackageID = ".mysql_escape_string($pkgid); + $q.= " ORDER BY Source"; + $result = db_query($q, $dbh); + if (!$result) {return array();} + while ($row = mysql_fetch_row($result)) { + $sources[] = $row[0]; + } + } + return $sources; +} + # display package details # function package_details($id=0) { - $q = "SELECT * FROM Packages WHERE ID = ".intval($_REQUEST["ID"]); + $q = "SELECT *,Location,Category "; + $q.= "FROM Packages,PackageLocations,PackageCategories "; + $q.= "WHERE Packages.LocationID = PackageLocations.ID "; + $q.= "AND Packages.CategoryID = PackageCategories.ID "; + $q.= "ANd Packages.ID = ".intval($_REQUEST["ID"]); $dbh = db_connect(); $results = db_query($q, $dbh); if (!$results) { @@ -63,7 +104,64 @@ function package_details($id=0) { print "<center>\n"; print "<table>\n"; print "<tr>\n"; - print " <td colspan='2'><span class='f2'>NAME</span></td>\n"; + print " <td colspan='2'><span class='f2'>"; + print $row["Name"] . "-" . $row["Version"]."</span></td>\n"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><span class='f3'>"; + print "<a href='".$row["URL"]."'>".$row["URL"]."</a></span></td>\n"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><span class='f3'>".$row["Description"]; + print "</a></span></td>\n"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><img src='/images/pad.gif' height='30'></td>"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><span class='f3'>"; + print $row["Location"]." :: ".$row["Category"]."</span></td>"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><span class='f3'>".__("Maintainer").": "; + if (isset($row["AURMaintainerUID"])) { + $maintainer = username_from_id($row["AURMaintainerUID"]); + } elseif (isset($row["MaintainerUID"])) { + $maintainer = username_from_id($row["MaintainerUID"]); + } else { + $maintainer = "None"; + } + print $maintainer . "</span></td>"; + print "</tr>\n"; + print "<tr>\n"; + print " <td colspan='2'><img src='/images/pad.gif' height='30'></td>"; + print "</tr>\n"; + print "<tr>\n"; + print " <td valign='top' style='padding-right: 10'>"; + print "<table class='boxSoft' style='width: 200px'>"; + print "<tr><td class='boxSoftTitle'><span class='f3'>"; + print "Dependencies</span></td></tr>\n"; + print "<tr><td class='boxSoft'>"; + $deps = package_dependencies($row["ID"]); # $deps[0] = array('id','name'); + while (list($k, $darr) = each($deps)) { + print $darr[0]." - ".$darr[1]."<br />\n"; + } + print "</td></tr>\n"; + print "</table></td>"; + + print " <td valign='top'>"; + print "<table class='boxSoft' style='width: 200px'>"; + print "<tr><td class='boxSoftTitle'><span class='f3'>"; + print "Sources</span></td></tr>\n"; + print "<tr><td class='boxSoft'>"; + $sources = package_sources($row["ID"]); # $sources[0] = 'src'; + while (list($k, $src) = each($sources)) { + # TODO left off here... URLify + print $src."<br />\n"; + } + print "</td></tr>\n"; + print "</table></td>"; + print "</tr>\n"; print "</table>\n"; |