From e280cbdeadd1fda76ea0680131445196684f3e8a Mon Sep 17 00:00:00 2001 From: Greg Szabo Date: Tue, 20 Jun 2017 13:07:01 +0000 Subject: [PATCH] Reorganized extrafiles to prepare for non-rpmbuild build. --- devops/rpmbuild/Makefile | 2 +- .../extrafiles/DEBIAN-basecoin/control | 1 + .../extrafiles/DEBIAN-basecoin/postinst | 27 ++-------- .../extrafiles/DEBIAN-basecoin/postrm | 1 - .../extrafiles/DEBIAN-ethermint/control | 1 + .../extrafiles/DEBIAN-ethermint/postinst | 29 ++--------- .../systemd/system-preset}/50-basecoin.preset | 0 .../systemd/system}/basecoin-server.service | 0 .../{ => etc/systemd/system}/basecoin.service | 0 .../rpmbuild/extrafiles/basecoin/genesis.json | 23 --------- .../basecoin/tendermint-config.toml | 16 ------ .../{ => usr/share/basecoin}/key.json | 0 .../{ => usr/share/basecoin}/key2.json | 0 .../system-preset}/50-ethermint.preset | 0 .../systemd/system}/ethermint-server.service | 0 .../systemd/system}/ethermint.service | 0 .../ethermint/tendermint-config.toml | 16 ------ devops/rpmbuild/spectemplates/basecoin.spec | 51 +++++-------------- devops/rpmbuild/spectemplates/ethermint.spec | 33 ++---------- 19 files changed, 27 insertions(+), 173 deletions(-) rename devops/rpmbuild/extrafiles/basecoin/{ => etc/systemd/system-preset}/50-basecoin.preset (100%) rename devops/rpmbuild/extrafiles/basecoin/{ => etc/systemd/system}/basecoin-server.service (100%) rename devops/rpmbuild/extrafiles/basecoin/{ => etc/systemd/system}/basecoin.service (100%) delete mode 100644 devops/rpmbuild/extrafiles/basecoin/genesis.json delete mode 100644 devops/rpmbuild/extrafiles/basecoin/tendermint-config.toml rename devops/rpmbuild/extrafiles/basecoin/{ => usr/share/basecoin}/key.json (100%) rename devops/rpmbuild/extrafiles/basecoin/{ => usr/share/basecoin}/key2.json (100%) rename devops/rpmbuild/extrafiles/ethermint/{ => etc/systemd/system-preset}/50-ethermint.preset (100%) rename devops/rpmbuild/extrafiles/ethermint/{ => etc/systemd/system}/ethermint-server.service (100%) rename devops/rpmbuild/extrafiles/ethermint/{ => etc/systemd/system}/ethermint.service (100%) delete mode 100644 devops/rpmbuild/extrafiles/ethermint/tendermint-config.toml diff --git a/devops/rpmbuild/Makefile b/devops/rpmbuild/Makefile index fa8c5c455..4ca6b6566 100644 --- a/devops/rpmbuild/Makefile +++ b/devops/rpmbuild/Makefile @@ -43,7 +43,7 @@ all: $(binaries) build: $(build-binaries) package: $(package-rpm) $(package-deb) install: $(install-rpm) $(install-deb) -$(binaries): %: build-% package-rpm-% install-rpm-% package-deb-% install-deb-% ; +$(binaries): %: build-% package-rpm-% package-deb-% ### # Building the binaries is not in the spec file, because in the spec file you already need to know the version number diff --git a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/control b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/control index 7d86a71b5..be77d46c9 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/control +++ b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: Greg Szabo Build-Depends: debhelper (>=9) Depends: tendermint (>=0.10.0) +Breaks: ethermint Standards-Version: 3.9.6 Homepage: https://tendermint.com Package: basecoin diff --git a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst index 3d558b2b1..9c79599f7 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst +++ b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postinst @@ -20,30 +20,11 @@ set -e case "$1" in configure) chown basecoin.basecoin /etc/basecoin - chown basecoin.basecoin /etc/basecoin/genesis.json chown basecoin.basecoin /etc/basecoin/tendermint - chown basecoin.basecoin /etc/basecoin/tendermint/config.toml - test ! -f /etc/basecoin/priv_validator.json && tendermint gen_validator > /etc/basecoin/priv_validator.json && chmod 0400 /etc/basecoin/priv_validator.json && chown basecoin.basecoin /etc/basecoin/priv_validator.json - test ! -f /etc/basecoin/tendermint/priv_validator.json && tendermint gen_validator > /etc/basecoin/tendermint/priv_validator.json && chmod 0400 /etc/basecoin/tendermint/priv_validator.json && chown basecoin.basecoin /etc/basecoin/tendermint/priv_validator.json - tendermint_pubkey="`tendermint show_validator --home /etc/basecoin/tendermint --log_level error`" - chown basecoin.basecoin /etc/basecoin/tendermint/data - test ! -f /etc/basecoin/tendermint/genesis.json && cat << EOF > /etc/basecoin/tendermint/genesis.json -{ - "genesis_time": "2017-06-10T03:37:03Z", - "chain_id": "my_chain_id", - "validators": - [ - { - "pub_key": $tendermint_pubkey, - "amount":10, - "name":"my_testchain_node" - } - ], - "app_hash": "", - "app_options": {} -} -EOF - chown basecoin.basecoin /etc/basecoin/tendermint/genesis.json + sudo -Hu basecoin basecoin init --home /etc/basecoin + #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 systemctl daemon-reload systemctl enable basecoin ;; diff --git a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postrm b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postrm index b8e3c39bd..76202534f 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postrm +++ b/devops/rpmbuild/extrafiles/DEBIAN-basecoin/postrm @@ -28,7 +28,6 @@ case "$1" in purge|remove|abort-install|disappear) systemctl daemon-reload -# userdel basecoin ;; *) diff --git a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/control b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/control index 0904eb4e8..7558a2780 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/control +++ b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: Greg Szabo Build-Depends: debhelper (>=9) Depends: tendermint (>=0.10.0) +Breaks: basecoin Standards-Version: 3.9.6 Homepage: https://tendermint.com Package: ethermint diff --git a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst index f096dabe7..f347dd5be 100644 --- a/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst +++ b/devops/rpmbuild/extrafiles/DEBIAN-ethermint/postinst @@ -22,37 +22,14 @@ case "$1" in chown ethermint.ethermint /etc/ethermint chown ethermint.ethermint /etc/ethermint/genesis.json chown ethermint.ethermint /etc/ethermint/tendermint - chown ethermint.ethermint /etc/ethermint/tendermint/config.toml chown ethermint.ethermint /etc/ethermint/keystore chown ethermint.ethermint /etc/ethermint/keystore/UTC--2016-10-21T22-30-03.071787745Z--7eff122b94897ea5b0e2a9abf47b86337fafebdc - /usr/bin/ethermint --datadir /etc/ethermint init /etc/ethermint/genesis.json - chown -R ethermint.ethermint /etc/ethermint/ethermint - test ! -f /etc/ethermint/tendermint/priv_validator.json && tendermint gen_validator > /etc/ethermint/tendermint/priv_validator.json && chmod 0400 /etc/ethermint/tendermint/priv_validator.json && chown ethermint.ethermint /etc/ethermint/tendermint/priv_validator.json - tendermint_pubkey="`tendermint show_validator --home /etc/ethermint/tendermint --log_level error`" - chown ethermint.ethermint /etc/ethermint/tendermint/data - test ! -f /etc/ethermint/tendermint/genesis.json && cat << EOF > /etc/ethermint/tendermint/genesis.json -{ - "genesis_time": "2017-06-10T03:37:03Z", - "chain_id": "my_chain_id", - "validators": - [ - { - "pub_key": $tendermint_pubkey, - "amount":10, - "name":"my_testchain_node" - } - ], - "app_hash": "", - "app_options": {} -} -EOF - chown ethermint.ethermint /etc/ethermint/tendermint/genesis.json + sudo -Hu ethermint /usr/bin/ethermint --datadir /etc/ethermint init /etc/ethermint/genesis.json + sudo -Hu ethermint tendermint init --home /etc/ethermint/tendermint + systemctl daemon-reload systemctl enable ethermint - if [ -d /etc/ethermint/tendermint/data ]; then - service ethermint start - fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/devops/rpmbuild/extrafiles/basecoin/50-basecoin.preset b/devops/rpmbuild/extrafiles/basecoin/etc/systemd/system-preset/50-basecoin.preset similarity index 100% rename from devops/rpmbuild/extrafiles/basecoin/50-basecoin.preset rename to devops/rpmbuild/extrafiles/basecoin/etc/systemd/system-preset/50-basecoin.preset diff --git a/devops/rpmbuild/extrafiles/basecoin/basecoin-server.service b/devops/rpmbuild/extrafiles/basecoin/etc/systemd/system/basecoin-server.service similarity index 100% rename from devops/rpmbuild/extrafiles/basecoin/basecoin-server.service rename to devops/rpmbuild/extrafiles/basecoin/etc/systemd/system/basecoin-server.service diff --git a/devops/rpmbuild/extrafiles/basecoin/basecoin.service b/devops/rpmbuild/extrafiles/basecoin/etc/systemd/system/basecoin.service similarity index 100% rename from devops/rpmbuild/extrafiles/basecoin/basecoin.service rename to devops/rpmbuild/extrafiles/basecoin/etc/systemd/system/basecoin.service diff --git a/devops/rpmbuild/extrafiles/basecoin/genesis.json b/devops/rpmbuild/extrafiles/basecoin/genesis.json deleted file mode 100644 index fc998aa6c..000000000 --- a/devops/rpmbuild/extrafiles/basecoin/genesis.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "genesis_time": "2017-06-10T03:37:03Z", - "chain_id": "my_chain_id", - "validators": [], - "app_hash": "", - "app_options": { - "accounts": [{ - "name": "dev_money", - "address": "1B1BE55F969F54064628A63B9559E7C21C925165", - "pub_key": { - "type": "ed25519", - "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279" - }, - "coins": [ - { - "denom": "mycoin", - "amount": 9007199254740992 - } - ] - }] - } -} - diff --git a/devops/rpmbuild/extrafiles/basecoin/tendermint-config.toml b/devops/rpmbuild/extrafiles/basecoin/tendermint-config.toml deleted file mode 100644 index 9da5d5053..000000000 --- a/devops/rpmbuild/extrafiles/basecoin/tendermint-config.toml +++ /dev/null @@ -1,16 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -proxy_app = "tcp://127.0.0.1:46658" -moniker = "" -fast_sync = true -db_backend = "leveldb" -log_level = "debug" - -[rpc] -laddr = "tcp://0.0.0.0:46657" - -[p2p] -laddr = "tcp://0.0.0.0:46656" -seeds = "" - diff --git a/devops/rpmbuild/extrafiles/basecoin/key.json b/devops/rpmbuild/extrafiles/basecoin/usr/share/basecoin/key.json similarity index 100% rename from devops/rpmbuild/extrafiles/basecoin/key.json rename to devops/rpmbuild/extrafiles/basecoin/usr/share/basecoin/key.json diff --git a/devops/rpmbuild/extrafiles/basecoin/key2.json b/devops/rpmbuild/extrafiles/basecoin/usr/share/basecoin/key2.json similarity index 100% rename from devops/rpmbuild/extrafiles/basecoin/key2.json rename to devops/rpmbuild/extrafiles/basecoin/usr/share/basecoin/key2.json diff --git a/devops/rpmbuild/extrafiles/ethermint/50-ethermint.preset b/devops/rpmbuild/extrafiles/ethermint/etc/systemd/system-preset/50-ethermint.preset similarity index 100% rename from devops/rpmbuild/extrafiles/ethermint/50-ethermint.preset rename to devops/rpmbuild/extrafiles/ethermint/etc/systemd/system-preset/50-ethermint.preset diff --git a/devops/rpmbuild/extrafiles/ethermint/ethermint-server.service b/devops/rpmbuild/extrafiles/ethermint/etc/systemd/system/ethermint-server.service similarity index 100% rename from devops/rpmbuild/extrafiles/ethermint/ethermint-server.service rename to devops/rpmbuild/extrafiles/ethermint/etc/systemd/system/ethermint-server.service diff --git a/devops/rpmbuild/extrafiles/ethermint/ethermint.service b/devops/rpmbuild/extrafiles/ethermint/etc/systemd/system/ethermint.service similarity index 100% rename from devops/rpmbuild/extrafiles/ethermint/ethermint.service rename to devops/rpmbuild/extrafiles/ethermint/etc/systemd/system/ethermint.service diff --git a/devops/rpmbuild/extrafiles/ethermint/tendermint-config.toml b/devops/rpmbuild/extrafiles/ethermint/tendermint-config.toml deleted file mode 100644 index 9da5d5053..000000000 --- a/devops/rpmbuild/extrafiles/ethermint/tendermint-config.toml +++ /dev/null @@ -1,16 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -proxy_app = "tcp://127.0.0.1:46658" -moniker = "" -fast_sync = true -db_backend = "leveldb" -log_level = "debug" - -[rpc] -laddr = "tcp://0.0.0.0:46657" - -[p2p] -laddr = "tcp://0.0.0.0:46656" -seeds = "" - diff --git a/devops/rpmbuild/spectemplates/basecoin.spec b/devops/rpmbuild/spectemplates/basecoin.spec index cf88d3d50..2bc0b6f05 100644 --- a/devops/rpmbuild/spectemplates/basecoin.spec +++ b/devops/rpmbuild/spectemplates/basecoin.spec @@ -27,17 +27,12 @@ test -d "$GOPATH" %{__mkdir_p} %{name}-%{version} cd %{name}-%{version} -%{__mkdir_p} .%{_bindir} .%{_defaultlicensedir}/%{name} .%{_sysconfdir}/%{name}/tendermint .%{_datadir}/%{name} .%{_sysconfdir}/systemd/system .%{_sysconfdir}/systemd/system-preset +%{__mkdir_p} .%{_bindir} .%{_defaultlicensedir}/%{name} .%{_sysconfdir}/%{name}/tendermint %{__cp} $GOPATH/bin/%{name} $GOPATH/bin/basecli .%{_bindir} %{__cp} $GOPATH/src/github.com/tendermint/%{name}/LICENSE .%{_defaultlicensedir}/%{name} -%{__cp} %{_topdir}/extrafiles/%{name}/genesis.json .%{_sysconfdir}/%{name}/genesis.json -%{__cp} %{_topdir}/extrafiles/%{name}/tendermint-config.toml .%{_sysconfdir}/%{name}/tendermint/config.toml -%{__cp} %{_topdir}/extrafiles/%{name}/%{name}.service .%{_sysconfdir}/systemd/system/%{name}.service -%{__cp} %{_topdir}/extrafiles/%{name}/%{name}-server.service .%{_sysconfdir}/systemd/system/%{name}-server.service -%{__cp} %{_topdir}/extrafiles/%{name}/50-%{name}.preset .%{_sysconfdir}/systemd/system-preset/50-%{name}.preset -%{__cp} %{_topdir}/extrafiles/%{name}/key.json .%{_datadir}/%{name}/key.json -%{__cp} %{_topdir}/extrafiles/%{name}/key2.json .%{_datadir}/%{name}/key2.json + +cp -r %{_topdir}/extrafiles/* ./ %{__chmod} -Rf a+rX,u+w,g-w,o-w . @@ -49,49 +44,29 @@ cd %{name}-%{version} %{__cp} -a * %{buildroot} %post -test ! -f %{_sysconfdir}/%{name}/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/priv_validator.json -test ! -f %{_sysconfdir}/%{name}/tendermint/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/priv_validator.json -tendermint_pubkey="`tendermint show_validator --home %{_sysconfdir}/%{name}/tendermint --log_level error`" -%{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/data -test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json -{ - "genesis_time": "2017-06-10T03:37:03Z", - "chain_id": "my_chain_id", - "validators": - [ - { - "pub_key": $tendermint_pubkey, - "amount":10, - "name":"my_testchain_node" - } - ], - "app_hash": "", - "app_options": {} -} -EOF -%{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/genesis.json +sudo -Hu %{name} basecoin init --home %{_sysconfdir}/%{name} +#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 + +#Temporary until https://github.com/tendermint/basecoin/issues/123 +rm -f %{_sysconfdir}/%{name}/key.json +rm -f %{_sysconfdir}/%{name}/key2.json + + systemctl daemon-reload systemctl enable %{name} -if [ -d /etc/%{name}/tendermint/data ]; then - service %{name} start -fi %preun systemctl stop %{name} 2> /dev/null || : systemctl stop %{name}-service 2> /dev/null || : %postun -#userdel %{name} systemctl daemon-reload %files %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name} -#%ghost %attr(0400, %{name}, %{name}) %{_sysconfdir}/%{name}/priv_validator.json -%config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/genesis.json %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/tendermint -#%ghost %attr(0400, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/priv_validator.json -%config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/config.toml -#%ghost %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/genesis.json %{_bindir}/* %{_sysconfdir}/systemd/system/* %{_sysconfdir}/systemd/system-preset/* diff --git a/devops/rpmbuild/spectemplates/ethermint.spec b/devops/rpmbuild/spectemplates/ethermint.spec index bc4c3c020..012e79aef 100644 --- a/devops/rpmbuild/spectemplates/ethermint.spec +++ b/devops/rpmbuild/spectemplates/ethermint.spec @@ -31,10 +31,8 @@ cd %{name}-%{version} %{__cp} $GOPATH/src/github.com/tendermint/%{name}/LICENSE .%{_defaultlicensedir}/%{name} %{__cp} $GOPATH/src/github.com/tendermint/%{name}/dev/genesis.json .%{_sysconfdir}/%{name}/genesis.json %{__cp} -r $GOPATH/src/github.com/tendermint/%{name}/dev/keystore .%{_sysconfdir}/%{name} -%{__cp} %{_topdir}/extrafiles/%{name}/tendermint-config.toml .%{_sysconfdir}/%{name}/tendermint/config.toml -%{__cp} %{_topdir}/extrafiles/%{name}/%{name}.service .%{_sysconfdir}/systemd/system/%{name}.service -%{__cp} %{_topdir}/extrafiles/%{name}/%{name}-server.service .%{_sysconfdir}/systemd/system/%{name}-server.service -%{__cp} %{_topdir}/extrafiles/%{name}/50-%{name}.preset .%{_sysconfdir}/systemd/system-preset/50-%{name}.preset + +cp -r %{_topdir}/extrafiles/* ./ %{__chmod} -Rf a+rX,u+w,g-w,o-w . @@ -46,32 +44,10 @@ cd %{name}-%{version} %{__cp} -a * %{buildroot} %post -%{_bindir}/%{name} --datadir %{_sysconfdir}/%{name} init %{_sysconfdir}/%{name}/genesis.json -test ! -f %{_sysconfdir}/%{name}/tendermint/priv_validator.json && tendermint gen_validator > %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chmod} 0400 %{_sysconfdir}/%{name}/tendermint/priv_validator.json && %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/priv_validator.json -tendermint_pubkey="`tendermint show_validator --home %{_sysconfdir}/%{name}/tendermint --log_level error`" -%{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/data -test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json -{ - "genesis_time": "2017-06-10T03:37:03Z", - "chain_id": "my_chain_id", - "validators": - [ - { - "pub_key": $tendermint_pubkey, - "amount":10, - "name":"my_testchain_node" - } - ], - "app_hash": "", - "app_options": {} -} -EOF -%{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/genesis.json +sudo -Hu %{name} %{_bindir}/%{name} --datadir %{_sysconfdir}/%{name} init %{_sysconfdir}/%{name}/genesis.json +sudo -Hu %{name} tendermint init --home %{_sysconfdir}/%{name}/tendermint systemctl daemon-reload systemctl enable %{name} -if [ -d /etc/%{name}/tendermint/data ]; then - service %{name} start -fi %preun systemctl stop %{name} 2> /dev/null || : @@ -87,7 +63,6 @@ systemctl daemon-reload %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/keystore %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/keystore/* %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/tendermint -%config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/config.toml %{_bindir}/* %{_sysconfdir}/systemd/system/* %{_sysconfdir}/systemd/system-preset/*