From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id F26EA1388C1 for ; Sun, 20 Dec 2015 00:17:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6CEC221C001; Sun, 20 Dec 2015 00:17:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C176121C003 for ; Sun, 20 Dec 2015 00:17:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7AF81340775 for ; Sun, 20 Dec 2015 00:17:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5650CCB2 for ; Sun, 20 Dec 2015 00:17:38 +0000 (UTC) From: "Michael Orlitzky" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Orlitzky" Message-ID: <1450564841.7d9d9e7ef2a642c2f568de59b1af5f20a0c828ab.mjo@gentoo> Subject: [gentoo-commits] proj/eselect-php:master commit in: src/ X-VCS-Repository: proj/eselect-php X-VCS-Files: src/php.eselect.in X-VCS-Directories: src/ X-VCS-Committer: mjo X-VCS-Committer-Name: Michael Orlitzky X-VCS-Revision: 7d9d9e7ef2a642c2f568de59b1af5f20a0c828ab X-VCS-Branch: master Date: Sun, 20 Dec 2015 00:17:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: db0c6170-7b33-4e4b-ac77-49e73e8c7198 X-Archives-Hash: 3cc8813b68316091ed4879a3428f0e0f commit: 7d9d9e7ef2a642c2f568de59b1af5f20a0c828ab Author: Michael Orlitzky gentoo org> AuthorDate: Sat Dec 19 22:40:41 2015 +0000 Commit: Michael Orlitzky gentoo org> CommitDate: Sat Dec 19 22:40:41 2015 +0000 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=7d9d9e7e Factor out the target major version number parsing into a function. src/php.eselect.in | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/php.eselect.in b/src/php.eselect.in index 4af8650..0eb4ae4 100644 --- a/src/php.eselect.in +++ b/src/php.eselect.in @@ -40,6 +40,28 @@ sapi_active_bin_link_path() { esac } + +# Parse and return the major version from a target name. For example, +# the "php5.6" target has a major version of "5". +# +# INPUT: +# +# The name of a valid PHP target, like php5.6 or php7.0. +# +# OUTPUT: +# +# A major version number. An error is raised if the given target is +# not valid. +# +parse_target_major_version() { + local target="${1}" + local major="${target:3:1}" + case "${major}" in + 5|7) echo "${major}" ;; + *) die "invalid PHP target name: ${target}" + esac +} + cleanup_sapis() { local m local link @@ -273,9 +295,7 @@ write_mod_php_conf() { @MKDIR_P@ "${conf_dir}" || die "failed to create ${conf_dir}" - # Parse the major version (for example "5" or "7") out of the - # target name. - local major="${target:3:1}" + local major=$(parse_target_major_version "${target}") cat <<-EOF > "${conf_path}" || die "failed to write mod_php.conf" LoadModule php${major}_module modules/mod_php.so @@ -367,15 +387,17 @@ list_phpdbg() { } set_apache2() { - local active_symlink libdir target=$(resolv_target apache2 $1) + local active_symlink libdir major target=$(resolv_target apache2 $1) active_symlink="$(get_apache2_active_symlink_path)" + major=$(parse_target_major_version "${target}") [[ -z $target ]] && die -q "invalid target" + for libdir in $(get_libdirs); do rm --force "${active_symlink}" || \ die "failed to remove active module symlink" - @LN_S@ --force "../../${target}/apache2/libphp${target:3:1}.so" \ + @LN_S@ --force "../../${target}/apache2/libphp${major}.so" \ "${active_symlink}" || \ die -q "failed to create active mod_php symlink" done