diff --git a/build-release-example.sh b/build-release-example.sh index 870c2d1040..c42bd75e88 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -1,5 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash __DIR__=$( cd "$(dirname "$0")" @@ -7,14 +6,14 @@ __DIR__=$( ) __PROJECT__=${__DIR__} -if [ ! -f ${__DIR__}/prepare.php ] ; then +if [ ! -f ${__DIR__}/prepare.php ]; then echo 'no found prepare.php' exit 0 fi cd ${__PROJECT__} -if [ ! -d ext/swoole/.git ] ; then +if [ ! -d ext/swoole/.git ]; then git submodule update --init --recursive fi @@ -38,7 +37,6 @@ case $OS in esac - IN_DOCKER=0 WITH_PHP_COMPOSER=1 @@ -75,12 +73,12 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done -if [ "$OS" = 'linux' ] ; then - if [ ! "$BASH_VERSION" ] ; then - echo "Please use bash to run this script ($0) " 1>&2 - echo "fix : " 1>&2 - echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-minimal.sh " 1>&2 - exit 1 +if [ "$OS" = 'linux' ]; then + if [ ! "$BASH_VERSION" ]; then + echo "Please use bash to run this script ($0) " 1>&2 + echo "fix : " 1>&2 + echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-minimal.sh " 1>&2 + exit 1 fi fi @@ -89,48 +87,48 @@ CMDS_NUMS=0 CMDS=("flex" "pkg-config" "cmake" "re2c" "bison" "curl" "automake" "libtool" "clang" "xz" "zip" "unzip" "autoconf") CMDS_LEN=${#CMDS[@]} for cmd in "${CMDS[@]}"; do - if command -v "$cmd" >/dev/null 2>&1; then - # echo "$cmd exists" - ((CMDS_NUMS++)) - fi + if command -v "$cmd" >/dev/null 2>&1; then + # echo "$cmd exists" + ((CMDS_NUMS++)) + fi done -if [ "$OS" = 'linux' ] ; then - if [ -f /.dockerenv ]; then - IN_DOCKER=1 - if test $CMDS_LEN -ne $CMDS_NUMS ;then - { - if [ "$MIRROR" = 'china' ] ; then - sh sapi/quickstart/linux/alpine-init.sh --mirror china - else - sh sapi/quickstart/linux/alpine-init.sh - fi - } +if [ "$OS" = 'linux' ]; then + if [ -f /.dockerenv ]; then + IN_DOCKER=1 + if test $CMDS_LEN -ne $CMDS_NUMS; then + { + if [ "$MIRROR" = 'china' ]; then + sh sapi/quickstart/linux/alpine-init.sh --mirror china + else + sh sapi/quickstart/linux/alpine-init.sh fi - git config --global --add safe.directory ${__PROJECT__} + } + fi + git config --global --add safe.directory ${__PROJECT__} + else + # docker inspect -f {{.State.Running}} download-box-web-server + if [ "$(docker inspect -f {{.State.Running}} swoole-cli-builder)" = "true" ]; then + echo " build container is running " else - # docker inspect -f {{.State.Running}} download-box-web-server - if [ "`docker inspect -f {{.State.Running}} swoole-cli-builder`" = "true" ]; then - echo " build container is running " - else - echo " build container no running " - fi + echo " build container no running " fi + fi fi -if [ "$OS" = 'macos' ] ; then - if test $CMDS_LEN -ne $CMDS_NUMS ; then - { - if [ "$MIRROR" = 'china' ] ; then - bash sapi/quickstart/macos/macos-init.sh --mirror china - else - bash sapi/quickstart/macos/macos-init.sh - fi - } +if [ "$OS" = 'macos' ]; then + if test $CMDS_LEN -ne $CMDS_NUMS; then + { + if [ "$MIRROR" = 'china' ]; then + bash sapi/quickstart/macos/macos-init.sh --mirror china + else + bash sapi/quickstart/macos/macos-init.sh + fi + } fi OWNER=$(stat -f "%Su" "${LIBRARY_INSTALL_PREFIX}") CURRENT_USER=$(whoami) - if test "${OWNER}" != "${CURRENT_USER}" ; then + if test "${OWNER}" != "${CURRENT_USER}"; then id -u ${CURRENT_USER} echo "创建目录: ${LIBRARY_INSTALL_PREFIX} ,并修改所属者为: ${CURRENT_USER} " sudo mkdir -p ${LIBRARY_INSTALL_PREFIX} @@ -139,13 +137,12 @@ if [ "$OS" = 'macos' ] ; then fi - -if [ ! -f "${__PROJECT__}/bin/runtime/php" ] ;then - if [ "$MIRROR" = 'china' ] ; then - bash sapi/quickstart/setup-php-runtime.sh --mirror china - else - bash sapi/quickstart/setup-php-runtime.sh - fi +if [ ! -f "${__PROJECT__}/bin/runtime/php" ]; then + if [ "$MIRROR" = 'china' ]; then + bash sapi/quickstart/setup-php-runtime.sh --mirror china + else + bash sapi/quickstart/setup-php-runtime.sh + fi fi export PATH="${__PROJECT__}/bin/runtime:$PATH" @@ -153,27 +150,24 @@ alias php="php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.c php -v +if [ ${WITH_PHP_COMPOSER} -eq 1 ]; then + export COMPOSER_ALLOW_SUPERUSER=1 + if [ "$MIRROR" = 'china' ]; then + composer config -g repos.packagist composer https://mirrors.tencent.com/composer/ + # composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + else + composer config -g repos.packagist composer https://packagist.org + fi + # composer suggests --all + # composer dump-autoload + # composer update --optimize-autoloader + composer install --no-interaction --no-autoloader --no-scripts --prefer-dist -vv --profile # --no-dev + composer dump-autoload --optimize --profile -if [ ${WITH_PHP_COMPOSER} -eq 1 ] ; then - export COMPOSER_ALLOW_SUPERUSER=1 - if [ "$MIRROR" = 'china' ]; then - composer config -g repos.packagist composer https://mirrors.tencent.com/composer/ - # composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ - else - composer config -g repos.packagist composer https://packagist.org - fi - # composer suggests --all - # composer dump-autoload - - # composer update --optimize-autoloader - composer install --no-interaction --no-autoloader --no-scripts --prefer-dist -vv --profile # --no-dev - composer dump-autoload --optimize --profile - - composer config -g --unset repos.packagist + composer config -g --unset repos.packagist fi - # 可用配置参数 # --with-swoole-pgsql=1 # --with-global-prefix=/usr/local/swoole-cli @@ -186,33 +180,31 @@ fi # --with-parallel-jobs=8 # --with-download-mirror-url=https://swoole-cli.jingjingxyk.com/ - # 定制构建选项 OPTIONS="${OPTIONS} +apcu +ds +xlswriter +ssh2 +uuid " OPTIONS="${OPTIONS} --with-swoole-pgsql=1" OPTIONS="${OPTIONS} --with-global-prefix=${LIBRARY_INSTALL_PREFIX}" # OPTIONS="${OPTIONS} @macos" +if [ ${IN_DOCKER} -eq 1 ]; then + { + # 容器中 -if [ ${IN_DOCKER} -eq 1 ] ; then -{ -# 容器中 - - php prepare.php +inotify ${OPTIONS} - -} else { -# 容器外 + php prepare.php +inotify ${OPTIONS} + } +else + { + # 容器外 - php prepare.php --without-docker=1 ${OPTIONS} + php prepare.php --without-docker=1 ${OPTIONS} -} + } fi - -if [ "$OS" = 'linux' ] && [ ${IN_DOCKER} -eq 0 ] ; then - echo ' please run in container !' - exit 0 +if [ "$OS" = 'linux' ] && [ ${IN_DOCKER} -eq 0 ]; then + echo ' please run in container !' + exit 0 fi bash make.sh all-library @@ -224,9 +216,3 @@ bash make.sh build bash make.sh archive exit 0 - - - - - - diff --git a/sapi/download-box/download-box-batch-downloader.sh b/sapi/download-box/download-box-batch-downloader.sh index 09faa077fd..f47f9694ba 100644 --- a/sapi/download-box/download-box-batch-downloader.sh +++ b/sapi/download-box/download-box-batch-downloader.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -33,8 +33,6 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - - DOWNLOAD_BOX_DIR=${__PROJECT__}/var/download-box/ mkdir -p ${__PROJECT__}/var/download-box/ @@ -42,8 +40,7 @@ cd ${__PROJECT__}/var/download-box/ mkdir -p lib mkdir -p ext - -if [ -f download_library_urls.txt ] && [ -f download_extension_urls.txt ] ; then +if [ -f download_library_urls.txt ] && [ -f download_extension_urls.txt ]; then echo 'downloading source code tarball ' else echo 'please run script : ' @@ -54,10 +51,3 @@ fi cd ${__PROJECT__} sh sapi/download-box/download-dependencies-use-aria2.sh - - - - - - - diff --git a/sapi/download-box/download-box-build.sh b/sapi/download-box/download-box-build.sh index fd885e93f8..3e91fa179b 100644 --- a/sapi/download-box/download-box-build.sh +++ b/sapi/download-box/download-box-build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -24,10 +24,8 @@ cp -f ${__PROJECT__}/bin/LICENSE . cp -f ${__PROJECT__}/bin/credits.html . cp -f ${__PROJECT__}/bin/ext-dependency-graph.pdf . - cd "${DOWNLOAD_BOX_DIR}" - test -f all-deps.zip && rm -rf all-deps.zip test -d ext && test -d lib && zip -9 -r all-deps.zip ext lib @@ -41,5 +39,5 @@ IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" docker build -t ${IMAGE} -f ./Dockerfile-dowload-box . --progress=plain -echo ${IMAGE} > download-box.txt +echo ${IMAGE} >download-box.txt docker push ${IMAGE} diff --git a/sapi/download-box/download-box-get-archive-from-container.sh b/sapi/download-box/download-box-get-archive-from-container.sh index f3a57f3a2f..dbafe43b49 100644 --- a/sapi/download-box/download-box-get-archive-from-container.sh +++ b/sapi/download-box/download-box-get-archive-from-container.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -15,14 +15,12 @@ test -d ${__PROJECT__}/var/download-box/ || mkdir -p ${__PROJECT__}/var/download cd ${__PROJECT__}/var/download-box/ - TAG='download-box-nginx-alpine-1.8-20231113T173944Z' IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" cd ${__PROJECT__}/var/download-box/ - container_id=$(docker create $IMAGE) # returns container ID docker cp $container_id:/usr/share/nginx/html/ext ext docker cp $container_id:/usr/share/nginx/html/lib lib diff --git a/sapi/download-box/download-box-get-archive-from-server.sh b/sapi/download-box/download-box-get-archive-from-server.sh index 98cb2d3769..fadbd0a624 100644 --- a/sapi/download-box/download-box-get-archive-from-server.sh +++ b/sapi/download-box/download-box-get-archive-from-server.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -11,8 +11,8 @@ __PROJECT__=$( ) cd ${__PROJECT__} -mkdir -p pool/lib -mkdir -p pool/ext +mkdir -p pool/lib +mkdir -p pool/ext test -d ${__PROJECT__}/var/download-box/ || mkdir -p ${__PROJECT__}/var/download-box/ @@ -25,7 +25,7 @@ DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.5.1/' while [ $# -gt 0 ]; do case "$1" in --mirror) - if [ "$2" = 'china' ] ; then + if [ "$2" = 'china' ]; then DOMAIN='https://swoole-cli.jingjingxyk.com/' fi ;; @@ -36,19 +36,18 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - URL="${DOMAIN}/all-deps.zip" -test -f all-deps.zip || curl -Lo all-deps.zip ${URL} +test -f all-deps.zip || curl -Lo all-deps.zip ${URL} # hash 签名 HASH=$(sha256sum all-deps.zip | awk '{print $1}') # 签名验证失败,删除下载文件 -if [ ${HASH} != ${ALL_DEPS_HASH} ] ; then - echo 'hash signature is invalid !' - rm -f all-deps.zip - exit 0 +if [ ${HASH} != ${ALL_DEPS_HASH} ]; then + echo 'hash signature is invalid !' + rm -f all-deps.zip + exit 0 fi unzip -n all-deps.zip diff --git a/sapi/download-box/download-box-init.sh b/sapi/download-box/download-box-init.sh index 4559d3bb98..6350ba2db2 100644 --- a/sapi/download-box/download-box-init.sh +++ b/sapi/download-box/download-box-init.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -30,6 +30,3 @@ sh sapi/scripts/generate-dependency-graph.sh awk 'BEGIN { cmd="cp -ri pool/lib/* var/download-box/lib/ " ; print "n" |cmd; }' awk 'BEGIN { cmd="cp -ri pool/ext/* var/download-box/ext/ " ; print "n" |cmd; }' - - - diff --git a/sapi/download-box/download-box-server-run-test.sh b/sapi/download-box/download-box-server-run-test.sh index 64b065c3a1..f44af354f5 100644 --- a/sapi/download-box/download-box-server-run-test.sh +++ b/sapi/download-box/download-box-server-run-test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( diff --git a/sapi/download-box/download-dependencies-use-aria2.sh b/sapi/download-box/download-dependencies-use-aria2.sh index 904115c851..31c7c537ce 100644 --- a/sapi/download-box/download-dependencies-use-aria2.sh +++ b/sapi/download-box/download-dependencies-use-aria2.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -11,14 +11,12 @@ __PROJECT__=$( ) cd ${__PROJECT__} - mkdir -p ${__PROJECT__}/var/ -mkdir -p ${__PROJECT__}/var/download-box/lib/ -mkdir -p ${__PROJECT__}/var/download-box/ext/ +mkdir -p ${__PROJECT__}/var/download-box/lib/ +mkdir -p ${__PROJECT__}/var/download-box/ext/ cd ${__PROJECT__}/var/download-box/ - # https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads # https://aria2.github.io/manual/en/html/aria2c.html # -with-config-file-path=/usr/local/php/etc @@ -26,7 +24,7 @@ cd ${__PROJECT__}/var/download-box/ # aria2c -h # aria2c --conf-path=/etc/aria2/aria2.conf -:< -x, --max-connection-per-server= @@ -37,14 +35,11 @@ EOF user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36' +test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 \ + -d lib --input-file=download_library_urls.txt -test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 \ - -d lib --input-file=download_library_urls.txt - - -test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \ - -d ext --input-file=download_extension_urls.txt - +test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \ + -d ext --input-file=download_extension_urls.txt cd ${__PROJECT__} @@ -59,4 +54,3 @@ awk 'BEGIN { cmd="cp -ri var/download-box/ext/* pool/ext"; print "n" |cmd; }' cd ${__PROJECT__} exit 0 - diff --git a/sapi/download-box/web-server-nginx.sh b/sapi/download-box/web-server-nginx.sh index a59f484a71..f100c13443 100644 --- a/sapi/download-box/web-server-nginx.sh +++ b/sapi/download-box/web-server-nginx.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -15,7 +15,6 @@ DOCUMENT_ROOT=${__PROJECT__}/pool/ IMAGE=nginx:alpine - { docker stop download-box-web-server sleep 5 @@ -23,10 +22,8 @@ IMAGE=nginx:alpine echo $? } - docker run -d --rm --name download-box-web-server \ --p 9503:80 \ --v ${DOCUMENT_ROOT}:/usr/share/nginx/html/ \ --v ${__DIR__}/default.conf:/etc/nginx/conf.d/default.conf \ -${IMAGE} - + -p 9503:80 \ + -v ${DOCUMENT_ROOT}:/usr/share/nginx/html/ \ + -v ${__DIR__}/default.conf:/etc/nginx/conf.d/default.conf \ + ${IMAGE} diff --git a/sapi/download-box/web-server.php b/sapi/download-box/web-server.php index acae95d15f..58cc927523 100644 --- a/sapi/download-box/web-server.php +++ b/sapi/download-box/web-server.php @@ -39,7 +39,7 @@ 'application/json' ], 'display_errors' => true, - 'daemonize'=>true, + 'daemonize' => true, 'log_file' => "/tmp/swoole-cli-download-box-web.log" # 'ssl_cert_file' => __DIR__.'/config/ssl.crt', # 'ssl_key_file' => __DIR__.'/config/ssl.key',