acmetool.spec 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 20160205
  25. %define V_acmetool_snap 20160205
  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: 20160205
  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
  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 = {
  59. version = %{V_acmetool_snap}
  60. url = http://download.openpkg.org/components/versioned/acmetool/
  61. regex = acmetool-(__VER__)\.tar\.xz
  62. }
  63. %prep
  64. %setup -q -n acmetool
  65. %patch -p0
  66. %build
  67. # build the setuid wrapper
  68. cp %{SOURCE acmetool.c} .
  69. %{l_shtool} subst %{l_value -s -a} acmetool.c
  70. %{l_cc} %{l_cflags} %{l_ldflags} -o acmetool acmetool.c
  71. # build program
  72. %{l_shtool} subst %{l_value -s -a} \
  73. src/github.com/hlandau/acme/cmd/acmetool/main.go
  74. export GOPATH=`pwd`
  75. cd $GOPATH/src/github.com/hlandau/acme
  76. go build -x \
  77. -ldflags "-X github.com/hlandau/acme/hooks.DefaultPath=%{l_prefix}/libexec/acmetool/hook \
  78. -X github.com/hlandau/acme/storage.RecommendedPath=%{l_prefix}/var/acmetool/state \
  79. -X github.com/hlandau/acme/responder.StandardWebrootPath=%{l_prefix}/var/acmetool/root \
  80. -X github.com/hlandau/degoutils/buildinfo.RawBuildInfo=XX" \
  81. -o acmetool \
  82. cmd/acmetool/main.go \
  83. cmd/acmetool/quickstart-nlinux.go \
  84. cmd/acmetool/quickstart.go \
  85. cmd/acmetool/le-import.go
  86. %install
  87. # create directory hierarchy
  88. %{l_shtool} mkdir -f -p -m 755 \
  89. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  90. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  91. $RPM_BUILD_ROOT%{l_prefix}/etc/sudo/sudoers.d \
  92. $RPM_BUILD_ROOT%{l_prefix}/etc/acmetool \
  93. $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d \
  94. $RPM_BUILD_ROOT%{l_prefix}/etc/nginx/nginx.d \
  95. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/hook \
  96. $RPM_BUILD_ROOT%{l_prefix}/var/acmetool/root \
  97. $RPM_BUILD_ROOT%{l_prefix}/var/acmetool/state
  98. # install program
  99. %{l_shtool} install -c -s -m 755 \
  100. src/github.com/hlandau/acme/acmetool \
  101. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/
  102. # install setuid wrapper script
  103. %{l_shtool} install -c -m 755 \
  104. acmetool $RPM_BUILD_ROOT%{l_prefix}/sbin/
  105. # install hook script
  106. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  107. %{SOURCE acmetool-hook.sh} \
  108. $RPM_BUILD_ROOT%{l_prefix}/libexec/acmetool/hook/life-updated
  109. # install sudo(8) configuration
  110. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  111. %{SOURCE acmetool-sudoers.txt} \
  112. $RPM_BUILD_ROOT%{l_prefix}/etc/sudo/sudoers.d/acmetool
  113. # install responses file
  114. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  115. %{SOURCE acmetool-responses.yaml} \
  116. $RPM_BUILD_ROOT%{l_prefix}/etc/acmetool/responses.yaml
  117. # install Apache config
  118. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  119. %{SOURCE acmetool-apache.conf} \
  120. $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d/acmetool.conf
  121. # install NGINX config
  122. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  123. %{SOURCE acmetool-nginx.conf} \
  124. $RPM_BUILD_ROOT%{l_prefix}/etc/nginx/nginx.d/acmetool.conf
  125. # install run-command script
  126. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  127. %{SOURCE rc.acmetool} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  128. # determine installation files
  129. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  130. %{l_files_std} \
  131. '%config %{l_prefix}/etc/acmetool/*' \
  132. '%attr(0600,%{l_susr},%{l_sgrp}) %{l_prefix}/etc/sudo/sudoers.d/acmetool' \
  133. '%not %dir %{l_prefix}/etc/sudo/sudoers.d' \
  134. '%not %dir %{l_prefix}/etc/sudo' \
  135. '%attr(4755,%{l_rusr},%{l_rgrp}) %{l_prefix}/sbin/acmetool' \
  136. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/acmetool/*'
  137. %files -f files
  138. %clean
  139. %post
  140. if [ $1 -eq 1 ]; then
  141. # after install, show hint
  142. ( echo "First configure the ACMETool response file:"
  143. echo " \$ vi $RPM_INSTALL_PREFIX/etc/acmetool/responses.yaml"
  144. echo "Edit especially the acme-enter-email and acmetool-quickstart-choose-server"
  145. echo "variables. The following directory servers are known:"
  146. echo " https://acme-staging.api.letsencrypt.org/directory (Test, RSA or ECDSA)"
  147. echo " https://acme-v01.api.letsencrypt.org/directory (Live, RSA only)"
  148. echo "Then perform the initial setup with it:"
  149. echo " \$ $RPM_INSTALL_PREFIX/sbin/acmetool quickstart --batch"
  150. echo "Then you can request your certificate:"
  151. echo " \$ $RPM_INSTALL_PREFIX/sbin/acmetool want example.com"
  152. echo "The resulting certificate/private-key you can find under:"
  153. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/cert"
  154. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/chain"
  155. echo " $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/privkey"
  156. echo "For Apache/mod_ssl use them with:"
  157. echo " SSLCertificateFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/cert"
  158. echo " SSLCertificateChainFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/chain"
  159. echo " SSLCertificateKeyFile $RPM_INSTALL_PREFIX/var/acmetool/state/live/example.com/privkey"
  160. ) | %{l_rpmtool} msg -b -t notice
  161. fi
  162. exit 0
  163. %preun
  164. # before erase, stop service and remove log files
  165. if [ $1 -eq 0 ]; then
  166. rm -rf $RPM_INSTALL_PREFIX/var/acmetool/root/* >/dev/null 2>&1 || true
  167. rm -rf $RPM_INSTALL_PREFIX/var/acmetool/state/* >/dev/null 2>&1 || true
  168. fi
  169. exit 0