From 191b2301a1dae37cc69f6282049bb63c3deaa9da Mon Sep 17 00:00:00 2001 From: Greg Szabo Date: Tue, 12 Sep 2017 15:33:09 -0400 Subject: [PATCH] Cosmos-SDK package additional files --- build/cosmos-sdk/DEBIAN/changelog | 6 ++ build/cosmos-sdk/DEBIAN/compat | 1 + build/cosmos-sdk/DEBIAN/control | 15 +++++ build/cosmos-sdk/DEBIAN/copyright | 21 ++++++ build/cosmos-sdk/DEBIAN/postinst | 46 +++++++++++++ build/cosmos-sdk/DEBIAN/postrm | 41 ++++++++++++ build/cosmos-sdk/DEBIAN/preinst | 38 +++++++++++ build/cosmos-sdk/DEBIAN/prerm | 39 +++++++++++ .../systemd/system-preset/50-basecoin.preset | 3 + .../systemd/system/basecoin-server.service | 23 +++++++ .../etc/systemd/system/basecoin.service | 29 ++++++++ build/cosmos-sdk/usr/share/basecoin/key.json | 12 ++++ build/cosmos-sdk/usr/share/basecoin/key2.json | 12 ++++ build/spectemplates/cosmos-sdk.spec | 67 +++++++++++++++++++ 14 files changed, 353 insertions(+) create mode 100644 build/cosmos-sdk/DEBIAN/changelog create mode 100644 build/cosmos-sdk/DEBIAN/compat create mode 100644 build/cosmos-sdk/DEBIAN/control create mode 100644 build/cosmos-sdk/DEBIAN/copyright create mode 100644 build/cosmos-sdk/DEBIAN/postinst create mode 100644 build/cosmos-sdk/DEBIAN/postrm create mode 100644 build/cosmos-sdk/DEBIAN/preinst create mode 100644 build/cosmos-sdk/DEBIAN/prerm create mode 100644 build/cosmos-sdk/etc/systemd/system-preset/50-basecoin.preset create mode 100644 build/cosmos-sdk/etc/systemd/system/basecoin-server.service create mode 100644 build/cosmos-sdk/etc/systemd/system/basecoin.service create mode 100644 build/cosmos-sdk/usr/share/basecoin/key.json create mode 100644 build/cosmos-sdk/usr/share/basecoin/key2.json create mode 100644 build/spectemplates/cosmos-sdk.spec diff --git a/build/cosmos-sdk/DEBIAN/changelog b/build/cosmos-sdk/DEBIAN/changelog new file mode 100644 index 000000000..0b56180ec --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/changelog @@ -0,0 +1,6 @@ +cosmos-sdk (@VERSION@) @STABILITY@; urgency=medium + + * Automatic build. See https://github.com/tendermint/basecoin for more information. + + -- Greg Szabo @DATETIMESTAMP@ + diff --git a/build/cosmos-sdk/DEBIAN/compat b/build/cosmos-sdk/DEBIAN/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/compat @@ -0,0 +1 @@ +9 diff --git a/build/cosmos-sdk/DEBIAN/control b/build/cosmos-sdk/DEBIAN/control new file mode 100644 index 000000000..588e61fa2 --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/control @@ -0,0 +1,15 @@ +Source: cosmos-sdk +Section: net +Priority: optional +Maintainer: Greg Szabo +Build-Depends: debhelper (>=9) +Depends: tendermint (>=0.10.0) +Standards-Version: 3.9.6 +Homepage: https://tendermint.com +Package: cosmos-sdk +Architecture: amd64 +Version: @VERSION@ +Installed-Size: @INSTALLEDSIZE@ +Description: cosmos-sdk is a Proof-of-Stake framework + Cosmos-SDK is a general purpose framework for the Tendermint consensus engine to form a Proof-of-Stake cryptocurrency. + diff --git a/build/cosmos-sdk/DEBIAN/copyright b/build/cosmos-sdk/DEBIAN/copyright new file mode 100644 index 000000000..ddb9d0272 --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/copyright @@ -0,0 +1,21 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: cosmos-sdk +Source: https://github.com/cosmos/cosmos-sdk + +Files: * +Copyright: 2017 All In Bits, Inc. +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the full text of the Apache License 2.0 can be found + in the file `/usr/share/common-licenses/Apache-2.0'. diff --git a/build/cosmos-sdk/DEBIAN/postinst b/build/cosmos-sdk/DEBIAN/postinst new file mode 100644 index 000000000..39471823f --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/postinst @@ -0,0 +1,46 @@ +#!/bin/sh +# postinst script for cosmos-sdk +# + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + chown basecoin.basecoin /etc/basecoin + sudo -Hu basecoin basecoin init --home /etc/basecoin 2B24DEE2364762300168DF19B6C18BCE2D399EA2 + #The above command generates a genesis.json file that contains validators. This is wrong, the validator part should be empty. https://github.com/tendermint/basecoin/issues/124 + sudo -Hu basecoin tendermint init --home /etc/basecoin/tendermint + #The above command might need some kind of additional option in the future. https://github.com/tendermint/tendermint/issues/542 + chmod 755 /etc/basecoin/tendermint + chown basecoin.basecoin /etc/basecoin/tendermint + systemctl daemon-reload + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/build/cosmos-sdk/DEBIAN/postrm b/build/cosmos-sdk/DEBIAN/postrm new file mode 100644 index 000000000..e23f777d1 --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/postrm @@ -0,0 +1,41 @@ +#!/bin/sh +# postrm script for cosmos-sdk +# + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + upgrade|failed-upgrade|abort-upgrade) + systemctl daemon-reload + ;; + + purge|remove|abort-install|disappear) + systemctl daemon-reload + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/build/cosmos-sdk/DEBIAN/preinst b/build/cosmos-sdk/DEBIAN/preinst new file mode 100644 index 000000000..308cfb1e7 --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/preinst @@ -0,0 +1,38 @@ +#!/bin/sh +# preinst script for cosmos-sdk +# + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + if ! grep -q '^basecoin:' /etc/passwd ; then + useradd -k /dev/null -r -m -b /etc basecoin + chmod 755 /etc/basecoin + fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/build/cosmos-sdk/DEBIAN/prerm b/build/cosmos-sdk/DEBIAN/prerm new file mode 100644 index 000000000..63fd84409 --- /dev/null +++ b/build/cosmos-sdk/DEBIAN/prerm @@ -0,0 +1,39 @@ +#!/bin/sh +# prerm script for cosmos-sdk +# + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + systemctl stop basecoin 2> /dev/null || : + systemctl stop basecoin-service 2> /dev/null || : + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/build/cosmos-sdk/etc/systemd/system-preset/50-basecoin.preset b/build/cosmos-sdk/etc/systemd/system-preset/50-basecoin.preset new file mode 100644 index 000000000..c97097b13 --- /dev/null +++ b/build/cosmos-sdk/etc/systemd/system-preset/50-basecoin.preset @@ -0,0 +1,3 @@ +disable basecoin.service +disable basecoin-server.service + diff --git a/build/cosmos-sdk/etc/systemd/system/basecoin-server.service b/build/cosmos-sdk/etc/systemd/system/basecoin-server.service new file mode 100644 index 000000000..62392d52a --- /dev/null +++ b/build/cosmos-sdk/etc/systemd/system/basecoin-server.service @@ -0,0 +1,23 @@ +[Unit] +Description=Basecoin server +Requires=network-online.target +BindTo=basecoin.service +PartOf=basecoin.service +After=network-online.target basecoin.service +PropagatesReloadTo=basecoin.service +ReloadPropagatedFrom=basecoin.service + +[Service] +Environment="TMHOME=/etc/basecoin/tendermint" +Restart=on-failure +User=basecoin +Group=basecoin +PermissionsStartOnly=true +ExecStart=/usr/bin/tendermint node +ExecReload=/bin/kill -HUP $MAINPID +KillSignal=SIGTERM + +[Install] +WantedBy=multi-user.target basecoin.service +Also=basecoin.service + diff --git a/build/cosmos-sdk/etc/systemd/system/basecoin.service b/build/cosmos-sdk/etc/systemd/system/basecoin.service new file mode 100644 index 000000000..f806ef481 --- /dev/null +++ b/build/cosmos-sdk/etc/systemd/system/basecoin.service @@ -0,0 +1,29 @@ +[Unit] +Description=Basecoin +#propagates activation, deactivation and activation fails. +Requires=network-online.target +#propagates activation, deactivation, activation fails and stops +BindTo=basecoin-server.service +#propagates stop and restart (one-way) +PartOf=basecoin-server.service +#order +Before=basecoin-server.service +After=network-online.target +#propagates reload +PropagatesReloadTo=basecoin-server.service +ReloadPropagatedFrom=basecoin-server.service + +[Service] +Environment="BCHOME=/etc/basecoin" +Restart=on-failure +User=basecoin +Group=basecoin +PermissionsStartOnly=true +ExecStart=/usr/bin/basecoin start --without-tendermint +ExecReload=/bin/kill -HUP $MAINPID +KillSignal=SIGTERM + +[Install] +WantedBy=multi-user.target +Also=basecoin-server.service + diff --git a/build/cosmos-sdk/usr/share/basecoin/key.json b/build/cosmos-sdk/usr/share/basecoin/key.json new file mode 100644 index 000000000..bdefe8fd4 --- /dev/null +++ b/build/cosmos-sdk/usr/share/basecoin/key.json @@ -0,0 +1,12 @@ +{ + "address": "1B1BE55F969F54064628A63B9559E7C21C925165", + "priv_key": { + "type": "ed25519", + "data": "C70D6934B4F55F1B7BC33B56B9CA8A2061384AFC19E91E44B40C4BBA182953D1619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279" + }, + "pub_key": { + "type": "ed25519", + "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279" + } +} + diff --git a/build/cosmos-sdk/usr/share/basecoin/key2.json b/build/cosmos-sdk/usr/share/basecoin/key2.json new file mode 100644 index 000000000..ddfc6809b --- /dev/null +++ b/build/cosmos-sdk/usr/share/basecoin/key2.json @@ -0,0 +1,12 @@ +{ + "address": "1DA7C74F9C219229FD54CC9F7386D5A3839F0090", + "priv_key": { + "type": "ed25519", + "data": "34BAE9E65CE8245FAD035A0E3EED9401BDE8785FFB3199ACCF8F5B5DDF7486A8352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8" + }, + "pub_key": { + "type": "ed25519", + "data": "352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8" + } +} + diff --git a/build/spectemplates/cosmos-sdk.spec b/build/spectemplates/cosmos-sdk.spec new file mode 100644 index 000000000..56697c6f5 --- /dev/null +++ b/build/spectemplates/cosmos-sdk.spec @@ -0,0 +1,67 @@ +Version: @VERSION@ +Release: @BUILD_NUMBER@ + +%define __spec_install_post %{nil} +%define debug_package %{nil} +%define __os_install_post %{nil} + +Name: cosmos-sdk +Summary: cosmos-sdk is a Proof-of-Stake framework +License: Apache 2.0 +URL: https://cosmos.network/ +Packager: Greg Szabo +Requires: tendermint >= 0.10.0 +Provides: basecoin basecli +#Requires(pre): useradd + +%description +Cosmos-SDK is a general purpose framework for the Tendermint consensus engine to form a Proof-of-Stake cryptocurrency. + +%pre +if ! %{__grep} -q '^%{name}:' /etc/passwd ; then + useradd -k /dev/null -r -m -b %{_sysconfdir} %{name} + chmod 755 %{_sysconfdir}/%{name} +fi + +%prep +# Nothing to do here. - It is done in the Makefile. + +%build +# Nothing to do here. + +%install +cd %{name}-%{version}-%{release} +%{__cp} -a * %{buildroot} + +%post +sudo -Hu %{name} basecoin init --home %{_sysconfdir}/%{name} 2B24DEE2364762300168DF19B6C18BCE2D399EA2 +#The above command generates a genesis.json file that contains validators. This is wrong, the validator part should be empty. https://github.com/tendermint/basecoin/issues/124 +sudo -Hu %{name} tendermint init --home %{_sysconfdir}/%{name}/tendermint +#The above command might need some kind of additional option in the future. https://github.com/tendermint/tendermint/issues/542 + +chmod 755 %{_sysconfdir}/%{name}/tendermint + +#Temporary until https://github.com/tendermint/basecoin/issues/123 +rm -f %{_sysconfdir}/%{name}/key.json +rm -f %{_sysconfdir}/%{name}/key2.json + +systemctl daemon-reload + +%preun +systemctl stop %{name} 2> /dev/null || : +systemctl stop %{name}-service 2> /dev/null || : + +%postun +systemctl daemon-reload + +%files +%ghost %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name} +%ghost %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/tendermint +%{_bindir}/* +%{_sysconfdir}/systemd/system/* +%{_sysconfdir}/systemd/system-preset/* +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/* +%dir %{_defaultlicensedir}/%{name} +%doc %{_defaultlicensedir}/%{name}/LICENSE +