You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
6.6 KiB

  1. %define __spec_install_post %{nil}
  2. %define debug_package %{nil}
  3. %define __os_install_post %{nil}
  4. Name: ethermint
  5. Summary: ethermint enables ethereum as an ABCI application on tendermint and the COSMOS hub
  6. License: Apache 2.0
  7. URL: https://tendermint.com/
  8. Packager: Greg Szabo
  9. Requires: tendermint >= 0.10.0
  10. Requires(pre): /sbin/useradd
  11. Requires(post): %{__python}
  12. %description
  13. Ethermint enables ethereum to run as an ABCI application on tendermint and the COSMOS hub. This application allows you to get all the benefits of ethereum without having to run your own miners.
  14. %pre
  15. if ! %{__grep} -q '^%{name}:' /etc/passwd ; then
  16. useradd -k /dev/null -r -m -b %{_sysconfdir} %{name}
  17. fi
  18. %prep
  19. test -d "$GOPATH" || echo "GOPATH not set"
  20. test -d "$GOPATH"
  21. %{__mkdir_p} %{name}-%{version}
  22. cd %{name}-%{version}
  23. %{__mkdir_p} .%{_bindir} .%{_defaultlicensedir}/%{name} .%{_sysconfdir}/%{name}/tendermint .%{_datadir}/%{name} .%{_sysconfdir}/systemd/system .%{_sysconfdir}/systemd/system-preset
  24. %{__cp} $GOPATH/bin/%{name} .%{_bindir}
  25. %{__cp} $GOPATH/src/github.com/tendermint/%{name}/LICENSE .%{_defaultlicensedir}/%{name}
  26. %{__cp} $GOPATH/src/github.com/tendermint/%{name}/dev/genesis.json .%{_sysconfdir}/%{name}/genesis.json
  27. %{__cp} -r $GOPATH/src/github.com/tendermint/%{name}/dev/keystore .%{_sysconfdir}/%{name}
  28. %{__cat} << EOF > .%{_sysconfdir}/%{name}/tendermint/config.toml
  29. # This is a TOML config file.
  30. # For more information, see https://github.com/toml-lang/toml
  31. proxy_app = "tcp://127.0.0.1:46658"
  32. moniker = ""
  33. fast_sync = true
  34. db_backend = "leveldb"
  35. log_level = "debug"
  36. [rpc]
  37. laddr = "tcp://0.0.0.0:46657"
  38. [p2p]
  39. laddr = "tcp://0.0.0.0:46656"
  40. seeds = ""
  41. EOF
  42. %{__cat} << EOF > .%{_sysconfdir}/systemd/system/%{name}.service
  43. [Unit]
  44. Description=Ethermint
  45. #propagates activation, deactivation and activation fails.
  46. Requires=network-online.target
  47. #propagates activation, deactivation, activation fails and stops
  48. BindTo=%{name}-server.service
  49. #propagates stop and restart (one-way)
  50. PartOf=%{name}-server.service
  51. #order
  52. Before=%{name}-server.service
  53. After=network-online.target
  54. #propagates reload
  55. PropagatesReloadTo=%{name}-server.service
  56. ReloadPropagatedFrom=%{name}-server.service
  57. [Service]
  58. Environment="EMHOME=%{_sysconfdir}/%{name}"
  59. Restart=on-failure
  60. User=%{name}
  61. Group=%{name}
  62. PermissionsStartOnly=true
  63. ExecStart=%{_bindir}/%{name} --rpc --rpcaddr=0.0.0.0 --ws --wsaddr=0.0.0.0 --rpcapi eth,net,web3,personal,admin
  64. ExecReload=/bin/kill -HUP \$MAINPID
  65. KillSignal=SIGTERM
  66. [Install]
  67. WantedBy=multi-user.target
  68. Also=%{name}-server.service
  69. EOF
  70. %{__cat} << EOF > .%{_sysconfdir}/systemd/system/%{name}-server.service
  71. [Unit]
  72. Description=Ethermint server
  73. Requires=network-online.target
  74. BindTo=%{name}.service
  75. PartOf=%{name}.service
  76. After=network-online.target %{name}.service
  77. PropagatesReloadTo=%{name}.service
  78. ReloadPropagatedFrom=%{name}.service
  79. [Service]
  80. Environment="TMHOME=%{_sysconfdir}/%{name}/tendermint"
  81. Restart=on-failure
  82. User=%{name}
  83. Group=%{name}
  84. PermissionsStartOnly=true
  85. ExecStart=%{_bindir}/tendermint node
  86. ExecReload=/bin/kill -HUP \$MAINPID
  87. KillSignal=SIGTERM
  88. [Install]
  89. WantedBy=multi-user.target %{name}.service
  90. Also=%{name}.service
  91. EOF
  92. %{__cat} << EOF > .%{_sysconfdir}/systemd/system-preset/50-%{name}.preset
  93. disable %{name}.service
  94. disable %{name}-server.service
  95. EOF
  96. %{__cat} << EOF > .%{_datadir}/%{name}/tendermint-genesis-validator.json
  97. {
  98. "genesis_time":"2017-06-10T03:37:03Z",
  99. "chain_id":"my_testchain_id",
  100. "validators":
  101. [
  102. {
  103. "pub_key":{"type":"ed25519","data":"F651E966D30CEA413839D63D9EC37455DF1FB2DDC409A76555B0CD0B186723E4"},
  104. "amount":10,
  105. "name":"my_testchain_node"
  106. }
  107. ],
  108. "app_hash":"",
  109. "app_options": {}
  110. }
  111. EOF
  112. %{__cat} << EOF > .%{_datadir}/%{name}/priv_validator-example.json
  113. {"address":"AF5886732763B3A38861FC8D2AA2698A156D28BD","pub_key":{"type":"ed25519","data":"F651E966D30CEA413839D63D9EC37455DF1FB2DDC409A76555B0CD0B186723E4"},"last_height":159,"last_round":0,"last_step":3,"last_signature":{"type":"ed25519","data":"654E93AA49B91F48AFEBE172E2C296900339F8849577467AEA9885200D5D9CD4DC225BB099C436A60C832DD2A3C60B6834D9748C0F8E977420BF3696604E2F04"},"last_signbytes":"7B22636861696E5F6964223A22677265677465737431222C22766F7465223A7B22626C6F636B5F6964223A7B2268617368223A2246333144343534433043343939334237333641323332393738443738333645453846384642433031222C227061727473223A7B2268617368223A2246304430443241333933443241444530323739303244304438333643384532443938333231304234222C22746F74616C223A317D7D2C22686569676874223A3135392C22726F756E64223A302C2274797065223A327D7D","priv_key":{"type":"ed25519","data":"44BD99EE9FFAEA5CECA7E52EF7476A5C949BC8635BCB906468C7CC3456659809F651E966D30CEA413839D63D9EC37455DF1FB2DDC409A76555B0CD0B186723E4"}}
  114. EOF
  115. %{__chmod} -Rf a+rX,u+w,g-w,o-w .
  116. %build
  117. # Nothing to do here.
  118. %install
  119. cd %{name}-%{version}
  120. %{__cp} -a * %{buildroot}
  121. %post
  122. %{_bindir}/%{name} --datadir %{_sysconfdir}/%{name} init %{_sysconfdir}/%{name}/genesis.json
  123. 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
  124. tendermint_pubkey=`%{__python} -uc "import json ; print json.loads(open('%{_sysconfdir}/%{name}/tendermint/priv_validator.json').read())['pub_key']['data']"`
  125. test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json
  126. {
  127. "genesis_time": "2017-06-10T03:37:03Z",
  128. "chain_id": "my_chain_id",
  129. "validators":
  130. [
  131. {
  132. "pub_key":{"type":"ed25519","data":"$tendermint_pubkey"},
  133. "amount":10,
  134. "name":"my_testchain_node"
  135. }
  136. ],
  137. "app_hash": "",
  138. "app_options": {}
  139. }
  140. EOF
  141. %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/genesis.json
  142. systemctl daemon-reload
  143. systemctl enable %{name}
  144. %preun
  145. systemctl stop %{name} 2> /dev/null || :
  146. systemctl stop %{name}-service 2> /dev/null || :
  147. %postun
  148. systemctl daemon-reload
  149. %files
  150. %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}
  151. %config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/genesis.json
  152. %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/keystore
  153. %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/keystore/*
  154. %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/tendermint
  155. %config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/config.toml
  156. %{_bindir}/*
  157. %{_sysconfdir}/systemd/system/*
  158. %{_sysconfdir}/systemd/system-preset/*
  159. %dir %{_datadir}/%{name}
  160. %{_datadir}/%{name}/*
  161. %dir %{_defaultlicensedir}/%{name}
  162. %doc %{_defaultlicensedir}/%{name}/LICENSE