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" ] },