Skip to content

Commit 3295688

Browse files
authored
Merge pull request #911 from jingjingxyk/experiment-feature
Experiment feature
2 parents 9c48726 + 0d135ac commit 3295688

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

docs/upgrade.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
## 升级 PHP 版本 步骤
1+
# 升级 PHP 版本 步骤
22

33
> 1、修改 sapi/PHP-VERSION.conf 文件里版本号即可
4-
> 2、执行同步源码脚本, 拉取 PHP 官方源码 到本项目
4+
5+
> 2、修改 sync-source-code.php 文件里 PHP 源码包的 sha256sum 配置
6+
7+
> 3、执行同步源码脚本, 拉取 PHP 官方源码 到本项目
8+
9+
> 4、sapi/cli/ 代码的升级,需要手动确认
510
611
```shell
712

sapi/scripts/cygwin/cygwin-pack.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ NAME="swoole-cli-v${APP_VERSION}-cygwin-x64"
2121
test -d /tmp/${NAME} && rm -rf /tmp/${NAME}
2222
mkdir -p /tmp/${NAME}
2323
mkdir -p /tmp/${NAME}/etc/
24+
mkdir -p /tmp/${NAME}/bin/
2425

2526
cd ${__PROJECT__}/
2627
ldd ${__PROJECT__}/bin/swoole-cli.exe | grep -v '/cygdrive/' | awk '{print $3}'
27-
ldd ${__PROJECT__}/bin/swoole-cli.exe | grep -v '/cygdrive/' | awk '{print $3}' | xargs -I {} cp {} /tmp/${NAME}/
28+
ldd ${__PROJECT__}/bin/swoole-cli.exe | grep -v '/cygdrive/' | awk '{print $3}' | xargs -I {} cp {} /tmp/${NAME}/bin/
2829

29-
ls -lh /tmp/${NAME}/
30+
ls -lh /tmp/${NAME}/
3031

3132
cp -f ${__PROJECT__}/bin/swoole-cli.exe /tmp/${NAME}/
3233
# cp -f ${__PROJECT__}/bin/LICENSE /tmp/${NAME}/

sapi/scripts/download-php-src-archive.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@
33
$poject_dir = realpath(__DIR__ . '/../../');
44
$php_version_tag = trim(file_get_contents($poject_dir . '/sapi/PHP-VERSION.conf'));
55
$php_source_folder = $poject_dir . "/var/php-{$php_version_tag}";
6-
$php_archive_file = $poject_dir . "/pool/php/php-{$php_version_tag}.tar.gz";
6+
$php_archive_file = $poject_dir . "/pool/php-tar/php-{$php_version_tag}.tar.gz";
7+
$php_archive_file_sha256sum = '41c9e703caaf73ba6c77ee641709a3a5378a5dcb7bcc1fd1997f6e156a84abd4';
78
$download_dir = dirname($php_archive_file);
9+
$download_php_counter = 0;
810

11+
DOWNLOAD_PHP:
912
# 下载 PHP 源码
1013
$download_cmd = "curl -fSL https://github.com/php/php-src/archive/refs/tags/php-{$php_version_tag}.tar.gz -o {$php_archive_file}";
1114
echo $download_cmd . PHP_EOL;
1215
if (!file_exists($php_archive_file)) {
1316
`test -d {$download_dir} || mkdir -p {$download_dir}`;
17+
$download_php_counter++;
1418
`{$download_cmd}`;
1519
}
1620

21+
$hash = hash_file('sha256', $php_archive_file);
22+
echo "sha256sum: " . $hash . PHP_EOL;
23+
if ($hash !== $php_archive_file_sha256sum) {
24+
if ($download_php_counter > 3) {
25+
throw new \Exception('curl download php archive Exception!', 500);
26+
}
27+
echo 'archive sha256sum mismatched , will re-download ' . PHP_EOL;
28+
unlink($php_archive_file);
29+
goto DOWNLOAD_PHP;
30+
}
31+
1732
# 若不存在则解压 PHP 源码包
1833
# tar -zxvf 文件名.tar.gz --strip-components=1 -C 指定解压目录
1934

sync-source-code.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
//测试同步
3131
# 准备工作 测试目录
3232

33-
3433
$directories = array_intersect($scanned_directory_source, $scanned_directory_destination);
3534

3635
`test -d {$sync_dest_dir} && rm -rf {$sync_dest_dir}`;
@@ -59,7 +58,9 @@
5958
# 执行代码同步之前准备
6059
$SYNC_SOURCE_CODE_SHELL .= PHP_EOL . <<<EOF
6160
SRC={$php_source_folder}
62-
cd {$sync_dest_dir}
61+
__PROJECT__={$project_dir}
62+
__WORKDIR__={$sync_dest_dir}
63+
cd \${WORKDIR}
6364
EOF;
6465

6566
# 准备 同步代码脚本
@@ -70,6 +71,19 @@
7071
cp -rf $SRC/Zend/. ./Zend
7172
7273
# Extension
74+
echo 'clean extension'
75+
cd ${SRC}/ext/
76+
EXTENSIONS=$(ls -d */)
77+
cd ${__WORKDIR__}/
78+
for EXT_NAME in $EXTENSIONS; do
79+
EXT_NAME=$(echo "$EXT_NAME" | sed 's@.\{1\}$@@')
80+
echo "EXTENSION_NAME: $EXT_NAME "
81+
test -d ${__WORKDIR__}/ext/${EXT_NAME} && rm -rf ${__WORKDIR__}/ext/${EXT_NAME}
82+
done
83+
84+
echo 'sync extensions '
85+
cd ${__WORKDIR__}/
86+
7387
cp -rf $SRC/ext/bcmath/. ./ext/bcmath
7488
cp -rf $SRC/ext/bz2/. ./ext/bz2
7589
cp -rf $SRC/ext/calendar/. ./ext/calendar

0 commit comments

Comments
 (0)