summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/schema/aur-schema.sql20
-rwxr-xr-xsupport/schema/gendummydata.py106
2 files changed, 29 insertions, 97 deletions
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index cd24f38..6af8167 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -1,5 +1,5 @@
-- The MySQL database layout for the AUR. Certain data
--- is also included such as AccountTypes, PackageLocations, etc.
+-- is also included such as AccountTypes, etc.
--
DROP DATABASE AUR;
CREATE DATABASE AUR;
@@ -89,21 +89,6 @@ INSERT INTO PackageCategories (Category) VALUES ('x11');
INSERT INTO PackageCategories (Category) VALUES ('xfce');
--- The various repositories that a package could live in.
---
-CREATE TABLE PackageLocations (
- ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
- Location CHAR(32) NOT NULL,
- PRIMARY KEY (ID)
-);
-INSERT INTO PackageLocations (Location) VALUES ('none');
-INSERT INTO PackageLocations (Location) VALUES ('unsupported');
-INSERT INTO PackageLocations (Location) VALUES ('community');
-INSERT INTO PackageLocations (Location) VALUES ('current');
-INSERT INTO PackageLocations (Location) VALUES ('extra');
-INSERT INTO PackageLocations (Location) VALUES ('unstable');
-
-
-- Information about the actual packages
--
CREATE TABLE Packages (
@@ -116,7 +101,6 @@ CREATE TABLE Packages (
DummyPkg TINYINT UNSIGNED NOT NULL DEFAULT 0, -- 1=>dummy
FSPath CHAR(255) NOT NULL DEFAULT '',
License CHAR(40) NOT NULL DEFAULT '',
- LocationID TINYINT UNSIGNED NOT NULL DEFAULT 1,
NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0,
OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL,
SubmittedTS BIGINT UNSIGNED NOT NULL,
@@ -127,13 +111,11 @@ CREATE TABLE Packages (
PRIMARY KEY (ID),
UNIQUE (Name),
INDEX (CategoryID),
- INDEX (LocationID),
INDEX (DummyPkg),
INDEX (NumVotes),
INDEX (SubmitterUID),
INDEX (MaintainerUID),
FOREIGN KEY (CategoryID) REFERENCES PackageCategories(ID) ON DELETE NO ACTION,
- FOREIGN KEY (LocationID) REFERENCES PackageLocations(ID) ON DELETE NO ACTION,
FOREIGN KEY (SubmitterUID) REFERENCES Users(ID) ON DELETE NO ACTION,
FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE NO ACTION
);
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index 99f8195..a03b3e6 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -85,28 +85,21 @@ esc = db.escape_string
#
seen_users = {}
seen_pkgs = {}
-locations = {}
categories = {}
-location_keys = []
category_keys = []
user_keys = []
# some functions to generate random data
#
-def genVersion(location_id=0):
+def genVersion():
ver = []
ver.append("%d" % random.randrange(0,10))
ver.append("%d" % random.randrange(0,20))
if random.randrange(0,2) == 0:
ver.append("%d" % random.randrange(0,100))
- if location_id == 2: # the package is in the AUR
- return ".".join(ver) + "-u%d" % random.randrange(1,11)
- else:
- return ".".join(ver) + "%d" % random.randrange(1,11)
+ return ".".join(ver) + "-u%d" % random.randrange(1,11)
def genCategory():
return categories[category_keys[random.randrange(0,len(category_keys))]]
-def genLocation():
- return locations[location_keys[random.randrange(0,len(location_keys))]]
def genUID():
return seen_users[user_keys[random.randrange(0,len(user_keys))]]
@@ -162,7 +155,7 @@ contents = None
# Load package categories from database
#
-if DBUG: print "Loading package categories/locations..."
+if DBUG: print "Loading package categories..."
q = "SELECT * FROM PackageCategories"
dbc.execute(q)
row = dbc.fetchone()
@@ -171,16 +164,6 @@ while row:
row = dbc.fetchone()
category_keys = categories.keys()
-# Load package locations from database
-#
-q = "SELECT * FROM PackageLocations"
-dbc.execute(q)
-row = dbc.fetchone()
-while row:
- locations[row[1]] = row[0]
- row = dbc.fetchone()
-location_keys = locations.keys()
-
# done with the database
#
dbc.close()
@@ -243,14 +226,10 @@ for p in seen_pkgs.keys():
if count % 20 == 0: # every so often, there are orphans...
muid = 0
- location_id = genLocation()
- if location_id == 1: # unsupported pkgs don't have a maintainer
- muid = 0
-
uuid = genUID() # the submitter/user
- s = "INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID, SubmittedTS, SubmitterUID, MaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(location_id),
- genCategory(), location_id, NOW, uuid, muid)
+ s = "INSERT INTO Packages (ID, Name, Version, CategoryID, SubmittedTS, SubmitterUID, MaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(),
+ genCategory(), NOW, uuid, muid)
out.write(s)
if count % 100 == 0:
if DBUG: print ".",
@@ -265,63 +244,34 @@ for p in seen_pkgs.keys():
s = "INSERT INTO PackageComments (PackageID, UsersID, Comments, CommentTS) VALUES (%d, %d, '%s', %d);\n" % (seen_pkgs[p], genUID(), fortune, now)
out.write(s)
- if location_id == 1: # Unsupported - just a PKGBUILD and maybe other stuff
- others = random.randrange(0,3)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/PKGBUILD" % p,
+ others = random.randrange(0,3)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/PKGBUILD" % p,
+ random.randrange(0,999))
+ out.write(s)
+ if others == 0:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
random.randrange(0,999))
out.write(s)
- if others == 0:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- elif others == 1:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
- random.randrange(0,999))
- out.write(s)
+ elif others == 1:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
- elif others == 2:
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
- random.randrange(0,999))
- out.write(s)
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.install" % (p,p),
- random.randrange(0,999))
- out.write(s)
+ elif others == 2:
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.patch" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/arch.patch" % p,
+ random.randrange(0,999))
+ out.write(s)
+ s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], "/home/aur/incoming/%s/%s.install" % (p,p),
+ random.randrange(0,999))
+ out.write(s)
- else:
- # Create package contents
- #
- num_files = random.randrange(PKG_FILES[0], PKG_FILES[1])
- files = {}
- for f in range(num_files):
- loc = RANDOM_PATHS[random.randrange(len(RANDOM_PATHS))]
- if "lib" in loc:
- path = loc + "/lib" + p + ".so"
- elif "man" in loc:
- path = loc + "/" + p + "." + loc[-1] + ".gz"
- elif "share" in loc:
- path = loc + "/" + p + "/sounds/" + p + ".wav"
- elif "profile" in loc:
- path = loc + "/" + p + ".sh"
- elif "rc.d" in loc:
- path = loc + "/" + p
- elif "etc" in loc:
- path = loc + "/" + p + ".conf"
- elif "opt" in loc:
- path = loc + "/" + p + "/bin/" + p
- else:
- path = loc + "/" + p
- if not files.has_key(path):
- files[path] = 1
- s = "INSERT INTO PackageContents (PackageID, FSPath, FileSize) VALUES (%d, '%s', %d);\n" % (seen_pkgs[p], path,
- random.randrange(0,99999999))
- out.write(s)
if DBUG: print "."
# Cast votes