summaryrefslogtreecommitdiffstats
path: root/util/cygwin.sh
blob: 4f7fac9e37ed0296b0b346980a0a7d0f4d7dfc5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
#
# This script configures, builds and packs the binary package for
# the Cygwin net distribution version of OpenSSL
#

# Uncomment when debugging
#set -x

CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
DESTDIR=/tmp/install/INSTALL

VERSION=
SHLIB_VERSION_NUMBER=
SUBVERSION=$1

function cleanup()
{
  rm -rf ${DESTDIR}/etc
  rm -rf ${DESTDIR}/usr
}

function get_openssl_version()
{
  eval `grep '^VERSION=' Makefile`
  if [ -z "${VERSION}" ]
  then
    echo "Error: Couldn't retrieve OpenSSL version from Makefile."
    echo "       Check value of variable VERSION in Makefile."
    exit 1
  fi
  eval `grep '^SHLIB_VERSION_NUMBER=' Makefile`
  if [ -z "${SHLIB_VERSION_NUMBER}" ]
  then
    echo "Error: Couldn't retrieve OpenSSL shared lib version from Makefile."
    echo " Check value of variable SHLIB_VERSION_NUMBER in Makefile."
    exit 1
  fi
}

function base_install()
{
  mkdir -p ${DESTDIR}
  cleanup
  make install DESTDIR="${DESTDIR}"
}

function doc_install()
{
  DOC_DIR=${DESTDIR}/usr/share/doc/openssl

  mkdir -p ${DOC_DIR}
  cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}

  create_cygwin_readme
}

function certs_install()
{
  CERTS_DIR=${DESTDIR}/usr/ssl/certs

  mkdir -p ${CERTS_DIR}
  cp -rp certs/* ${CERTS_DIR}
}

function create_cygwin_readme()
{
  README_DIR=${DESTDIR}/usr/share/doc/Cygwin
  README_FILE=${README_DIR}/openssl-${VERSION}.README

  mkdir -p ${README_DIR}
  cat > ${README_FILE} <<- EOF
	The Cygwin version has been built using the following configure:

	  ./config ${CONFIG_OPTIONS}

	The IDEA and RC5 algorithms are disabled due to patent and/or
	licensing issues.
	EOF
}

function create_profile_files()
{
  PROFILE_DIR=${DESTDIR}/etc/profile.d

  mkdir -p $PROFILE_DIR
  cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
	export MANPATH="${MANPATH}:/usr/ssl/man"
	EOF
  cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
	if ( $?MANPATH ) then
	  setenv MANPATH "${MANPATH}:/usr/ssl/man"
	else
	  setenv MANPATH ":/usr/ssl/man"
	endif
	EOF
}

if [ -z "${SUBVERSION}" ]
then
  echo "Usage: $0 subversion"
  exit 1
fi

if [ ! -f config ]
then
  echo "You must start this script in the OpenSSL toplevel source dir."
  exit 1
fi

./config ${CONFIG_OPTIONS}

get_openssl_version

make depend || exit 1

make || exit 1

base_install

doc_install

certs_install

create_cygwin_readme

create_profile_files

cd ${DESTDIR}
chmod u+w usr/lib/engines/*.so
strip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
chmod u-w usr/lib/engines/*.so

# Runtime package
tar cjf libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
     usr/bin/cyg*dll
# Base package
find etc usr/bin/openssl.exe usr/bin/c_rehash usr/lib/engines usr/share/doc \
     usr/ssl/certs usr/ssl/man/man[157] usr/ssl/misc usr/ssl/openssl.cnf \
     usr/ssl/private \
     -empty -o \! -type d |
tar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
# Development package
find usr/include usr/lib/*.a usr/lib/pkgconfig usr/ssl/man/man3 \
     -empty -o \! -type d |
tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -

ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
ls -l libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2

cleanup

exit 0