still working on pkgsearch.php::do_Details

This commit is contained in:
eric 2004-07-01 22:20:09 +00:00
parent ab6afc990c
commit 993fcb7811
5 changed files with 174 additions and 3 deletions

View file

@ -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 (

Binary file not shown.

View file

@ -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")