From 0d6c37d0f8b125fc1ed928978da7aa6f84b9a588 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 30 May 2019 21:33:19 -0700 Subject: [PATCH] misc updates --- Dockerfile | 10 +++++----- README.md | 3 +++ repobot/aptprovider.py | 18 +++++++++++++----- setup.py | 3 ++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba86f6f..4faa60a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ FROM ubuntu:bionic RUN apt-get update && \ - apt-get install -y python3-pip gpgv1 gnupg1 gpg sudo wget git + apt-get install -y python3-pip gpgv1 gnupg1 gpg sudo wget git && \ + useradd artifactd ADD . /tmp/code RUN cd /tmp/code && \ pip3 install -r requirements.txt && \ - python3 setup.py install && \ - useradd repobot + python3 setup.py install -USER repobot +USER artifact -ENTRYPOINT ["repobotd"] +ENTRYPOINT ["artifactd"] diff --git a/README.md b/README.md index 2ea2249..6c5fdd8 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Todo * CLI tool (for adding packages only) * 'Simple' cli tool (shell script fetchable from the server for adding packages) +* Centralize deleting packages * Rpm Support * Auth * Support using existing GPG keys for apt @@ -100,3 +101,5 @@ Todo * Standardize what is returned from provider's web_addpkg * Standardize some fields of provider's schema (name, version) * Delete repos if empty (with option to disable per provider) +* Centralize the jinja template environment + * need a way for providers to register jinja filters though diff --git a/repobot/aptprovider.py b/repobot/aptprovider.py index 53d49c5..df3623a 100644 --- a/repobot/aptprovider.py +++ b/repobot/aptprovider.py @@ -422,13 +422,18 @@ class AptFiles(object): raise cherrypy.HTTPError(404) dpath = os.path.join(self.base.basepath, package.blobpath) + + if cherrypy.request.method == "DELETE": + db().delete(package) + self.base.s3.delete_object(Bucket=self.base.bucket, Key=dpath) + db().commit() + return + + elif cherrypy.request.method not in ("GET", "HEAD"): + raise cherrypy.HTTPError(405) + response = self.base.s3.get_object(Bucket=self.base.bucket, Key=dpath) - print("reading ", dpath) - - cherrypy.response.headers["Content-Type"] = "application/x-debian-package" - cherrypy.response.headers["Content-Length"] = response["ContentLength"] - def stream(): while True: data = response["Body"].read(65535) @@ -436,6 +441,9 @@ class AptFiles(object): return yield data + cherrypy.response.headers["Content-Type"] = "application/x-debian-package" + cherrypy.response.headers["Content-Length"] = response["ContentLength"] + return stream() __call__._cp_config = {'response.stream': True} diff --git a/setup.py b/setup.py index 76cbbc7..ffb7943 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,8 @@ setup(name='repobot', packages=['repobot'], entry_points={ "console_scripts": [ - "repobotd = repobot.server:main", + "repobotd = repobot.server:main", # legacy + "artifactd = repobot.server:main", "rpcli = repobot.cli:main" ] },