summaryrefslogtreecommitdiffstats
path: root/tupkg/update
diff options
context:
space:
mode:
authorpjmattal <pjmattal>2005-04-10 00:31:01 +0000
committerpjmattal <pjmattal>2005-04-10 00:31:01 +0000
commitda80234d77f7ea22613d19e0f8831fe91f4f4352 (patch)
tree0b87e0e66c8fe5c2a2fa1a9bbe5dbf8c4739c711 /tupkg/update
parent2f27045c0ffe988dcb2b94b2766d6a2e5f22abde (diff)
downloadaurweb-da80234d77f7ea22613d19e0f8831fe91f4f4352.tar.xz
added capability to get category from the directory in CVS
fixed bogus reference to subzero in the user docs
Diffstat (limited to 'tupkg/update')
-rwxr-xr-xtupkg/update/tupkgupdate30
1 files changed, 26 insertions, 4 deletions
diff --git a/tupkg/update/tupkgupdate b/tupkg/update/tupkgupdate
index 021c1e1..c828799 100755
--- a/tupkg/update/tupkgupdate
+++ b/tupkg/update/tupkgupdate
@@ -29,6 +29,7 @@ class Version:
class Package:
def __init__(self):
self.name = None
+ self.category = None
self.old = None
self.new = None
self.desc = None
@@ -56,11 +57,15 @@ class PackageDatabase:
return None
def insert(self, package, locationId):
warning("DB: Inserting package: " + package.name)
+ category_id = lookupCategory(package.category)
+ if (category_id == None):
+ category_id = 1
global repo_dir
q = self.cursor()
q.execute("INSERT INTO Packages " +
- "(Name, Version, FSPath, LocationID, Description, URL) VALUES ('" +
- MySQLdb.escape_string(package.name) + "', '" +
+ "(Name, CategoryID, Version, FSPath, LocationID, Description, URL) VALUES ('" +
+ MySQLdb.escape_string(package.name) + "', " +
+ str(category_id) + ", '" +
MySQLdb.escape_string(package.new.version) + "', '" +
MySQLdb.escape_string(
os.path.join(repo_dir, os.path.basename(package.new.file))) + "', " +
@@ -98,6 +103,14 @@ class PackageDatabase:
if (retval != None):
return retval
return self.createDummy(packagename)
+ def lookupCategory(self, categoryname):
+ warning("DB: Looking up category: " + categoryname)
+ q = self.cursor()
+ q.execute("SELECT ID from PackageCategories WHERE Category = '" + MySQLdb.escape_string(categoryname) + "'")
+ if (q.rowcount != 0):
+ row = q.fetchone()
+ return row[0]
+ return None
def createDummy(self, packagename):
warning("DB: Creating dummy package for: " + packagename)
q = self.cursor()
@@ -165,6 +178,14 @@ def infoFromPackageFile(filename):
return pkg.name, pkg.version + "-" + pkg.release
def infoFromPkgbuildFile(filename):
+ # first grab the category based on the file path
+ directory = os.path.dirname(os.path.abspath(filename))
+ m = re.match(r".*/([^/]+)$", directory)
+ if (m):
+ category = m.group(1)
+ else:
+ category = "none"
+
# open and source the file
pf_stdin, pf_stdout = os.popen2("/bin/bash", 't', 0)
print >>pf_stdin, ". " + filename
@@ -207,7 +228,7 @@ def infoFromPkgbuildFile(filename):
pf_stdin.close()
pf_stdout.close()
- return pkgname, pkgver + "-" + pkgrel, pkgdesc, url, depends, source
+ return pkgname, pkgver + "-" + pkgrel, pkgdesc, url, depends, source, category
def infoFromPkgbuildFileWorse(filename):
# load the file with pacman library
@@ -296,7 +317,7 @@ dbmodify = list()
a_files = pkgbuildsInTree(pkgbuild_dir)
for a_file in a_files:
- pkgname, ver, desc, url, depends, sources = infoFromPkgbuildFile(a_file)
+ pkgname, ver, desc, url, depends, sources, category = infoFromPkgbuildFile(a_file)
# Error (and skip) if we encounter any invalid PKGBUILD files
if (pkgname == None or ver == None):
@@ -315,6 +336,7 @@ for a_file in a_files:
package = Package()
package.name = pkgname
+ package.category = category
package.desc = desc
package.url = url
package.depends = depends