acmetool.spec 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. ##
  2. ## acmetool.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 information
  24. %define V_acmetool_base 0.0.49
  25. %define V_acmetool_snap 20160323
  26. # package information
  27. Name: acmetool
  28. Summary: ACME Client Utility
  29. URL: https://github.com/hlandau/acme
  30. Vendor: Hugo Landau
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Cryptography
  35. License: MIT
  36. Version: %{V_acmetool_base}
  37. Release: 20160323
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/acmetool/acmetool-%{V_acmetool_snap}.tar.xz
  40. Source1: acmetool-apache.conf
  41. Source2: acmetool-nginx.conf
  42. Source3: acmetool-responses.yaml
  43. Source4: acmetool-hook.sh
  44. Source5: acmetool-sudoers.txt
  45. Source6: acmetool.c
  46. Source7: rc.acmetool
  47. Patch0: acmetool.patch
  48. # build information
  49. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  50. PreReq: OpenPKG, openpkg >= 20160101, sudo, x509
  51. %description
  52. ACMETool is an easy-to-use command line tool for automatically
  53. acquiring certificates from ACME servers (such as Let's Encrypt).
  54. Designed to flexibly integrate into your webserver setup to enable
  55. automatic verification. Unlike the official Let's Encrypt client,
  56. this doesn't modify your web server configuration.
  57. %track
  58. prog acmetool:base = {
  59. version = %{V_acmetool_base}
  60. url = https://github.com/hlandau/acme/releases
  61. regex = v(__VER__)\.tar\.gz
  62. }
  63. prog acmetool:snap = {
  64. version = %{V_acmetool_snap}
  65. url = http://download.openpkg.org/components/versioned/acmetool/
  66. regex = acmetool-(__VER__)\.tar\.xz
  67. }
  68. %prep
  69. %setup -q -n acmetool
  70. %patch -p0
  71. %build
  72. # build the setuid wrapper
  73. cp %{SOURCE acmetool.c} .
  74. %{l_shtool} subst %{l_value -s -a} acmetool.c
  75. %{l_cc} %{l_cflags} %{l_ldflags} -o acmetool acmetool.c
  76. # build program
  77. %{l_shtool} subst %{l_value -s -a} \
  78. src/github.com/hlandau/acme/cmd/acmetool/main.go
  79. export GOPATH=`pwd`
  80. cd $GOPATH/src/github.com/hlandau/acme
  81. go build -x \
  82. -ldflags "-X github.com/hlandau/acme/hooks.DefaultPath=%{l_prefix}/libexec/acmetool/hook \
  83. -X github.com/hlandau/acme/storage.RecommendedPath=%{l_prefix}/var/acmetool/state \
  84. -X github.com/hlandau/acme/responder.StandardWebrootPath=%{l_prefix}/var/acmetool/root \
  85. -X github.com/hlandau/degoutils/buildinfo.RawBuildInfo=XX" \
  86. -o acmetool \
  87. cmd/acmetool/main.go \
  88. cmd/acmetool/quickstart-nlinux.go \
  89. cmd/acmetool/quickstart.go \
  90. cmd/acmetool/le-import.go
  91. %install
  92. # create directory hierarchy
  93. %{l_shtool} mkdir -f -p -m 755 \
  94. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  95. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  96. $RPM_BUILD_ROOT%{l_prefix}/etc/sudo/sudoers.d \
  97. $RPM_BUILD_ROOT%{l_prefix}/etc/acmetool \
  98. $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d \
  99. $RPM_BUILD_ROOT%{l_prefix}/etc/nginx/nginx.d \
  100. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/hook \
  101. $RPM_BUILD_ROOT%{l_prefix}/var/acmetool/root \
  102. $RPM_BUILD_ROOT%{l_prefix}/var/acmetool/state
  103. # install program
  104. %{l_shtool} install -c -s -m 755 \
  105. src/github.com/hlandau/acme/acmetool \
  106. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/
  107. # install setuid wrapper script
  108. %{l_shtool} install -c -m 755 \
  109. acmetool $RPM_BUILD_ROOT%{l_prefix}/sbin/
  110. # install hook script
  111. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  112. %{SOURCE acmetool-hook.sh} \
  113. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/hook/life-updated
  114. # install sudo(8) configuration
  115. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  116. %{SOURCE acmetool-sudoers.txt} \
  117. $RPM_BUILD_ROOT%{l_prefix}/etc/sudo/sudoers.d/acmetool
  118. # install responses file
  119. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  120. %{SOURCE acmetool-responses.yaml} \
  121. $RPM_BUILD_ROOT%{l_prefix}/etc/acmetool/responses.yaml
  122. # install Apache config
  123. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  124. %{SOURCE acmetool-apache.conf} \
  125. $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d/acmetool.conf
  126. # install NGINX config
  127. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  128. %{SOURCE acmetool-nginx.conf} \
  129. $RPM_BUILD_ROOT%{l_prefix}/etc/nginx/nginx.d/acmetool.conf
  130. # install run-command script
  131. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  132. %{SOURCE rc.acmetool} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  133. # determine installation files
  134. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  135. %{l_files_std} \
  136. '%config %{l_prefix}/etc/acmetool/*' \
  137. '%attr(0600,%{l_susr},%{l_sgrp}) %{l_prefix}/etc/sudo/sudoers.d/acmetool' \
  138. '%not %dir %{l_prefix}/etc/sudo/sudoers.d' \
  139. '%not %dir %{l_prefix}/etc/sudo' \
  140. '%attr(4755,%{l_rusr},%{l_rgrp}) %{l_prefix}/sbin/acmetool' \
  141. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/acmetool/*'
  142. %files -f files
  143. %clean
  144. %post
  145. if [ $1 -eq 1 ]; then
  146. # after install, show hint
  147. ( echo "First configure the ACMETool response file:"
  148. echo " \$ vi $RPM_INSTALL_PREFIX/etc/acmetool/responses.yaml"
  149. echo "Edit especially the acme-enter-email and acmetool-quickstart-choose-server"
  150. echo "variables. The following directory servers are known:"
  151. echo " https://acme-staging.api.letsencrypt.org/directory (Test, RSA or ECDSA)"
  152. echo " https://acme-v01.api.letsencrypt.org/directory (Live, RSA only)"
  153. echo "Then perform the initial setup with it:"
  154. echo " \$ $RPM_INSTALL_PREFIX/sbin/acmetool quickstart --batch"
  155. echo "Then you can request your certificate:"
  156. echo " \$ $RPM_INSTALL_PREFIX/sbin/acmetool want example.com"
  157. echo "The resulting certificate/private-key you can find under:"
  158. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/cert"
  159. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/chain"
  160. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/privkey"
  161. echo "For Apache/mod_ssl use them with:"
  162. echo " SSLCertificateFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/cert"
  163. echo " SSLCertificateChainFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/chain"
  164. echo " SSLCertificateKeyFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/privkey"
  165. ) | %{l_rpmtool} msg -b -t notice
  166. fi
  167. exit 0
  168. %preun
  169. # before erase, stop service and remove log files
  170. if [ $1 -eq 0 ]; then
  171. rm -rf $RPM_INSTALL_PREFIX/var/acmetool/root/* >/dev/null 2>&1 || true
  172. rm -rf $RPM_INSTALL_PREFIX/var/acmetool/state/* >/dev/null 2>&1 || true
  173. fi
  174. exit 0