openvpn.spec 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ##
  2. ## openvpn.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_dist 2.0.7
  26. %define V_opkg 2.0.7
  27. # package information
  28. Name: openvpn
  29. Summary: Virtual Private Network Facility
  30. URL: http://openvpn.sourceforge.net/
  31. Vendor: James Yonan
  32. Packager: OpenPKG
  33. Distribution: OpenPKG
  34. Class: PLUS
  35. Group: Network
  36. License: GPL
  37. Version: %{V_opkg}
  38. Release: 20060412
  39. # package options
  40. %option with_fsl yes
  41. # list of sources
  42. Source0: http://openvpn.net/release/openvpn-%{V_dist}.tar.gz
  43. Source1: rc.openvpn
  44. Source2: fsl.openvpn
  45. Source3: openvpn.conf
  46. Patch0: openvpn.patch
  47. # build information
  48. Prefix: %{l_prefix}
  49. BuildRoot: %{l_buildroot}
  50. BuildPreReq: OpenPKG, openpkg >= 20040130
  51. PreReq: OpenPKG, openpkg >= 20040130, perl
  52. BuildPreReq: openssl, lzo >= 1.08
  53. PreReq: openssl, lzo >= 1.08
  54. %if "%{with_fsl}" == "yes"
  55. BuildPreReq: fsl >= 1.3.0
  56. PreReq: fsl >= 1.3.0
  57. %endif
  58. AutoReq: no
  59. AutoReqProv: no
  60. %description
  61. OpenVPN is a robust and highly configurable VPN (Virtual Private
  62. Network) daemon which can be used to securely link two or more
  63. private networks using an encrypted tunnel over the internet.
  64. %track
  65. prog openvpn = {
  66. version = %{V_dist}
  67. url = http://openvpn.net/release/
  68. regex = openvpn-(\d+\.\d+(\.\d+)*)\.tar\.gz
  69. }
  70. %prep
  71. %setup -q -n openvpn-%{V_dist}
  72. %patch -p0
  73. %build
  74. # configure program
  75. CC="%{l_cc}" \
  76. CFLAGS="%{l_cflags -O}" \
  77. CPPFLAGS="%{l_cppflags lzo openssl}" \
  78. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
  79. LIBS="%{l_fsl_libs}" \
  80. ./configure \
  81. --prefix=%{l_prefix} \
  82. --with-ssl-headers=%{l_prefix}/include/openssl \
  83. --with-ssl-lib=%{l_prefix}/lib \
  84. --with-lzo-headers=%{l_prefix}/include/lzo \
  85. --with-lzo-lib=%{l_prefix}/lib
  86. # build program
  87. %{l_make} %{l_mflags -O}
  88. %install
  89. # install program
  90. rm -rf $RPM_BUILD_ROOT
  91. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  92. # strip down installation files
  93. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  94. # install additional files
  95. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  96. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
  97. sample-scripts/verify-cn $RPM_BUILD_ROOT%{l_prefix}/sbin/openvpn-verify-cn
  98. %{l_shtool} mkdir -f -p -m 755 \
  99. $RPM_BUILD_ROOT%{l_prefix}/man/cat8
  100. %{l_shtool} install -c -m 644 \
  101. management/management-notes.txt $RPM_BUILD_ROOT%{l_prefix}/man/cat8/openvpn-management.8
  102. # install run-command script
  103. %{l_shtool} mkdir -f -p -m 755 \
  104. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  105. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  106. %{SOURCE rc.openvpn} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  107. # install default config file
  108. %{l_shtool} mkdir -f -p -m 755 \
  109. $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn
  110. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  111. %{SOURCE openvpn.conf} \
  112. $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn/
  113. # install OSSP fsl configuration
  114. %{l_shtool} mkdir -f -p -m 755 \
  115. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  116. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  117. %{SOURCE fsl.openvpn} \
  118. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  119. # create run-time directory
  120. %{l_shtool} mkdir -f -p -m 755 \
  121. $RPM_BUILD_ROOT%{l_prefix}/var/openvpn
  122. # determine installation files
  123. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  124. %{l_files_std} \
  125. '%not %dir %{l_prefix}/etc/fsl' \
  126. '%config %{l_prefix}/etc/fsl/fsl.openvpn' \
  127. '%config %{l_prefix}/etc/openvpn/openvpn.conf'
  128. %files -f files
  129. %clean
  130. rm -rf $RPM_BUILD_ROOT
  131. %post
  132. # on initial install, create a sample shared key
  133. if [ $1 -eq 1 ]; then
  134. if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh ]; then
  135. $RPM_INSTALL_PREFIX/bin/openssl dhparam \
  136. -out $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh 1024
  137. fi
  138. if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key ]; then
  139. $RPM_INSTALL_PREFIX/sbin/openvpn \
  140. --genkey --secret $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key
  141. fi
  142. fi
  143. # after upgrade, restart service
  144. [ $1 -eq 2 ] || exit 0
  145. eval `%{l_rc} openvpn status 2>/dev/null`
  146. [ ".$openvpn_active" = .yes ] && %{l_rc} openvpn restart
  147. exit 0
  148. %preun
  149. # before erase, stop service and remove log files
  150. [ $1 -eq 0 ] || exit 0
  151. %{l_rc} openvpn stop 2>/dev/null
  152. rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.log* >/dev/null 2>&1 || true
  153. rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.status >/dev/null 2>&1 || true
  154. exit 0