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.

254 lines
8.6 KiB

  1. %define __spec_install_post %{nil}
  2. %define debug_package %{nil}
  3. %define __os_install_post %{nil}
  4. Name: basecoin
  5. Summary: basecoin is a Proof-of-Stake cryptocurrency and framework
  6. License: Apache 2.0
  7. URL: https://tendermint.com/
  8. Packager: Greg Szabo
  9. Requires: tendermint >= 0.10.0
  10. Provides: basecli
  11. Requires(pre): /sbin/useradd
  12. Requires(post): %{__python}
  13. %description
  14. Basecoin is an ABCI application designed to be used with the Tendermint consensus engine to form a Proof-of-Stake cryptocurrency. It also provides a general purpose framework for extending the feature-set of the cryptocurrency by implementing plugins.
  15. %pre
  16. if ! %{__grep} -q '^%{name}:' /etc/passwd ; then
  17. useradd -k /dev/null -r -m -b %{_sysconfdir} %{name}
  18. fi
  19. %prep
  20. test -d "$GOPATH" || echo "GOPATH not set"
  21. test -d "$GOPATH"
  22. %{__mkdir_p} %{name}-%{version}
  23. cd %{name}-%{version}
  24. %{__mkdir_p} .%{_bindir} .%{_defaultlicensedir}/%{name} .%{_sysconfdir}/%{name}/tendermint .%{_datadir}/%{name} .%{_sysconfdir}/systemd/system .%{_sysconfdir}/systemd/system-preset
  25. %{__cp} $GOPATH/bin/%{name} $GOPATH/bin/basecli .%{_bindir}
  26. %{__cp} $GOPATH/src/github.com/tendermint/%{name}/LICENSE .%{_defaultlicensedir}/%{name}
  27. #iso8601date=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
  28. %{__cat} << EOF > .%{_sysconfdir}/%{name}/genesis.json
  29. {
  30. "genesis_time": "2017-06-10T03:37:03Z",
  31. "chain_id": "my_chain_id",
  32. "validators": [],
  33. "app_hash": "",
  34. "app_options": {
  35. "accounts": [{
  36. "name": "dev_money",
  37. "address": "1B1BE55F969F54064628A63B9559E7C21C925165",
  38. "pub_key": {
  39. "type": "ed25519",
  40. "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
  41. },
  42. "coins": [
  43. {
  44. "denom": "mycoin",
  45. "amount": 9007199254740992
  46. }
  47. ]
  48. }]
  49. }
  50. }
  51. EOF
  52. %{__cat} << EOF > .%{_sysconfdir}/%{name}/tendermint/config.toml
  53. # This is a TOML config file.
  54. # For more information, see https://github.com/toml-lang/toml
  55. proxy_app = "tcp://127.0.0.1:36658"
  56. moniker = ""
  57. fast_sync = true
  58. db_backend = "leveldb"
  59. log_level = "debug"
  60. [rpc]
  61. laddr = "tcp://0.0.0.0:36657"
  62. [p2p]
  63. laddr = "tcp://0.0.0.0:36656"
  64. seeds = ""
  65. EOF
  66. %{__cat} << EOF > .%{_sysconfdir}/systemd/system/%{name}.service
  67. [Unit]
  68. Description=Basecoin
  69. #propagates activation, deactivation and activation fails.
  70. Requires=network-online.target
  71. #propagates activation, deactivation, activation fails and stops
  72. BindTo=%{name}-server.service
  73. #propagates stop and restart (one-way)
  74. PartOf=%{name}-server.service
  75. #order
  76. Before=%{name}-server.service
  77. After=network-online.target
  78. #propagates reload
  79. PropagatesReloadTo=%{name}-server.service
  80. ReloadPropagatedFrom=%{name}-server.service
  81. [Service]
  82. Environment="BCHOME=%{_sysconfdir}/%{name}"
  83. Restart=on-failure
  84. User=%{name}
  85. Group=%{name}
  86. PermissionsStartOnly=true
  87. ExecStart=%{_bindir}/%{name} start --without-tendermint
  88. ExecReload=/bin/kill -HUP \$MAINPID
  89. KillSignal=SIGTERM
  90. [Install]
  91. WantedBy=multi-user.target
  92. Also=%{name}-server.service
  93. EOF
  94. %{__cat} << EOF > .%{_sysconfdir}/systemd/system/%{name}-server.service
  95. [Unit]
  96. Description=Basecoin server
  97. Requires=network-online.target
  98. BindTo=%{name}.service
  99. PartOf=%{name}.service
  100. After=network-online.target %{name}.service
  101. PropagatesReloadTo=%{name}.service
  102. ReloadPropagatedFrom=%{name}.service
  103. [Service]
  104. Environment="TMHOME=%{_sysconfdir}/%{name}/tendermint"
  105. Restart=on-failure
  106. User=%{name}
  107. Group=%{name}
  108. PermissionsStartOnly=true
  109. ExecStart=%{_bindir}/tendermint node
  110. ExecReload=/bin/kill -HUP \$MAINPID
  111. KillSignal=SIGTERM
  112. [Install]
  113. WantedBy=multi-user.target %{name}.service
  114. Also=%{name}.service
  115. EOF
  116. %{__cat} << EOF > .%{_sysconfdir}/systemd/system-preset/50-%{name}.preset
  117. disable %{name}.service
  118. disable %{name}-server.service
  119. EOF
  120. %{__cat} << EOF > .%{_datadir}/%{name}/key.json
  121. {
  122. "address": "1B1BE55F969F54064628A63B9559E7C21C925165",
  123. "priv_key": {
  124. "type": "ed25519",
  125. "data": "C70D6934B4F55F1B7BC33B56B9CA8A2061384AFC19E91E44B40C4BBA182953D1619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
  126. },
  127. "pub_key": {
  128. "type": "ed25519",
  129. "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
  130. }
  131. }
  132. EOF
  133. %{__cat} << EOF > .%{_datadir}/%{name}/key2.json
  134. {
  135. "address": "1DA7C74F9C219229FD54CC9F7386D5A3839F0090",
  136. "priv_key": {
  137. "type": "ed25519",
  138. "data": "34BAE9E65CE8245FAD035A0E3EED9401BDE8785FFB3199ACCF8F5B5DDF7486A8352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8"
  139. },
  140. "pub_key": {
  141. "type": "ed25519",
  142. "data": "352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8"
  143. }
  144. }
  145. EOF
  146. %{__cat} << EOF > .%{_datadir}/%{name}/tendermint-genesis-validator.json
  147. {
  148. "genesis_time":"2017-06-10T03:37:03Z",
  149. "chain_id":"my_testchain_id",
  150. "validators":
  151. [
  152. {
  153. "pub_key":{"type":"ed25519","data":"F651E966D30CEA413839D63D9EC37455DF1FB2DDC409A76555B0CD0B186723E4"},
  154. "amount":10,
  155. "name":"my_testchain_node"
  156. }
  157. ],
  158. "app_hash":"",
  159. "app_options": {}
  160. }
  161. EOF
  162. %{__cat} << EOF > .%{_datadir}/%{name}/basecoin-genesis-devmoney.json
  163. {
  164. "genesis_time":"2017-06-10T03:37:03Z",
  165. "chain_id":"my_testchain_id",
  166. "validators": [],
  167. "app_hash":"",
  168. "app_options": {
  169. "accounts": [{
  170. "pub_key": {
  171. "type": "ed25519",
  172. "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
  173. },
  174. "coins": [
  175. {
  176. "denom": "mycoin",
  177. "amount": 9007199254740992
  178. }
  179. ]
  180. }]
  181. }
  182. }
  183. EOF
  184. %{__cat} << EOF > .%{_datadir}/%{name}/priv_validator-example.json
  185. {"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"}}
  186. EOF
  187. %{__chmod} -Rf a+rX,u+w,g-w,o-w .
  188. %build
  189. # Nothing to do here.
  190. %install
  191. cd %{name}-%{version}
  192. %{__cp} -a * %{buildroot}
  193. %post
  194. 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
  195. 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
  196. tendermint_pubkey=`%{__python} -uc "import json ; print json.loads(open('%{_sysconfdir}/%{name}/tendermint/priv_validator.json').read())['pub_key']['data']"`
  197. test ! -f %{_sysconfdir}/%{name}/tendermint/genesis.json && %{__cat} << EOF > %{_sysconfdir}/%{name}/tendermint/genesis.json
  198. {
  199. "genesis_time": "2017-06-10T03:37:03Z",
  200. "chain_id": "my_chain_id",
  201. "validators":
  202. [
  203. {
  204. "pub_key":{"type":"ed25519","data":"$tendermint_pubkey"},
  205. "amount":10,
  206. "name":"my_testchain_node"
  207. }
  208. ],
  209. "app_hash": "",
  210. "app_options": {}
  211. }
  212. EOF
  213. %{__chown} %{name}.%{name} %{_sysconfdir}/%{name}/tendermint/genesis.json
  214. systemctl daemon-reload
  215. systemctl enable %{name}
  216. %preun
  217. systemctl stop %{name} 2> /dev/null || :
  218. systemctl stop %{name}-service 2> /dev/null || :
  219. %postun
  220. systemctl daemon-reload
  221. %files
  222. %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}
  223. #%ghost %attr(0400, %{name}, %{name}) %{_sysconfdir}/%{name}/priv_validator.json
  224. %config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/genesis.json
  225. %attr(0755, %{name}, %{name}) %dir %{_sysconfdir}/%{name}/tendermint
  226. #%ghost %attr(0400, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/priv_validator.json
  227. %config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/config.toml
  228. #%ghost %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tendermint/genesis.json
  229. %{_bindir}/*
  230. %{_sysconfdir}/systemd/system/*
  231. %{_sysconfdir}/systemd/system-preset/*
  232. %dir %{_datadir}/%{name}
  233. %{_datadir}/%{name}/*
  234. %dir %{_defaultlicensedir}/%{name}
  235. %doc %{_defaultlicensedir}/%{name}/LICENSE