summaryrefslogtreecommitdiffstats
path: root/dev-lang/php/files/eblits/src_install-v3.eblit
blob: 4c3ba241b9ec1b24b3f1fbb88bbdae85df2b26b5 (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
155
156
157
158
159
160
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/files/eblits/src_install-v3.eblit,v 1.5 2011/11/08 18:14:08 olemarkus Exp $

eblit-php-src_install() {
	# see bug #324739 for what happens when we don't have that
	addpredict /usr/share/snmp/mibs/.index

	# grab the first SAPI that got built and install common files from there
	local first_sapi=""
	for sapi in $SAPIS ; do
		if use $sapi ; then
			first_sapi=$sapi
			break
		fi
	done

	# Makefile forgets to create this before trying to write to it...
	dodir "${PHP_DESTDIR}/bin"

	# Install php environment (without any sapis)
	cd "${WORKDIR}/sapis-build/$first_sapi"
	emake INSTALL_ROOT="${D}" \
		install-build install-headers install-programs \
		|| die "emake install failed"

	local extension_dir="$("${D}/${PHP_DESTDIR}/bin/php-config" --extension-dir)"

	# Create the directory where we'll put version-specific php scripts
	keepdir /usr/share/php${PHP_MV}

	local sapi="", file=""
	local sapi_list=""

	for sapi in ${SAPIS}; do
		if use "${sapi}" ; then
			einfo "Installing SAPI: ${sapi}"
			cd "${WORKDIR}/sapis-build/${sapi}"

			if [[ "${sapi}" == "apache2" ]] ; then
				# We're specifically not using emake install-sapi as libtool
				# may cause unnecessary relink failures (see bug #351266)
				insinto "${PHP_DESTDIR}/apache2/"
				newins ".libs/libphp5.so" "libphp${PHP_MV}.so"
				keepdir "/usr/$(get_libdir)/apache2/modules"
			else
				# needed each time, php_install_ini would reset it
				into "${PHP_DESTDIR}"
			    case "$sapi" in
					cli)
						source="sapi/cli/php"
						;;
					cgi)
						source="sapi/cgi/php-cgi"
						;;
					fpm)
						source="sapi/fpm/php-fpm"
						;;
					embed)
						source="libs/libphp${PHP_MV}.so"
						;;
					*)
						die "unhandled sapi in src_install"
						;;
				esac

				if [[ "${source: -3}" == ".so" ]]; then 
					dolib.so "${source}" || die "Unable to install ${sapi} sapi"
				else
					dobin "${source}" || die "Unable to install ${sapi} sapi"
				fi
			fi

			php_install_ini "${sapi}"

			# construct correct SAPI string for php-config
			# thanks to ferringb for the bash voodoo
			if [[ "${sapi}" == "apache2" ]]; then
				sapi_list="${sapi_list:+${sapi_list} }apache2handler"
			else
				sapi_list="${sapi_list:+${sapi_list} }${sapi}"
			fi
		fi
	done

	# Install env.d files
	newenvd "${FILESDIR}/20php5-envd" \
		"20php${SLOT}"
	sed -e "s|/lib/|/$(get_libdir)/|g" -i \
		"${D}/etc/env.d/20php${SLOT}"
	sed -e "s|php5|php${SLOT}|g" -i \
		"${D}/etc/env.d/20php${SLOT}"

	# set php-config variable correctly (bug #278439)
	sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
		"${D}/usr/$(get_libdir)/php${SLOT}/bin/php-config"
}

php_install_ini() {
	local phpsapi="${1}"

	# work out where we are installing the ini file
	php_set_ini_dir "${phpsapi}"

	local phpinisrc="${PHP_INI_UPSTREAM}-${phpsapi}"
	cp "${PHP_INI_UPSTREAM}" "${phpinisrc}"

	# default to /tmp for save_path, bug #282768
	sed -e 's|^;session.save_path .*$|session.save_path = "/tmp"|g' -i "${phpinisrc}"

	# Set the extension dir
	sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" -i "${phpinisrc}"

	# Set the include path to point to where we want to find PEAR packages
	sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:/usr/share/php'${PHP_MV}':/usr/share/php"|' -i "${phpinisrc}"

	dodir "${PHP_INI_DIR}"
	insinto "${PHP_INI_DIR}"
	newins "${phpinisrc}" "${PHP_INI_FILE}"

	elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR}"
	elog

	dodir "${PHP_EXT_INI_DIR}"
	dodir "${PHP_EXT_INI_DIR_ACTIVE}"

	# SAPI-specific handling
	if [[ "${sapi}" == "apache2" ]] ; then
			insinto "${APACHE_MODULES_CONFDIR}"
			newins "${FILESDIR}/70_mod_php${PHP_MV}.conf-apache2" \
				"70_mod_php${PHP_MV}.conf"
	fi

	if [[ "${sapi}" == "fpm" ]] ; then
        [[ -z ${PHP_FPM_INIT_VER} ]] && PHP_FPM_INIT_VER=3
        [[ -z ${PHP_FPM_CONF_VER} ]] && PHP_FPM_CONF_VER=0
		einfo "Installing FPM CGI config file php-fpm.conf"
		insinto ${PHP_INI_DIR}
		newins "${FILESDIR}/php-fpm-r${PHP_FPM_CONF_VER}.conf" php-fpm.conf
		dodir "/etc/init.d"
		insinto "/etc/init.d"
		newinitd "${FILESDIR}/php-fpm-r${PHP_FPM_INIT_VER}.init" "php-fpm"
		#dosym "${PHP_DESTDIR}/bin/php-fpm" "/usr/bin/php-fpm"
		
		# Remove bogus /etc/php-fpm.conf.default (bug 359906)
		[[ -f "${D}/etc/php-fpm.conf.default" ]] && rm "${D}/etc/php-fpm.conf.default"
	fi

  # Install PHP ini files into /usr/share/php
	if [[ ${SLOT} == '5.2' ]]; then
		newdoc php.ini-dist php.ini-development
		newdoc php.ini-recommended php.ini-production
	fi

	if [[ ${SLOT} == '5.3' ]]; then
		dodoc php.ini-development
		dodoc php.ini-production
	fi

}