Add apt repo info screen
This commit is contained in:
parent
31574f7123
commit
2b10e711b4
|
@ -148,11 +148,18 @@ class AptProvider(PkgProvider):
|
||||||
# TODO validate deb file name version against user passed version
|
# TODO validate deb file name version against user passed version
|
||||||
|
|
||||||
def browse(self, args):
|
def browse(self, args):
|
||||||
|
if not args:
|
||||||
|
with open(self.pubkeypath) as f:
|
||||||
|
pubkey_body = f.read()
|
||||||
|
return "<plaintext>{}\n\nSigning key:\n\n\n{}".format(self._get_gpg_info(), pubkey_body)
|
||||||
fpath = os.path.abspath(os.path.join(self.dir, "public", *args))
|
fpath = os.path.abspath(os.path.join(self.dir, "public", *args))
|
||||||
if not os.path.exists(fpath):
|
if not os.path.exists(fpath):
|
||||||
raise cherrypy.HTTPError(404)
|
raise cherrypy.HTTPError(404)
|
||||||
return cherrypy.lib.static.serve_file(fpath)
|
return cherrypy.lib.static.serve_file(fpath)
|
||||||
|
|
||||||
|
def _get_gpg_info(self):
|
||||||
|
return check_output(["gpg", "--list-keys"], env=self._env).decode("UTF-8")
|
||||||
|
|
||||||
def _generate_gpg_key(self):
|
def _generate_gpg_key(self):
|
||||||
"""
|
"""
|
||||||
Generate a GPG key for signing packages in this repo. Because only gpg2 supports unattended generation of
|
Generate a GPG key for signing packages in this repo. Because only gpg2 supports unattended generation of
|
||||||
|
@ -188,12 +195,15 @@ Expire-Date: 0
|
||||||
assert proc.returncode == 0
|
assert proc.returncode == 0
|
||||||
|
|
||||||
def _export_pubkey(self):
|
def _export_pubkey(self):
|
||||||
keypath = os.path.join(self.dir, "public", "repo.key")
|
if not os.path.exists(self.pubkeypath):
|
||||||
if not os.path.exists(keypath):
|
|
||||||
keydata = check_output(["gpg", "--export", "--armor", "aptmaster@localhost"], env=self._env)
|
keydata = check_output(["gpg", "--export", "--armor", "aptmaster@localhost"], env=self._env)
|
||||||
with open(keypath, "wb") as f:
|
with open(self.pubkeypath, "wb") as f:
|
||||||
f.write(keydata)
|
f.write(keydata)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pubkeypath(self):
|
||||||
|
return os.path.join(self.dir, "public", "repo.key")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _env(self):
|
def _env(self):
|
||||||
"""
|
"""
|
||||||
|
@ -205,7 +215,7 @@ Expire-Date: 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _gpg_dir(self):
|
def _gpg_dir(self):
|
||||||
return os.path.join(self.dir, "gpg")
|
return os.path.normpath(os.path.join(self.dir, "gpg"))
|
||||||
|
|
||||||
def get_path(self, pkgobj, fname):
|
def get_path(self, pkgobj, fname):
|
||||||
assert fname in pkgobj.data["files"]
|
assert fname in pkgobj.data["files"]
|
||||||
|
|
Loading…
Reference in New Issue