cfssl.spec 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ##
  2. ## cfssl.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2014 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 20140929
  25. %define V_dist 20140929
  26. # package information
  27. Name: cfssl
  28. Summary: CloudFlare PKI Toolkit
  29. URL: https://github.com/cloudflare/cfssl
  30. Vendor: CloudFlare
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Network
  35. License: MIT
  36. Version: %{V_opkg}
  37. Release: 20140929
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/cfssl/cfssl-%{V_dist}.tar.gz
  40. Source1: rc.cfssl
  41. Source2: ca.json
  42. Source3: cfssl-initca.sh
  43. Patch0: cfssl.patch
  44. # build information
  45. BuildPreReq: OpenPKG, openpkg >= 20120101, go
  46. PreReq: OpenPKG, openpkg >= 20120101
  47. %description
  48. CF-SSL is CloudFlare's SSL/TLS/X.509 swiss army knife. It is both a
  49. command line tool and an HTTP API server for signing, verifying, and
  50. bundling SSL/TLS X.509 certificates.
  51. %track
  52. prog cfssl = {
  53. version = %{version}
  54. url = http://download.openpkg.org/components/versioned/cfssl/
  55. regex = cfssl-(__VER__)\.tar\.gz
  56. }
  57. %prep
  58. %setup -q -n cfssl
  59. %patch -p0
  60. %build
  61. # patch paths
  62. %{l_shtool} subst \
  63. -e 's;/etc/cfssl/ca-bundle\.crt;%{l_prefix}/var/cfssl/dat/ca-bundle.crt;g' \
  64. -e 's;/etc/cfssl/ca-bundle.crt.metadata;%{l_prefix}/var/cfssl/dat/ca-bundle.crt.metadata;g' \
  65. -e 's;/etc/cfssl/int-bundle\.crt;%{l_prefix}/var/cfssl/dat/int-bundle.crt;g' \
  66. -e 's;/etc/cfssl/intermediates;%{l_prefix}/var/cfssl/dat/int.d;g' \
  67. cfssl.go
  68. # prepare Go build environment
  69. rm -rf gopath
  70. mkdir -p gopath/src/github.com/cloudflare
  71. ln -s ../../../.. gopath/src/github.com/cloudflare/cfssl
  72. export GOPATH=`pwd`/gopath
  73. # build program
  74. go build -x
  75. go build -x -o cfssl-mkbundle mkbundle/mkbundle.go
  76. go build -x -o cfssl-json cfssljson/cfssljson.go
  77. %install
  78. # create directory hierarchy
  79. %{l_shtool} mkdir -f -p -m 755 \
  80. $RPM_BUILD_ROOT%{l_prefix}/bin \
  81. $RPM_BUILD_ROOT%{l_prefix}/etc/cfssl \
  82. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  83. $RPM_BUILD_ROOT%{l_prefix}/var/cfssl/dat/int.d \
  84. $RPM_BUILD_ROOT%{l_prefix}/var/cfssl/run \
  85. $RPM_BUILD_ROOT%{l_prefix}/var/cfssl/log
  86. # install program
  87. %{l_shtool} install -c -s -m 755 \
  88. cfssl cfssl-mkbundle cfssl-json $RPM_BUILD_ROOT%{l_prefix}/bin/
  89. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  90. %{SOURCE cfssl-initca.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/cfssl-initca
  91. # install default configuration
  92. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  93. %{SOURCE ca.json} $RPM_BUILD_ROOT%{l_prefix}/etc/cfssl/
  94. # install run-command script
  95. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  96. %{SOURCE rc.cfssl} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  97. # determine installation files
  98. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  99. %{l_files_std} \
  100. '%config %{l_prefix}/etc/cfssl/*' \
  101. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cfssl/*' \
  102. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cfssl/*/*'
  103. %files -f files
  104. %clean
  105. %post
  106. # on initial installation, generate CA crt/key pair
  107. if [ $1 -eq 1 ]; then
  108. ( echo "Generating initial CA RSA key and X.509 certificate files."
  109. echo "You can change the CA parameters by editing the file..."
  110. echo " $RPM_INSTALL_PREFIX/etc/cfssl/ca.json"
  111. echo "...and then re-running the command:"
  112. echo " su - %{l_rusr} -c \"$RPM_INSTALL_PREFIX/bin/cfssl-initca\""
  113. ) | %{l_rpmtool} msg -b -t notice
  114. su - %{l_rusr} -c "$RPM_INSTALL_PREFIX/bin/cfssl-initca"
  115. fi
  116. # after upgrade, restart service
  117. [ $1 -eq 2 ] || exit 0
  118. eval `%{l_rc} cfssl status 2>/dev/null`
  119. [ ".$cfssl_active" = .yes ] && %{l_rc} cfssl restart
  120. exit 0
  121. %preun
  122. # before erase, stop service and remove log files
  123. [ $1 -eq 0 ] || exit 0
  124. %{l_rc} cfssl stop 2>/dev/null
  125. rm -rf $RPM_INSTALL_PREFIX/var/cfssl/log/* >/dev/null 2>&1 || true
  126. rm -rf $RPM_INSTALL_PREFIX/var/cfssl/run/* >/dev/null 2>&1 || true
  127. exit 0