From 69a184cb757a9f6eb0d8dc0dc433f227c1991655 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 5 May 2019 00:56:33 -0700 Subject: [PATCH] apt repo convenience script --- .dockerignore | 3 ++- .gitignore | 2 ++ README.md | 23 +++++++++++++++-------- repobot/__init__.py | 2 +- repobot/aptprovider.py | 9 ++++++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7f43f86..1bdea3f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,4 +8,5 @@ testenv2/* test/* aptly/* wheel/* -dist/* \ No newline at end of file +dist/* +extpython/* diff --git a/.gitignore b/.gitignore index 8b91784..6b902c5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ __pycache__ /build /dist /repos.db* +/extpython +/wheel diff --git a/README.md b/README.md index 181160f..adfa747 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + docker-artifact =============== @@ -22,24 +23,24 @@ Examples Upload python package: -`curl -vv -F 'f=@pyircbot-4.0.0.post3-py3.5.egg' 'http://localhost:8080/addpkg?provider=pypi&reponame=main&name=pyircbot&version=4.0.0'` +`curl -vv -F 'f=@pyircbot-4.0.0.post3-py3.5.egg' 'http://localhost:8080/addpkg?provider=pypi&reponame=reponame&name=pyircbot&version=4.0.0'` Install python packages: -`pip3 install -i http://host/repo/pypi/main/ --trusted-host host ` +`pip3 install -i http://host/repo/pypi/reponame/ --trusted-host host ` Upload apt package: -`curl -vv -F 'f=@python3_3.6.7-1~18.04_amd64.deb' 'http://host/addpkg?provider=apt&reponame=main&name=python3&version=3.6.7-1~18.04&dist=bionic'` +`curl -vv -F 'f=@python3_3.6.7-1~18.04_amd64.deb' 'http://host/addpkg?provider=apt&reponame=reponame&name=python3&version=3.6.7-1~18.04&dist=bionic'` Install apt packages: ``` -wget -qO- http://host/repo/apt/main/pubkey | apt-key add - && \ -echo "deb http://host/repo/apt/main bionic main" | tee -a /etc/apt/sources.list && \ +wget -qO- http://host/repo/apt/reponame/pubkey | apt-key add - && \ +echo "deb http://host/repo/apt/reponame bionic main" | tee -a /etc/apt/sources.list && \ apt-get update ``` @@ -51,11 +52,11 @@ Building on the rest endpoints above: Apt: -* `rpcli -s http://localhost:8080 upload -y apt -f extpython-python3.6_3.6.7_amd64.deb_trusty -r exttest -p extpython-python3.6 -i 3.6.7 -a dist=trusty` +* `rpcli -s http://localhost:8080 upload -y apt -f extpython-python3.6_3.6.7_amd64.deb_trusty -r reponame -p extpython-python3.6 -i 3.6.7 -a dist=trusty` Python: -* `rpcli -s http://localhost:8080 upload -y pypi -f tensorflow-2.0.0a0-cp37-cp37m-manylinux1_x86_64.whl -r ttest2 -p tensorflow -i 2.0.0a0` +* `rpcli -s http://localhost:8080 upload -y pypi -f tensorflow-2.0.0a0-cp37-cp37m-manylinux1_x86_64.whl -r reponame -p tensorflow -i 2.0.0a0` Notes @@ -64,13 +65,19 @@ Notes * Repos are created automatically when a package is added to them. * Repo URLs are structured as: `/repo//`. URLs at and below this level are handled directly by the provider. -* In the apt provider, only binary-amd64 packages are supported. No source, binary-386 or other groups +* In the apt provider, only binary-amd64 packages are supported. No source, binary-i386 or other groups * In the apt provider, every repo has only one component, named "main" * The apt provider will generate a gpg key per repo upon repo creation * The repo contents can be browsed on the web * This uses my fork of python-dpkg, from [here](https://git.davepedu.com/dave/python-dpkg), which is not automatically installed via `setup.py` due to pip limitations. +* The apt provider includes a convenience shell script: +``` +apt-get update && \ +apt-get install -y wget gnupg && \ +wget -qO- http://host/repo/apt/reponame/dists/trusty/install | bash -x /dev/stdin +``` Todo ---- diff --git a/repobot/__init__.py b/repobot/__init__.py index 260c070..f9aa3e1 100644 --- a/repobot/__init__.py +++ b/repobot/__init__.py @@ -1 +1 @@ -__version__ = "0.3.1" +__version__ = "0.3.2" diff --git a/repobot/aptprovider.py b/repobot/aptprovider.py index f2fa371..53d49c5 100644 --- a/repobot/aptprovider.py +++ b/repobot/aptprovider.py @@ -336,7 +336,7 @@ class AptWeb(object): "regen
".format(reponame=repo.name) for dist in db().query(AptDist).filter(AptDist.repo == repo).order_by(AptDist.name).all(): - yield "{name}: Packages Release Release.gpg
".format(reponame=repo.name, name=dist.name) + yield "{name}: Packages Release Release.gpg install
".format(reponame=repo.name, name=dist.name) if regen: self.base.regen_dist(dist.id) @@ -380,6 +380,13 @@ class AptDists(object): return dist.release_cache elif target == "Release.gpg": return dist.sig_cache + elif target == "install": + + return """#!/bin/sh -ex +wget -qO- {scheme}://{host}/repo/apt/{reponame}/pubkey | apt-key add - +echo 'deb {scheme}://{host}/repo/apt/{reponame}/ {dist} main' | tee /etc/apt/sources.list.d/{reponame}-{dist}.list +apt-get update +""".format(scheme=cherrypy.request.scheme, host=cherrypy.request.headers['Host'], reponame=repo.name, dist=dist.name) else: raise cherrypy.HTTPError(404)