Commit efef3991 authored by Lisa's avatar Lisa

test-import uses os.path.join properly and ignores non-directories in the pacman local database.

parent 91e4d218
......@@ -21,18 +21,11 @@ except ImportError:
print "[!!] You need to install the python-pysqlite package to execute this script. Quitting..."
# Concatenate two paths (relative or non) safely
def concatenatePaths(path1, path2):
if (path1[-1] != '/'):
path1 += "/"
path1 += path2
return path1
# Reads the package name directly from the main information file
# This is much safer than obtaining it from the directory name for cause of
# inconsistencies in version specifications
def getPackageName(pkgDir):
descFile = open(concatenatePaths(pkgDir, "desc"), "r")
descFile = open(os.path.join(pkgDir, "desc"), "r")
isName = False
for line in descFile.readlines():
......@@ -68,7 +61,10 @@ def compareDatabases(pacmanDb, akabeiDb):
# Takes every package in the pacman database directory and looks for it in the akabei database
for pkgDir in os.listdir(pacmanDb):
pkgname = getPackageName(concatenatePaths(pacmanDb, pkgDir))
if not os.path.isdir(pkgDir):
pkgname = getPackageName(os.path.join(pacmanDb, pkgDir))
query = "SELECT * FROM packages WHERE name='" + pkgname + "'"
......@@ -153,4 +149,4 @@ if __name__ == "__main__":
if len(diff) > 0:
print "[!!] Package " + diff + " was found in pacman db but not in akabei db"
print "[**] Test passed."
\ No newline at end of file
print "[**] Test passed."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment