From 40d09bc82e896634a50800b5b44d716864c5bd6b Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 22 Apr 2023 01:32:17 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/connection-static-php-cli.sh | 11 +++++++ quickstart/debian-11-init.sh | 18 ++++++++++++ .../prepare-php-runtime-linux-x86_64.sh | 29 +++++++++++++++++++ quickstart/prepare.sh | 22 ++++++++++++++ quickstart/run-debian-11-container.sh | 25 ++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 quickstart/connection-static-php-cli.sh create mode 100644 quickstart/debian-11-init.sh create mode 100644 quickstart/prepare-php-runtime-linux-x86_64.sh create mode 100644 quickstart/prepare.sh create mode 100644 quickstart/run-debian-11-container.sh diff --git a/quickstart/connection-static-php-cli.sh b/quickstart/connection-static-php-cli.sh new file mode 100644 index 000000000..109735024 --- /dev/null +++ b/quickstart/connection-static-php-cli.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +cd ${__DIR__} + +docker exec -it static-php-cli-dev-1 bash diff --git a/quickstart/debian-11-init.sh b/quickstart/debian-11-init.sh new file mode 100644 index 000000000..c5a14e372 --- /dev/null +++ b/quickstart/debian-11-init.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list && \ +sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + +apt update -y +apt install -y git curl wget ca-certificates +apt install -y xz-utils autoconf automake libclang-13-dev clang lld libtool cmake bison re2c gettext coreutils lzip zip unzip +apt install -y pkg-config bzip2 flex +apt install -y musl-gcc + +# apt install build-essential linux-headers-$(uname -r) \ No newline at end of file diff --git a/quickstart/prepare-php-runtime-linux-x86_64.sh b/quickstart/prepare-php-runtime-linux-x86_64.sh new file mode 100644 index 000000000..dd6e82512 --- /dev/null +++ b/quickstart/prepare-php-runtime-linux-x86_64.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__PROJECT__} +mkdir -p var +cd ${__PROJECT__}/var + +test -f swoole-cli-v5.0.2-linux-x64.tar.xz || wget -O swoole-cli-v5.0.2-linux-x64.tar.xz https://github.com/swoole/swoole-src/releases/download/v5.0.2/swoole-cli-v5.0.2-linux-x64.tar.xz +test -f swoole-cli-v5.0.2-linux-x64.tar || xz -d -k swoole-cli-v5.0.2-linux-x64.tar.xz +test -f swoole-cli || tar -xvf swoole-cli-v5.0.2-linux-x64.tar +chmod a+x swoole-cli + +test -f composer.phar || wget -O composer.phar https://getcomposer.org/download/2.5.5/composer.phar +chmod a+x composer.phar + +cp -f swoole-cli /usr/local/bin/ +cp -f composer.phar /usr/local/bin/ + +ln -sf /usr/local/bin//swoole-cli /usr/local/bin//php +ln -sf /usr/local/bin//composer.phar /usr/local/bin//composer + diff --git a/quickstart/prepare.sh b/quickstart/prepare.sh new file mode 100644 index 000000000..c278d3386 --- /dev/null +++ b/quickstart/prepare.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__PROJECT__} + +composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +chmod +x bin/spc + +./bin/spc fetch --all --debug + +./bin/spc list-ext +# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx +./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-all --cc=gcc --debug \ No newline at end of file diff --git a/quickstart/run-debian-11-container.sh b/quickstart/run-debian-11-container.sh new file mode 100644 index 000000000..63b757619 --- /dev/null +++ b/quickstart/run-debian-11-container.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__DIR__} + + +{ + docker stop static-php-cli-dev-1 +} || { + echo $? +} +cd ${__DIR__} +IMAGE=debian:11 + +cd ${__DIR__} +docker run --rm --name static-php-cli-dev-1 -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null + From 65a32a977ff87729d0b4e8b37f758fd8dff7ca2b Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 22 Apr 2023 02:05:26 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E7=BC=96=E8=AF=91=E7=8E=AF=E5=A2=83=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/linux/x86_64/README.md | 33 +++++++++++++++++++ quickstart/linux/x86_64/alpine-3.16-init.sh | 14 ++++++++ .../x86_64}/connection-static-php-cli.sh | 0 .../{ => linux/x86_64}/debian-11-init.sh | 4 +-- .../prepare-php-runtime-linux-x86_64.sh | 0 quickstart/linux/x86_64/prepare.sh | 25 ++++++++++++++ .../linux/x86_64/run-alpine-3.16-container.sh | 25 ++++++++++++++ .../x86_64}/run-debian-11-container.sh | 0 .../prepare-php-runtime-macos-x86_64.sh | 33 +++++++++++++++++++ quickstart/{ => macOS/x86_64}/prepare.sh | 6 ++-- 10 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 quickstart/linux/x86_64/README.md create mode 100644 quickstart/linux/x86_64/alpine-3.16-init.sh rename quickstart/{ => linux/x86_64}/connection-static-php-cli.sh (100%) rename quickstart/{ => linux/x86_64}/debian-11-init.sh (86%) rename quickstart/{ => linux/x86_64}/prepare-php-runtime-linux-x86_64.sh (100%) create mode 100644 quickstart/linux/x86_64/prepare.sh create mode 100644 quickstart/linux/x86_64/run-alpine-3.16-container.sh rename quickstart/{ => linux/x86_64}/run-debian-11-container.sh (100%) create mode 100644 quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh rename quickstart/{ => macOS/x86_64}/prepare.sh (58%) diff --git a/quickstart/linux/x86_64/README.md b/quickstart/linux/x86_64/README.md new file mode 100644 index 000000000..206688f33 --- /dev/null +++ b/quickstart/linux/x86_64/README.md @@ -0,0 +1,33 @@ +# 快速启动容器环境 +> 提供了2款构建环境 +> 任意一款都可以 + + +## debian 11 构建环境 + +```bash + +# 启动 debian 11 容器环境 +sh quickstart/linux/x86_64/run-debian-11-container.sh + +# 进入容器 +sh quickstart/linux/x86_64/connection-static-php-cli.sh + +# 准备构建基础软件 +sh quickstart/linux/x86_64/debian-11-init.sh + +``` + +## aline 构建环境 +```bash + +# 启动 alpine 容器环境 +sh quickstart/linux/x86_64/run-alpine-3.16-container.sh + +# 进入容器 +sh sh quickstart/linux/x86_64/connection-static-php-cli.sh + +# 准备构建基础软件 +sh quickstart/linux/x86_64/alpine-3.16-init.sh + +``` \ No newline at end of file diff --git a/quickstart/linux/x86_64/alpine-3.16-init.sh b/quickstart/linux/x86_64/alpine-3.16-init.sh new file mode 100644 index 000000000..238e91bdc --- /dev/null +++ b/quickstart/linux/x86_64/alpine-3.16-init.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save +sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories + +apk update + +apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils \ No newline at end of file diff --git a/quickstart/connection-static-php-cli.sh b/quickstart/linux/x86_64/connection-static-php-cli.sh similarity index 100% rename from quickstart/connection-static-php-cli.sh rename to quickstart/linux/x86_64/connection-static-php-cli.sh diff --git a/quickstart/debian-11-init.sh b/quickstart/linux/x86_64/debian-11-init.sh similarity index 86% rename from quickstart/debian-11-init.sh rename to quickstart/linux/x86_64/debian-11-init.sh index c5a14e372..9e4463b6b 100644 --- a/quickstart/debian-11-init.sh +++ b/quickstart/linux/x86_64/debian-11-init.sh @@ -10,9 +10,9 @@ sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list && \ sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list apt update -y -apt install -y git curl wget ca-certificates +apt install -y git curl wget ca-certificates apt install -y xz-utils autoconf automake libclang-13-dev clang lld libtool cmake bison re2c gettext coreutils lzip zip unzip apt install -y pkg-config bzip2 flex -apt install -y musl-gcc + # apt install build-essential linux-headers-$(uname -r) \ No newline at end of file diff --git a/quickstart/prepare-php-runtime-linux-x86_64.sh b/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh similarity index 100% rename from quickstart/prepare-php-runtime-linux-x86_64.sh rename to quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh diff --git a/quickstart/linux/x86_64/prepare.sh b/quickstart/linux/x86_64/prepare.sh new file mode 100644 index 000000000..19f5d0d29 --- /dev/null +++ b/quickstart/linux/x86_64/prepare.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__PROJECT__} + +composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +chmod +x bin/spc + +./bin/spc fetch --all --debug + +./bin/spc list-ext + + +#./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=gcc --cxx=g++ --debug + +./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug diff --git a/quickstart/linux/x86_64/run-alpine-3.16-container.sh b/quickstart/linux/x86_64/run-alpine-3.16-container.sh new file mode 100644 index 000000000..f0e6fbb51 --- /dev/null +++ b/quickstart/linux/x86_64/run-alpine-3.16-container.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__DIR__} + + +{ + docker stop static-php-cli-dev-1 +} || { + echo $? +} +cd ${__DIR__} +IMAGE=alpine:3.16 + +cd ${__DIR__} +docker run --rm --name static-php-cli-dev-1 -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null + diff --git a/quickstart/run-debian-11-container.sh b/quickstart/linux/x86_64/run-debian-11-container.sh similarity index 100% rename from quickstart/run-debian-11-container.sh rename to quickstart/linux/x86_64/run-debian-11-container.sh diff --git a/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh b/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh new file mode 100644 index 000000000..2bf74b4bd --- /dev/null +++ b/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) +cd ${__PROJECT__} + + +mkdir -p ${__PROJECT__}/bin/runtime +mkdir -p ${__PROJECT__}/var + +cd ${__PROJECT__}/var + + + +test -f swoole-cli-v5.0.1-macos-x64.tar.xz || wget -O swoole-cli-v5.0.1-macos-x64.tar.xz https://github.com/swoole/swoole-src/releases/download/v5.0.1/swoole-cli-v5.0.1-macos-x64.tar.xz +test -f swoole-cli-v5.0.1-macos-x64.tar || xz -d -k swoole-cli-v5.0.1-macos-x64.tar.xz +test -f swoole-cli || tar -xvf swoole-cli-v5.0.1-macos-x64.tar +chmod a+x swoole-cli + +test -f composer.phar || wget -O composer.phar https://getcomposer.org/download/2.5.5/composer.phar +chmod a+x composer.phar + +mv ${__PROJECT__}/var/swoole-cli ${__PROJECT__}/bin/runtime/php +mv ${__PROJECT__}/var/composer.phar ${__PROJECT__}/bin/runtime/composer + +export PATH=${__PROJECT__}/bin/runtime:$PATH \ No newline at end of file diff --git a/quickstart/prepare.sh b/quickstart/macOS/x86_64/prepare.sh similarity index 58% rename from quickstart/prepare.sh rename to quickstart/macOS/x86_64/prepare.sh index c278d3386..ef978b42f 100644 --- a/quickstart/prepare.sh +++ b/quickstart/macOS/x86_64/prepare.sh @@ -11,6 +11,8 @@ __PROJECT__=$( ) cd ${__PROJECT__} +export PATH=${__PROJECT__}/bin/runtime:$PATH + composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ chmod +x bin/spc @@ -18,5 +20,5 @@ chmod +x bin/spc ./bin/spc fetch --all --debug ./bin/spc list-ext -# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx -./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-all --cc=gcc --debug \ No newline at end of file + +./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug From eacb24a482a70be8119384f8ae1e20c6add34c9a Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 22 Apr 2023 02:14:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20linux=20X86=5F64=20REA?= =?UTF-8?q?DME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/linux/x86_64/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quickstart/linux/x86_64/README.md b/quickstart/linux/x86_64/README.md index 206688f33..deb80a2be 100644 --- a/quickstart/linux/x86_64/README.md +++ b/quickstart/linux/x86_64/README.md @@ -1,7 +1,7 @@ # 快速启动容器环境 -> 提供了2款构建环境 -> 任意一款都可以 +> 提供了 debian 11 构建 和 alpine 构建环境 +> 任意选一个就可以 ## debian 11 构建环境 @@ -19,6 +19,7 @@ sh quickstart/linux/x86_64/debian-11-init.sh ``` ## aline 构建环境 + ```bash # 启动 alpine 容器环境 From ea40d25125224c92aad5c6b862844c3f2907b105 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 22 Apr 2023 11:12:16 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9E=84=E5=BB=BA=E7=8E=AF=E5=A2=83=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/linux/x86_64/run-alpine-3.16-container.sh | 2 +- quickstart/linux/x86_64/run-debian-11-container.sh | 2 +- quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstart/linux/x86_64/run-alpine-3.16-container.sh b/quickstart/linux/x86_64/run-alpine-3.16-container.sh index f0e6fbb51..b53d9cd43 100644 --- a/quickstart/linux/x86_64/run-alpine-3.16-container.sh +++ b/quickstart/linux/x86_64/run-alpine-3.16-container.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../ + cd ${__DIR__}/../../../ pwd ) cd ${__DIR__} diff --git a/quickstart/linux/x86_64/run-debian-11-container.sh b/quickstart/linux/x86_64/run-debian-11-container.sh index 63b757619..a9239727a 100644 --- a/quickstart/linux/x86_64/run-debian-11-container.sh +++ b/quickstart/linux/x86_64/run-debian-11-container.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../ + cd ${__DIR__}/../../../ pwd ) cd ${__DIR__} diff --git a/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh b/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh index 2bf74b4bd..df3884fb0 100644 --- a/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh +++ b/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../../ + cd ${__DIR__}/../../../ pwd ) cd ${__PROJECT__} From e4de37708b1214d6304dfc2f11ce956855919f6a Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 22 Apr 2023 11:20:36 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9E=84=E5=BB=BA=E7=8E=AF=E5=A2=83=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh | 2 +- quickstart/linux/x86_64/prepare.sh | 2 +- quickstart/macOS/x86_64/prepare.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh b/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh index dd6e82512..05b1a3502 100644 --- a/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh +++ b/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../ + cd ${__DIR__}/../../../ pwd ) cd ${__PROJECT__} diff --git a/quickstart/linux/x86_64/prepare.sh b/quickstart/linux/x86_64/prepare.sh index 19f5d0d29..bd2783309 100644 --- a/quickstart/linux/x86_64/prepare.sh +++ b/quickstart/linux/x86_64/prepare.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../ + cd ${__DIR__}/../../../ pwd ) cd ${__PROJECT__} diff --git a/quickstart/macOS/x86_64/prepare.sh b/quickstart/macOS/x86_64/prepare.sh index ef978b42f..93b835608 100644 --- a/quickstart/macOS/x86_64/prepare.sh +++ b/quickstart/macOS/x86_64/prepare.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../ + cd ${__DIR__}/../../../ pwd ) cd ${__PROJECT__} From 8fb8b3423950d5673ff85b96388b11668bd20c8f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Apr 2023 17:18:21 +0800 Subject: [PATCH 6/6] enhancement for prepare-php-runtime: integrate in one file --- .gitignore | 5 ++ bin/setup-runtime | 48 +++++++++++++++++++ .../prepare-php-runtime-linux-x86_64.sh | 29 ----------- .../prepare-php-runtime-macos-x86_64.sh | 33 ------------- 4 files changed, 53 insertions(+), 62 deletions(-) create mode 100755 bin/setup-runtime delete mode 100644 quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh delete mode 100644 quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh diff --git a/.gitignore b/.gitignore index 3e7d7e33c..0b6f47933 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ composer.lock # php cs fixer cache file .php-cs-fixer.cache + +# exclude self-runtime +/bin/* +!/bin/spc +!/bin/setup-runtime diff --git a/bin/setup-runtime b/bin/setup-runtime new file mode 100755 index 000000000..54c89455f --- /dev/null +++ b/bin/setup-runtime @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# set error-quit, verbose, non-variable-quit +set -eu +# see what system used +__OS__=$(uname -s) +# see what arch used +__ARCH__=$(uname -m) +# format arch name +case $__ARCH__ in +arm64 | aarch64) __ARCH__=arm64 ;; +x86_64|x64) __ARCH__=x64 ;; +*) ;; +esac + +# format uname +case $__OS__ in +Darwin) __OS_FIXED__=macos ;; +Linux) __OS_FIXED__=linux ;; +*) echo "Current OS is not supported" && exit 1 ;; +esac + +# set project dir +__DIR__=$(cd "$(dirname "$0")" && pwd) +__PROJECT__=$(cd ${__DIR__}/../ && pwd) + +# set download dir +__PHP_RUNTIME_URL__="https://github.com/swoole/swoole-src/releases/download/v5.0.1/swoole-cli-v5.0.1-${__OS_FIXED__}-${__ARCH__}.tar.xz" +__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar" + +# download static-php binary (currently using swoole-cli temporarily) +test -d ${__PROJECT__}/downloads || mkdir ${__PROJECT__}/downloads +# download static php binary +test -f ${__PROJECT__}/downloads/runtime.tar.xz || curl -#fSL -o ${__PROJECT__}/downloads/runtime.tar.xz "$__PHP_RUNTIME_URL__" +test -f ${__DIR__}/php || { tar -xf ${__PROJECT__}/downloads/runtime.tar.xz -C ${__DIR__}/ && mv ${__DIR__}/swoole-cli ${__DIR__}/php && rm ${__DIR__}/LICENSE ; } # (TODO: temporarily use swoole-cli as php) +chmod +x ${__DIR__}/php +# download composer +test -f ${__DIR__}/composer || curl -#fSL -o ${__DIR__}/composer "$__COMPOSER_URL__" +chmod +x ${__DIR__}/composer +# sanity check for php and composer +${__DIR__}/php -v >/dev/null || { echo "Failed to run php" && exit 1; } +${__DIR__}/php ${__DIR__}/composer --version >/dev/null || { echo "Failed to run composer" && exit 1; } + +echo "Setup runtime OK!" +echo "runtime bin path needs to add manually by command below:" +echo "" +echo " export PATH=\"${__DIR__}:\$PATH\"" +echo "" diff --git a/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh b/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh deleted file mode 100644 index 05b1a3502..000000000 --- a/quickstart/linux/x86_64/prepare-php-runtime-linux-x86_64.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} -mkdir -p var -cd ${__PROJECT__}/var - -test -f swoole-cli-v5.0.2-linux-x64.tar.xz || wget -O swoole-cli-v5.0.2-linux-x64.tar.xz https://github.com/swoole/swoole-src/releases/download/v5.0.2/swoole-cli-v5.0.2-linux-x64.tar.xz -test -f swoole-cli-v5.0.2-linux-x64.tar || xz -d -k swoole-cli-v5.0.2-linux-x64.tar.xz -test -f swoole-cli || tar -xvf swoole-cli-v5.0.2-linux-x64.tar -chmod a+x swoole-cli - -test -f composer.phar || wget -O composer.phar https://getcomposer.org/download/2.5.5/composer.phar -chmod a+x composer.phar - -cp -f swoole-cli /usr/local/bin/ -cp -f composer.phar /usr/local/bin/ - -ln -sf /usr/local/bin//swoole-cli /usr/local/bin//php -ln -sf /usr/local/bin//composer.phar /usr/local/bin//composer - diff --git a/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh b/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh deleted file mode 100644 index df3884fb0..000000000 --- a/quickstart/macOS/x86_64/prepare-php-runtime-macos-x86_64.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} - - -mkdir -p ${__PROJECT__}/bin/runtime -mkdir -p ${__PROJECT__}/var - -cd ${__PROJECT__}/var - - - -test -f swoole-cli-v5.0.1-macos-x64.tar.xz || wget -O swoole-cli-v5.0.1-macos-x64.tar.xz https://github.com/swoole/swoole-src/releases/download/v5.0.1/swoole-cli-v5.0.1-macos-x64.tar.xz -test -f swoole-cli-v5.0.1-macos-x64.tar || xz -d -k swoole-cli-v5.0.1-macos-x64.tar.xz -test -f swoole-cli || tar -xvf swoole-cli-v5.0.1-macos-x64.tar -chmod a+x swoole-cli - -test -f composer.phar || wget -O composer.phar https://getcomposer.org/download/2.5.5/composer.phar -chmod a+x composer.phar - -mv ${__PROJECT__}/var/swoole-cli ${__PROJECT__}/bin/runtime/php -mv ${__PROJECT__}/var/composer.phar ${__PROJECT__}/bin/runtime/composer - -export PATH=${__PROJECT__}/bin/runtime:$PATH \ No newline at end of file