cygwin.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. #
  3. # This script configures, builds and packs the binary package for
  4. # the Cygwin net distribution version of OpenSSL
  5. #
  6. # Uncomment when debugging
  7. #set -x
  8. CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
  9. INSTALL_PREFIX=/tmp/install
  10. VERSION=
  11. SUBVERSION=$1
  12. function cleanup()
  13. {
  14. rm -rf ${INSTALL_PREFIX}/etc
  15. rm -rf ${INSTALL_PREFIX}/usr
  16. }
  17. function get_openssl_version()
  18. {
  19. eval `grep '^VERSION=' Makefile`
  20. if [ -z "${VERSION}" ]
  21. then
  22. echo "Error: Couldn't retrieve OpenSSL version from Makefile."
  23. echo " Check value of variable VERSION in Makefile."
  24. exit 1
  25. fi
  26. }
  27. function base_install()
  28. {
  29. mkdir -p ${INSTALL_PREFIX}
  30. cleanup
  31. make install INSTALL_PREFIX="${INSTALL_PREFIX}"
  32. }
  33. function doc_install()
  34. {
  35. DOC_DIR=${INSTALL_PREFIX}/usr/share/doc/openssl
  36. mkdir -p ${DOC_DIR}
  37. cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}
  38. create_cygwin_readme
  39. }
  40. function certs_install()
  41. {
  42. CERTS_DIR=${INSTALL_PREFIX}/usr/ssl/certs
  43. mkdir -p ${CERTS_DIR}
  44. cp -rp certs/* ${CERTS_DIR}
  45. }
  46. function create_cygwin_readme()
  47. {
  48. README_DIR=${INSTALL_PREFIX}/usr/share/doc/Cygwin
  49. README_FILE=${README_DIR}/openssl-${VERSION}.README
  50. mkdir -p ${README_DIR}
  51. cat > ${README_FILE} <<- EOF
  52. The Cygwin version has been built using the following configure:
  53. ./config ${CONFIG_OPTIONS}
  54. The IDEA and RC5 algorithms are disabled due to patent and/or
  55. licensing issues.
  56. EOF
  57. }
  58. function create_profile_files()
  59. {
  60. PROFILE_DIR=${INSTALL_PREFIX}/etc/profile.d
  61. mkdir -p $PROFILE_DIR
  62. cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
  63. export MANPATH="${MANPATH}:/usr/ssl/man"
  64. EOF
  65. cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
  66. if ( $?MANPATH ) then
  67. setenv MANPATH "${MANPATH}:/usr/ssl/man"
  68. else
  69. setenv MANPATH ":/usr/ssl/man"
  70. endif
  71. EOF
  72. }
  73. if [ -z "${SUBVERSION}" ]
  74. then
  75. echo "Usage: $0 subversion"
  76. exit 1
  77. fi
  78. if [ ! -f config ]
  79. then
  80. echo "You must start this script in the OpenSSL toplevel source dir."
  81. exit 1
  82. fi
  83. ./config ${CONFIG_OPTIONS}
  84. get_openssl_version
  85. make depend || exit 1
  86. make || exit 1
  87. base_install
  88. doc_install
  89. certs_install
  90. create_cygwin_readme
  91. create_profile_files
  92. cd ${INSTALL_PREFIX}
  93. chmod u+w usr/lib/engines/*.so
  94. strip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
  95. chmod u-w usr/lib/engines/*.so
  96. # Runtime package
  97. find etc usr/bin usr/lib/engines usr/share/doc usr/ssl/certs \
  98. usr/ssl/man/man[157] usr/ssl/misc usr/ssl/openssl.cnf usr/ssl/private \
  99. -empty -o \! -type d |
  100. tar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
  101. # Development package
  102. find usr/include usr/lib/*.a usr/lib/pkgconfig usr/ssl/man/man3 \
  103. -empty -o \! -type d |
  104. tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
  105. ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
  106. ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
  107. cleanup
  108. exit 0