11#! /usr/bin/env bash
2- set -e
32
43extension=$1
54repo=$2
@@ -37,6 +36,7 @@ get_latest_git_tag() {
3736 if [ -z " $latest_tag " ]; then
3837 repo_owner=" ${repo_slug%%/* } "
3938 repo_name=" ${repo_slug##*/ } "
39+ # shellcheck disable=SC2016
4040 graph_query=' query($owner:String!,$name:String!){repository(owner:$owner,name:$name){refs(refPrefix:"refs/tags/",first:1,orderBy:{field:TAG_COMMIT_DATE,direction:DESC}){nodes{name}}}}'
4141 latest_tag=$( gh api graphql -f owner=" $repo_owner " -f name=" $repo_name " -f query=" $graph_query " --jq ' .data.repository.refs.nodes[0].name' 2> /dev/null || true)
4242 fi
@@ -82,7 +82,7 @@ download_latest_pecl_archive() {
8282}
8383
8484if [[ " $repo " != " pecl" && " $tag " = " latest" ]]; then
85- tag=" $( get_latest_git_tag " $repo " ) "
85+ tag=" $( get_latest_git_tag " $repo " ) " || exit 1
8686fi
8787
8888# Clean stale sources from previous local builds of the same extension.
@@ -92,34 +92,35 @@ rm -rf /tmp/"$extension"-* /tmp/"$pecl_package"-* /tmp/"$extension".tar.gz "$ext
9292if [ " $repo " = " pecl" ]; then
9393 " $PHP_INSTALL_ROOT " /usr/bin/pecl channel-update pecl.php.net || true
9494 if [ -n " ${tag// } " ]; then
95- " $PHP_INSTALL_ROOT " /usr/bin/pecl download " $pecl_package -$tag " || compgen -G " $pecl_package *.tgz" > /dev/null
95+ " $PHP_INSTALL_ROOT " /usr/bin/pecl download " $pecl_package -$tag " || compgen -G " $pecl_package *.tgz" > /dev/null || exit 1
9696 else
97- " $PHP_INSTALL_ROOT " /usr/bin/pecl download " $pecl_package " || compgen -G " $pecl_package *.tgz" > /dev/null || download_latest_pecl_archive
97+ " $PHP_INSTALL_ROOT " /usr/bin/pecl download " $pecl_package " || compgen -G " $pecl_package *.tgz" > /dev/null || download_latest_pecl_archive || exit 1
9898 fi
99- mv " $pecl_package " * .tgz /tmp/" $extension " .tar.gz
99+ mv " $pecl_package " * .tgz /tmp/" $extension " .tar.gz || exit 1
100100else
101- download_git_archive
101+ download_git_archive || exit 1
102102fi
103103
104104# Extract it to /tmp and build the extension in INSTALL_ROOT
105- tar xf " /tmp/$extension .tar.gz" -C /tmp
105+ tar xf " /tmp/$extension .tar.gz" -C /tmp || exit 1
106106(
107107 if [ " $repo " = " pecl" ]; then
108108 cd /tmp/" $pecl_package " -* || exit 1
109109 else
110110 tag=${tag# v}
111111 cd /tmp/" $( basename " $repo " ) " -" ${tag/ \/ / -} " || exit 1
112112 fi
113- export SED=$( command -v sed)
113+ SED=$( command -v sed) || exit 1
114+ export SED
114115 configure_legacy_extension_flags
115116 if declare -f " patch_${extension} " > /dev/null; then
116117 " patch_${extension} "
117118 fi
118- phpize
119- ./configure " --with-php-config=/usr/bin/php-config" " ${params[@]} "
120- make -j" $( nproc) "
121- make install
119+ phpize || exit 1
120+ ./configure " --with-php-config=/usr/bin/php-config" " ${params[@]} " || exit 1
121+ make -j" $( nproc) " || exit 1
122+ make install || exit 1
122123 # shellcheck disable=SC2097
123124 # shellcheck disable=SC2098
124- INSTALL_ROOT=" $INSTALL_ROOT " make install DESTDIR=" $INSTALL_ROOT "
125- )
125+ INSTALL_ROOT=" $INSTALL_ROOT " make install DESTDIR=" $INSTALL_ROOT " || exit 1
126+ ) || exit 1
0 commit comments