Skip to content
Snippets Groups Projects
Unverified Commit c6c14bf5 authored by Max Adamo's avatar Max Adamo
Browse files

added shell script to create pkgs

parent 940c5837
Branches
No related tags found
No related merge requests found
packages/** filter=lfs diff=lfs merge=lfs -text
== A tool to manage certificate lifecycle on Vault, Redis, Consul
this tool is used in conjunction with certbot to upload certificates to the key stores
include requirements.txt
include README.rst
include LICENSE.md
# A tool to manage certificate lifecycle on Vault, Redis, Consul # A tool to manage certificates lifecycle on Vault, Redis, Consul
![Wile Coyote](https://filesender.geant.org/images/wile_coyote.jpg "Wile coyote") ![Wile Coyote](https://filesender.geant.org/images/wile_coyote.jpg "Wile coyote")
## Build & Install the package ## Install the package
The version number is defined in `./version/__init__.py`\ ### dependencies
In this README we assume that we are using version `0.5.0`
### Build pip `py-consul` is a fork of `python-consul` and is only available as PIP package.
```sh DEB users need to install `packages/deb/python3-py-consul_1.2.4-1_all.deb`
python3 setup.py bdist_wheel RPM users need to install `packages/rpm/py-consul-1.2.4-1.noarch.rpm`, as well as pip versions of `docopt` and `hvac` on CentOS 7. _[ **untested** ]_
pip install dist wile_coyote-0.5.0-py3-none-any.whl
```
### UBuildse RPM ### packages
```sh You can install one of the packages stored under the following directories:
python3 setup.py bdist_rpm
sudo rpm -Uvh dist/wile_coyote-0.5.0-1.noarch.rpm ```txt
packages/
├── deb
├── rpm
└── whl
``` ```
### Build DEB ## developer's notes
`DEB_BUILD_OPTIONS=nocheck` is required because `dh_auto_test` resets `$HOME` variable and the unit test fails because it won't find `acme.ini` ### version number
```sh the version number is stored inside `./version/__init__.py`
sudo apt install python3-stdeb fakeroot python-all dh-python
DEB_BUILD_OPTIONS=nocheck python3 setup.py --command-packages=stdeb.command bdist_deb
sudo dpkg -i deb_dist/python3-wile-coyote_0.5.0-1_all.deb
```
## create README.rst ### create README.rst
```sh ```sh
pandoc README.md --from markdown --to rst -s -o README.rst pandoc README.md --from markdown --to rst -s -o README.rst
......
A tool to manage certificate lifecycle on Vault, Redis, Consul A tool to manage certificates lifecycle on Vault, Redis, Consul
============================================================== ===============================================================
.. figure:: https://filesender.geant.org/images/wile_coyote.jpg .. figure:: https://filesender.geant.org/images/wile_coyote.jpg
:alt: Wile coyote :alt: Wile coyote
Wile Coyote Wile Coyote
Build & Install the package Install the package
--------------------------- -------------------
Let’s assume we have version ``0.5.0`` dependencies
~~~~~~~~~~~~
Use pip ``py-consul`` is a fork of ``python-consul`` and is only available as
~~~~~~~ PIP package.
.. code:: sh DEB users need to install
``packages/deb/python3-py-consul_1.2.4-1_all.deb`` RPM users need to
python3 setup.py bdist_wheel install ``packages/rpm/py-consul-1.2.4-1.noarch.rpm``, as well as pip
pip install dist wile_coyote-0.5.0-py3-none-any.whl versions of ``docopt`` and ``hvac`` on CentOS 7. *[*\ **untested**\ *]*
Use RPM packages
~~~~~~~ ~~~~~~~~
.. code:: sh You can install one of the packages stored under the following
directories:
python3 setup.py bdist_rpm .. code:: txt
rpm -Uvh dist/wile_coyote-0.5.0-1.noarch.rpm
Use DEB packages/
~~~~~~~ ├── deb
├── rpm
└── whl
sudo is required to install the packages and to create the debian developer’s notes
package -----------------
.. code:: sh version number
~~~~~~~~~~~~~~
sudo apt install python3-stdeb fakeroot python-all dh-python the version number is stored inside ``./version/__init__.py``
DEB_BUILD_OPTIONS=nocheck python3 setup.py --command-packages=stdeb.command bdist_deb
create README.rst create README.rst
----------------- ~~~~~~~~~~~~~~~~~
.. code:: sh .. code:: sh
......
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Anvil """Anvil,
wile_coyote test tool, erases, uploads and check certificates wile_coyote test tool, erases, uploads and checks certificates
validity onto test instances of Vault, Redis and Consul validity onto test instances of Vault, Redis and Consul.
In order to use Anvil you need to define a list of certificates
that you always expect to find in Vault, Redis and Consul.
Usage: Usage:
anvil.py [--prune] anvil.py [--prune]
...@@ -9,7 +11,7 @@ Usage: ...@@ -9,7 +11,7 @@ Usage:
Options: Options:
-h --help Show this screen. -h --help Show this screen.
-p --prune Client -p --prune Delete local certificates and fetch them again
""" """
import os import os
import re import re
......
#!/bin/bash
PATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
usage() {
echo ""
echo "Create Wile_Coyote DEB, RPM, PIP package"
echo "-----------------------------------------"
echo ""
echo "example: $(basename $0) --deb --pip"
echo ""
echo "Usage: $(basename $0)"
echo " -h | --help Print this help and exit"
echo " -d | --deb Create DEB package"
echo " -r | --rpm Create RPM package"
echo " -p | --pip Create PIP package"
echo ""
exit 3
}
parameters=0
OPTS=$(getopt -o "h,d,r,p" --longoptions "help,deb,rpm,pip" -- "$@")
if [ $? != 0 ]; then
usage
fi
eval set -- "$OPTS"
while true; do
case $1 in
-h | --help)
usage
;;
-d | --deb)
DEB='yes'
((parameters++))
;;
-r | --rpm)
RPM='yes'
((parameters++))
;;
-p | --pip)
PIP='yes'
((parameters++))
;;
--)
shift
break
;;
*)
break
;;
esac
shift
done
if [[ $parameters -eq 0 ]]; then
printf "\nYou need to use at least one option\n" >&2
usage
fi
VERSION=$(awk -F\' '/__version__/{print $2}' version/__init__.py)
# == Create RPM
#
if [[ -n $RPM ]]; then
RPM_NAME="wile_coyote-${VERSION}-1.noarch.rpm"
python3 setup.py bdist_rpm --packager="Massimiliano Adamo <massimiliano.adamo@geant.org" \
--requires="python3-redis, python36-requests, python36-pyOpenSSL"
if [[ $? -eq 0 ]]; then
mv dist/$RPM_NAME packages/rpm/
echo -e "\nthe package was created and stored as ./packages/rpm/${RPM_NAME}"
else
echo -e "\nthere was an error creating the package"
fi
fi
# == Create DEB
#
# reminder:
# `DEB_BUILD_OPTIONS=nocheck` is needed because `dh_auto_test` resets `$HOME`
# variable and the unit test fails because it won't find `acme.ini`
#
if [[ -n $DEB ]]; then
for pkg in python3-stdeb fakeroot python-all dh-python; do
if ! dpkg -l | grep -wq $pkg; then
echo "please use apt to install ${pkg}"
exit
fi
done
DEB_NAME="python3-wile-coyote_${VERSION}-1_all.deb"
DEB_BUILD_OPTIONS=nocheck python3 setup.py --command-packages=stdeb.command bdist_deb
if [[ $? -eq 0 ]]; then
mv deb_dist/$DEB_NAME packages/deb/
echo -e "\nthe package was created and stored as ./packages/deb/${DEB_NAME}"
else
echo -e "\nthere was an error creating the package"
fi
fi
# == Create PIP
#
if [[ -n $PIP ]]; then
PIP_NAME="wile_coyote-${VERSION}-py3-none-any.whl"
python3 setup.py bdist_wheel
if [[ $? -eq 0 ]]; then
mv dist/$PIP_NAME packages/pip/
echo -e "\nthe package was created and stored as ./packages/pip/${PIP_NAME}"
else
echo -e "\nthere was an error creating the package"
fi
fi
docopt==0.6.2
hvac==0.11.2
pyopenssl==22.0.0
py-consul==1.2.4
redis==3.5.3
requests==2.28.1
""" """
wile_coyote wile_coyote
""" """
from ensurepip import version
import os import os
from glob import glob from glob import glob
from shutil import rmtree from shutil import rmtree
from setuptools import setup, find_packages from setuptools import setup, find_packages
VERSION = __import__("version").__version__ version = __import__("version").__version__
description = """ this tool is used in conjunction with certbot to leverage
the lifecycle of the certificates on the key store"""
requirements = [
x.strip() for x in
open('requirements.txt').readlines() if not x.startswith('#') and x != '\n']
rmtree('dist', ignore_errors=True) rmtree('dist', ignore_errors=True)
rmtree('deb_dist', ignore_errors=True) rmtree('deb_dist', ignore_errors=True)
...@@ -19,19 +25,11 @@ def read(fname): ...@@ -19,19 +25,11 @@ def read(fname):
setup( setup(
name="wile_coyote", name="wile_coyote",
version=VERSION, version=version,
description="A tool to manage certificates on Vault, Redis, Consul", description="A tool to manage certificates on Vault, Redis, Consul",
long_description=read('Description.txt'), long_description=description,
url="https://gitlab.geant.net/devops/wile_coyote", url="https://gitlab.geant.org/devops/wile_coyote",
install_requires=[ install_requires=requirements,
'configparser==5.0.2',
'docopt==0.6.2',
'hvac==0.11.2',
'pyopenssl==22.0.0',
'python-consul2==0.1.5',
'redis==3.5.3',
'requests==2.28.1',
],
author="Massimiliano Adamo", author="Massimiliano Adamo",
author_email="massimiliano.adamo@geant.org", author_email="massimiliano.adamo@geant.org",
license='GPLv3', license='GPLv3',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment