Skip to content

Commit

Permalink
add a half written Qkkk
Browse files Browse the repository at this point in the history
  • Loading branch information
farseerfc committed Jun 1, 2018
1 parent ebfa060 commit 3e9289f
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pacfiles/Qkkk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
import pyalpm
import pycman
import tarfile
import sys, os, os.path

pacmanconf = pycman.config.init_with_config("/etc/pacman.conf")
rootdir = pacmanconf.rootdir

def local_database():
handle = pacmanconf
localdb = handle.get_localdb()
packages = localdb.pkgcache
syncdbs = handle.get_syncdbs()
db = dict()
for pkg in packages:
for syncdb in syncdbs:
if syncdb.get_pkg(pkg.name) is not None:
db[pkg.name] = syncdb.get_pkg(pkg.name)
return db

def get_pkgfiles(package):
db = local_database()
pkg = db[package].filename
result = []
for d in pacmanconf.cachedirs:
p = os.path.join(d, pkg)
if os.path.exists(p):
result.append(p)
return result

def error_file(file, pkgfile, pkgname):
print(f'"{{file}}" in {{pkgfile}} of {{pkgname}} mismatch')

def check_pkgfile(pkgname, pkgfile):
with tarfile.open(pkgfile) as tar:
for fn in tar:
fnpath = os.path.join(rootdir, fn.name)
if fn.isdir():
if not os.path.isdir(fnpath):
error_file(fnpath, pkgfile, pkgname)
# else if fn.issym():
# if not os.path.issym(fnpath):

def main():
for pkgname in sys.args:
for pkgfile in get_pkgfiles(pkgname):
check_pkgfile(pkgname, pkgfile)

if __name__ == '__main__':
main()

0 comments on commit 3e9289f

Please sign in to comment.