mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
drop pkgreader
This field currently has no use, and even if we'll need it later, we should implement it using pyalpm. This changes is made to support zstd-compressed packages.
This commit is contained in:
parent
bd1ac0962f
commit
eef3c96242
3 changed files with 2 additions and 68 deletions
|
@ -1,48 +0,0 @@
|
||||||
import tarfile
|
|
||||||
import logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
multikeys = {'depend', 'makepkgopt', 'optdepend', 'replaces', 'conflict',
|
|
||||||
'provides', 'license', 'backup', 'group', 'makedepend', 'checkdepend'}
|
|
||||||
|
|
||||||
def _add_to_dict(d, key, value):
|
|
||||||
if key in multikeys:
|
|
||||||
if key in d:
|
|
||||||
d[key].append(value)
|
|
||||||
else:
|
|
||||||
d[key] = [value]
|
|
||||||
else:
|
|
||||||
assert key not in d, 'unexpected multi-value key "%s"' % key
|
|
||||||
d[key] = value
|
|
||||||
|
|
||||||
def readpkg(file):
|
|
||||||
tar = tarfile.open(file)
|
|
||||||
for _ in range(5):
|
|
||||||
info = tar.next()
|
|
||||||
if info and info.name == '.PKGINFO':
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
logger.warn('%s is not a nice package!', file)
|
|
||||||
info = '.PKGINFO' # have to look further
|
|
||||||
|
|
||||||
f = tar.extractfile(info)
|
|
||||||
data = f.read().decode()
|
|
||||||
tar.close()
|
|
||||||
|
|
||||||
d = {}
|
|
||||||
key = None
|
|
||||||
for l in data.split('\n'):
|
|
||||||
if l.startswith('#'):
|
|
||||||
continue
|
|
||||||
if not l:
|
|
||||||
continue
|
|
||||||
if '=' not in l:
|
|
||||||
value += l
|
|
||||||
else:
|
|
||||||
if key is not None:
|
|
||||||
_add_to_dict(d, key, value)
|
|
||||||
key, value = l.split(' = ', 1)
|
|
||||||
_add_to_dict(d, key, value)
|
|
||||||
|
|
||||||
return d
|
|
|
@ -21,7 +21,6 @@ from tornado.ioloop import IOLoop
|
||||||
import tornado.process
|
import tornado.process
|
||||||
|
|
||||||
from .lib import archpkg
|
from .lib import archpkg
|
||||||
from . import pkgreader
|
|
||||||
from . import dbutil
|
from . import dbutil
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -362,13 +361,7 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
owner = 'uid_%d' % stat.st_uid
|
owner = 'uid_%d' % stat.st_uid
|
||||||
|
|
||||||
try:
|
info = None
|
||||||
info = pkgreader.readpkg(act.path)
|
|
||||||
except:
|
|
||||||
logger.error('failed to read info for package %s', act.path, exc_info=True)
|
|
||||||
info = None
|
|
||||||
info = pickle.dumps(info)
|
|
||||||
|
|
||||||
self._db.execute(
|
self._db.execute(
|
||||||
'''insert or replace into pkginfo
|
'''insert or replace into pkginfo
|
||||||
(filename, pkgrepo, pkgname, pkgarch, pkgver, forarch, state, owner, mtime, info) values
|
(filename, pkgrepo, pkgname, pkgarch, pkgver, forarch, state, owner, mtime, info) values
|
||||||
|
@ -499,7 +492,7 @@ def repomon(config):
|
||||||
if 'any' not in supported_archs:
|
if 'any' not in supported_archs:
|
||||||
supported_archs.append('any')
|
supported_archs.append('any')
|
||||||
# assume none of the archs has regex meta characters
|
# assume none of the archs has regex meta characters
|
||||||
regex = re.compile(r'(?:^|/)[^.].*-[^-]+-[\d.]+-(?:' + '|'.join(supported_archs) + r')\.pkg\.tar\.xz(?:\.sig)?$')
|
regex = re.compile(r'(?:^|/)[^.].*-[^-]+-[\d.]+-(?:' + '|'.join(supported_archs) + r')\.pkg\.tar\.(?:xz|zst)(?:\.sig)?$')
|
||||||
|
|
||||||
filter_func = partial(filter_pkg, regex)
|
filter_func = partial(filter_pkg, regex)
|
||||||
handler = EventHandler(
|
handler = EventHandler(
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
from subprocess import getoutput
|
|
||||||
allpkgs = getoutput(r"locate -be --regex '\.pkg\.tar\.xz$'").split('\n')
|
|
||||||
|
|
||||||
from archrepo2.pkgreader import readpkg
|
|
||||||
for p in allpkgs:
|
|
||||||
print('reading package:', p)
|
|
||||||
d = readpkg(p)
|
|
||||||
print('desc:', d.get('pkgdesc', '(nothing)'))
|
|
Loading…
Add table
Reference in a new issue