confd.spec 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ##
  2. ## confd.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2017 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 0.14.0
  25. %define V_dist 20171106
  26. # package information
  27. Name: confd
  28. Summary: Configuration Management Server
  29. URL: http://www.confd.io/
  30. Vendor: Kelsey Hightower
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Networking
  35. License: MIT
  36. Version: %{V_opkg}.%{V_dist}
  37. Release: 20171106
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/confd/confd-%{V_dist}.tar.xz
  40. Source1: confd.toml
  41. Source2: rc.confd
  42. Source3: example.toml
  43. Source4: example.conf.tmpl
  44. # build information
  45. BuildPreReq: OpenPKG, openpkg >= 20160101, go, gb
  46. PreReq: OpenPKG, openpkg >= 20160101, etcd
  47. %description
  48. ConfD is a lightweight configuration management tool focusing on:
  49. keeping local configuration files up-to-date by polling EtcD, Consul
  50. or Vault and processing template resources; reloading applications
  51. to pick up new config file changes.
  52. %track
  53. prog confd = {
  54. version = %{version}
  55. url = https://github.com/kelseyhightower/confd/releases
  56. regex = v(\d+\.\d+\.\d+)\.tar\.gz
  57. }
  58. %prep
  59. %setup -q -n confd
  60. %build
  61. # patch path to configuration file
  62. %{l_shtool} subst \
  63. -e 's;/etc/confd/confd.toml;%{l_prefix}/etc/confd/confd.toml;' \
  64. src/github.com/kelseyhightower/confd/config.go
  65. # build program
  66. export GOPATH=`pwd`
  67. ( cd src/github.com/kelseyhightower/confd
  68. mkdir bin
  69. go build -x -o bin/confd .
  70. ) || exit $?
  71. %install
  72. # create directory hierarchy
  73. %{l_shtool} mkdir -f -p -m 755 \
  74. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  75. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  76. $RPM_BUILD_ROOT%{l_prefix}/etc/confd/conf.d \
  77. $RPM_BUILD_ROOT%{l_prefix}/etc/confd/templates \
  78. $RPM_BUILD_ROOT%{l_prefix}/var/confd/run \
  79. $RPM_BUILD_ROOT%{l_prefix}/var/confd/log \
  80. $RPM_BUILD_ROOT%{l_prefix}/var/confd/out
  81. # install program
  82. %{l_shtool} install -c -s -m 755 \
  83. src/github.com/kelseyhightower/confd/bin/confd \
  84. $RPM_BUILD_ROOT%{l_prefix}/sbin/confd
  85. # install configuration files
  86. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  87. %{SOURCE confd.toml} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/
  88. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  89. %{SOURCE example.toml} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/conf.d/
  90. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  91. %{SOURCE example.conf.tmpl} $RPM_BUILD_ROOT%{l_prefix}/etc/confd/templates/
  92. # install run-command script
  93. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  94. %{SOURCE rc.confd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  95. # determine installation files
  96. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  97. %{l_files_std} \
  98. '%config %{l_prefix}/etc/confd/conf.d/*' \
  99. '%config %{l_prefix}/etc/confd/templates/*' \
  100. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/confd/*'
  101. %files -f files
  102. %clean
  103. %post
  104. # after upgrade, restart service
  105. [ $1 -eq 2 ] || exit 0
  106. eval `%{l_rc} confd status 2>/dev/null`
  107. [ ".$confd_active" = .yes ] && %{l_rc} confd restart
  108. exit 0
  109. %preun
  110. # before erase, stop service and remove log files
  111. [ $1 -eq 0 ] || exit 0
  112. %{l_rc} confd stop 2>/dev/null
  113. rm -rf $RPM_INSTALL_PREFIX/var/confd/log/* >/dev/null 2>&1 || true
  114. rm -rf $RPM_INSTALL_PREFIX/var/confd/run/* >/dev/null 2>&1 || true
  115. rm -rf $RPM_INSTALL_PREFIX/var/confd/out/* >/dev/null 2>&1 || true
  116. exit 0