Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format download-box script #837

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 74 additions & 88 deletions build-release-example.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/bin/bash

#!/usr/bin/env bash

__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__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

Expand All @@ -38,7 +37,6 @@ case $OS in

esac


IN_DOCKER=0
WITH_PHP_COMPOSER=1

Expand Down Expand Up @@ -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

Expand All @@ -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}
Expand All @@ -139,41 +137,37 @@ 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"
alias php="php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem"

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
Expand All @@ -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
Expand All @@ -224,9 +216,3 @@ bash make.sh build
bash make.sh archive

exit 0






14 changes: 2 additions & 12 deletions sapi/download-box/download-box-batch-downloader.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -exu
__DIR__=$(
Expand Down Expand Up @@ -33,17 +33,14 @@ while [ $# -gt 0 ]; do
shift $(($# > 0 ? 1 : 0))
done



DOWNLOAD_BOX_DIR=${__PROJECT__}/var/download-box/
mkdir -p ${__PROJECT__}/var/download-box/

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 : '
Expand All @@ -54,10 +51,3 @@ fi
cd ${__PROJECT__}

sh sapi/download-box/download-dependencies-use-aria2.sh







6 changes: 2 additions & 4 deletions sapi/download-box/download-box-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -exu
__DIR__=$(
Expand All @@ -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
Expand All @@ -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}
4 changes: 1 addition & 3 deletions sapi/download-box/download-box-get-archive-from-container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -exu
__DIR__=$(
Expand All @@ -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
Expand Down
19 changes: 9 additions & 10 deletions sapi/download-box/download-box-get-archive-from-server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -exu
__DIR__=$(
Expand All @@ -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/

Expand All @@ -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
;;
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions sapi/download-box/download-box-init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -exu
__DIR__=$(
Expand Down Expand Up @@ -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; }'



Loading
Loading