etcd.spec 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ##
  2. ## etcd.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2016 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package version
  24. %define V_opkg 3.0.9
  25. %define V_dist 20160916
  26. # package information
  27. Name: etcd
  28. Summary: High-Availability Distributed Key/Value Store
  29. URL: http://coreos.com/using-coreos/etcd/
  30. Vendor: CoreOS Project
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Network
  35. License: Apache
  36. Version: %{V_opkg}
  37. Release: 20160916
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/etcd/etcd-%{V_dist}.tar.xz
  40. Source1: etcd.conf
  41. Source2: rc.etcd
  42. Patch0: etcd.patch
  43. # build information
  44. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  45. PreReq: OpenPKG, openpkg >= 20160101
  46. %description
  47. EtcD is a highly-available key/value store for shared configuration
  48. and service discovery of a cluster, based on the RAFT consensus
  49. protocol to manage a highly-available replicated log. EtcD is
  50. usually used as the cluster manager for distributed applications.
  51. %track
  52. prog etcd:release = {
  53. version = %{V_opkg}
  54. url = https://github.com/coreos/etcd/releases
  55. regex = v(__VER__)\.tar\.gz
  56. }
  57. prog etcd:snapshot = {
  58. version = %{V_dist}
  59. url = http://download.openpkg.org/components/versioned/etcd/
  60. regex = etcd-(__VER__)\.tar\.xz
  61. }
  62. %prep
  63. %setup -q -n etcd
  64. %patch -p0
  65. %build
  66. # build program
  67. export GOPATH=`pwd`
  68. cd src/github.com/coreos/etcd
  69. GO_BUILD_FLAGS="-x" %{l_bash} ./build
  70. %install
  71. # create directory hierarchy
  72. %{l_shtool} mkdir -f -p -m 755 \
  73. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  74. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  75. $RPM_BUILD_ROOT%{l_prefix}/etc/etcd \
  76. $RPM_BUILD_ROOT%{l_prefix}/var/etcd/log \
  77. $RPM_BUILD_ROOT%{l_prefix}/var/etcd/run \
  78. $RPM_BUILD_ROOT%{l_prefix}/var/etcd/data
  79. # install program
  80. %{l_shtool} install -c -s -m 755 \
  81. src/github.com/coreos/etcd/bin/etcd \
  82. src/github.com/coreos/etcd/bin/etcdctl \
  83. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  84. # install default configutation
  85. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  86. %{SOURCE etcd.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/etcd/
  87. # install run-command script
  88. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  89. %{SOURCE rc.etcd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  90. # determine installation files
  91. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  92. %{l_files_std} \
  93. '%config %{l_prefix}/etc/etcd/*' \
  94. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/etcd/*'
  95. %files -f files
  96. %clean
  97. %post
  98. # after upgrade, restart service
  99. [ $1 -eq 2 ] || exit 0
  100. eval `%{l_rc} etcd status 2>/dev/null`
  101. [ ".$etcd_active" = .yes ] && %{l_rc} etcd restart
  102. exit 0
  103. %preun
  104. # before erase, stop service and remove log files
  105. [ $1 -eq 0 ] || exit 0
  106. %{l_rc} etcd stop 2>/dev/null
  107. rm -rf $RPM_INSTALL_PREFIX/var/etcd/log/* >/dev/null 2>&1 || true
  108. rm -rf $RPM_INSTALL_PREFIX/var/etcd/run/* >/dev/null 2>&1 || true
  109. rm -rf $RPM_INSTALL_PREFIX/var/etcd/data/* >/dev/null 2>&1 || true
  110. exit 0