From 35395538b45f3ffbf0c37a57d6122434424d2fb9 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Jul 2021 05:24:14 +0000 Subject: [PATCH] update to 1.3.2 version (support sqlite3) --- README-en.md | 75 ++++++++++++++++---------------- README.md | 3 +- docker/Dockerfile | 6 ++- docker/ac_override_1 | 0 docker/ac_override_2 | 0 docker/check-extensions.sh | 3 ++ docker/compile-php.sh | 4 +- docker/config.json | 89 +++++++++++++++++++------------------- docker/download.sh | 48 +++++++++++++------- docker/extensions.txt | 1 + docker/fast-compiler.sh | 48 ++++++++++++++++++++ 11 files changed, 175 insertions(+), 102 deletions(-) mode change 100644 => 100755 README-en.md mode change 100644 => 100755 README.md mode change 100644 => 100755 docker/Dockerfile mode change 100644 => 100755 docker/ac_override_1 mode change 100644 => 100755 docker/ac_override_2 mode change 100644 => 100755 docker/config.json mode change 100644 => 100755 docker/extensions.txt create mode 100755 docker/fast-compiler.sh diff --git a/README-en.md b/README-en.md old mode 100644 new mode 100755 index d7e69434..5f58d4af --- a/README-en.md +++ b/README-en.md @@ -3,7 +3,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. BTW, It's only for CLI mode. -[![version](https://img.shields.io/badge/version-1.3.0-green.svg)]() +[![version](https://img.shields.io/badge/version-1.3.2-green.svg)]() ## Requirements - Tested on `x86_64` and `aarch64` platform, others have not tested. @@ -33,42 +33,43 @@ To customize PHP extensions, edit `docker/extensions.txt` file, and rules below: - extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue ## Supported PHP extensions -| Support | PHP Ext Name | Version | Comments | -| -------- | ------------ | -------- | ------------------------------------------------------- | -| yes | bcmath | * | | -| yes | calendar | * | | -| yes | ctype | * | | -| yes | curl | * | | -| yes | dom | * | | -| | event | | | -| yes | filter | * | | -| yes | gd | * | | -| yes | hash | * | PHP7.3 or older uses `--enable-hash` | -| yes | iconv | * | | -| yes | inotify | 3.0.0 | | -| yes | json | * | | -| yes | libxml | * | | -| yes | mbstring | * | | -| yes | mongodb | >=1.9.1 | not tested | -| | mysqli | | | -| yes | mysqlnd | * | | -| yes | openssl | * | | -| yes | pcntl | * | | -| yes | pdo | * | | -| yes | pdo_mysql | * | | -| | pdo_pgsql | * | | -| yes | phar | * | | -| yes | posix | * | | -| yes | redis | * | | -| yes | simplexml | * | | -| yes | sockets | * | | -| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis | -| yes | tokenizer | * | | -| yes | xml | * | | -| yes | xmlreader | * | | -| yes | xmlwriter | * | | -| | zip | | | -| yes | zlib | * | | +| Support | PHP Ext Name | Version | Comments | +| ------- | ------------ | ------- | ---------------------------------------- | +| yes | bcmath | * | | +| yes | calendar | * | | +| yes | ctype | * | | +| yes | curl | * | | +| yes | dom | * | | +| | event | | | +| yes | filter | * | | +| yes | gd | * | | +| yes | hash | * | PHP7.3 or older uses `--enable-hash` | +| yes | iconv | * | | +| yes | inotify | 3.0.0 | | +| yes | json | * | | +| yes | libxml | * | | +| yes | mbstring | * | | +| yes | mongodb | >=1.9.1 | not tested | +| | mysqli | | | +| yes | mysqlnd | * | | +| yes | openssl | * | | +| yes | pcntl | * | | +| yes | pdo | * | | +| yes | pdo_mysql | * | | +| | pdo_pgsql | * | | +| yes | phar | * | | +| yes | posix | * | | +| yes | redis | * | | +| yes | simplexml | * | | +| yes | sockets | * | | +| yes | sqlite3 | * | not tested | +| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis | +| yes | tokenizer | * | | +| yes | xml | * | | +| yes | xmlreader | * | | +| yes | xmlwriter | * | | +| | zip | | | +| yes | zlib | * | | ## Customization - `docker/Dockerfile` edit `VER_PHP=x.x.x` to switch PHP version. diff --git a/README.md b/README.md old mode 100644 new mode 100755 index fd71057e..2ae2ef7e --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [English READM 注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式 -[![版本](https://img.shields.io/badge/script--version-1.3.0-green.svg)]() +[![版本](https://img.shields.io/badge/script--version-1.3.2-green.svg)]() ## 环境需求 - 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试 @@ -64,6 +64,7 @@ file ./php | yes | redis | * | | | yes | simplexml | * | | | yes | sockets | * | | +| yes | sqlite3 | * | not tested | | yes | swoole | >=4.6.6 | 默认支持mysqlnd, sockets, openssl, redis | | yes | tokenizer | * | | | yes | xml | * | | diff --git a/docker/Dockerfile b/docker/Dockerfile old mode 100644 new mode 100755 index 0ea58c5d..7e19fe81 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:latest # define script basic information # Version of this Dockerfile -ENV SCRIPT_VERSION=1.3.1 +ENV SCRIPT_VERSION=1.3.2 # Download address uses backup address # (if downloading slowly, consider set it to yes) ENV USE_BACKUP=no @@ -23,7 +23,7 @@ RUN if [ "${USE_BACKUP}" = "yes" ]; then \ RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories # build requirements -RUN apk add wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses +RUN apk add bash wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses # php zlib dependencies RUN apk add zlib-dev zlib-static # php mbstring dependencies @@ -36,6 +36,8 @@ RUN apk add libpng-dev libpng-static RUN apk add c-ares-static c-ares-dev # php event dependencies RUN apk add libevent libevent-dev libevent-static +# php sqlite3 dependencies +RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static RUN mkdir /app diff --git a/docker/ac_override_1 b/docker/ac_override_1 old mode 100644 new mode 100755 diff --git a/docker/ac_override_2 b/docker/ac_override_2 old mode 100644 new mode 100755 diff --git a/docker/check-extensions.sh b/docker/check-extensions.sh index 4ac85e4f..d00a1e21 100755 --- a/docker/check-extensions.sh +++ b/docker/check-extensions.sh @@ -73,6 +73,7 @@ function check_before_configure() { phar) ;; posix) ;; sockets) ;; + sqlite3) ;; tokenizer) ;; zlib) ;; curl) @@ -187,6 +188,8 @@ function check_in_configure() { redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;; simplexml) php_configure="$php_configure --enable-simplexml" ;; sockets) php_configure="$php_configure --enable-sockets" ;; + sqlite3) php_configure="$php_configure --with-sqlite3" ;; + swoole) php_configure="$php_configure --enable-swoole" have_openssl=$(echo $list | grep openssl) diff --git a/docker/compile-php.sh b/docker/compile-php.sh index 17e183d7..44a725e3 100755 --- a/docker/compile-php.sh +++ b/docker/compile-php.sh @@ -6,7 +6,7 @@ self_dir=$(cd "$(dirname "$0")";pwd) php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1) function php_compile_args() { - _php_arg="--prefix=/app/php-dist" + _php_arg="--prefix=$self_dir/php-dist" _php_arg="$_php_arg --disable-all" _php_arg="$_php_arg --enable-shared=no" _php_arg="$_php_arg --enable-static=yes" @@ -29,4 +29,4 @@ cd $php_dir && \ sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \ make LDFLAGS=-ldl -j4 && \ make install && \ - strip /app/php-dist/bin/php \ No newline at end of file + strip $self_dir/php-dist/bin/php \ No newline at end of file diff --git a/docker/config.json b/docker/config.json old mode 100644 new mode 100755 index 581f9410..816a9644 --- a/docker/config.json +++ b/docker/config.json @@ -1,46 +1,47 @@ { - "php": { - "link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz", - "link_2": "https://www.php.net/distributions/php-{version}.tar.gz" - }, - "swoole": { - "version": "4.6.7", - "link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz", - "link_2": "https://pecl.php.net/get/swoole-{version}.tgz" - }, - "mongodb": { - "version": "1.9.1", - "link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz", - "link_2": "https://pecl.php.net/get/mongodb-{version}.tgz" - }, - "inotify": { - "version": "3.0.0", - "link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz", - "link_2": "https://pecl.php.net/get/inotify-{version}.tgz" - }, - "event": { - "version": "3.0.4", - "link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz", - "link_2": "https://pecl.php.net/get/event-{version}.tgz" - }, - "redis": { - "version": "5.3.4", - "link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz", - "link_2": "https://pecl.php.net/get/redis-{version}.tgz" - }, - "libxml2": { - "version": "2.9.10", - "link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz", - "link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz" - }, - "liblzma": { - "version": "master", - "link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz", - "link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip" - }, - "curl": { - "version": "7.77.0", - "link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz", - "link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz" - } + "php": { + "link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz", + "link_2": "https://www.php.net/distributions/php-{version}.tar.gz" + }, + "swoole": { + "version": "4.7.0", + "link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz", + "link_2": "https://pecl.php.net/get/swoole-{version}.tgz" + }, + "mongodb": { + "version": "1.9.1", + "link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz", + "link_2": "https://pecl.php.net/get/mongodb-{version}.tgz" + }, + "inotify": { + "version": "3.0.0", + "link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz", + "link_2": "https://pecl.php.net/get/inotify-{version}.tgz" + }, + "event": { + "version": "3.0.4", + "link": "http://mirrors.zhamao.xin/pecl/event-{version}.tgz", + "link_2": "https://pecl.php.net/get/event-{version}.tgz" + }, + "redis": { + "version": "5.3.4", + "link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz", + "link_2": "https://pecl.php.net/get/redis-{version}.tgz" + }, + "libxml2": { + "version": "2.9.10", + "link": "https://dl.zhamao.me/libxml2/libxml2-{version}.tar.gz", + "link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz" + }, + "liblzma": { + "version": "master", + "link": "https://dl.zhamao.me/liblzma/liblzma.tar.gz", + "link_2": "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip", + "alt_name": "master" + }, + "curl": { + "version": "7.78.0", + "link": "https://dl.zhamao.me/curl/curl-{version}.tar.gz", + "link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz" + } } \ No newline at end of file diff --git a/docker/download.sh b/docker/download.sh index 7f94827c..bb6be0e7 100755 --- a/docker/download.sh +++ b/docker/download.sh @@ -8,6 +8,10 @@ if [ ! -d "source" ]; then mkdir source fi +if [ ! -d "source/cache" ]; then + mkdir source/cache +fi + function readconf() { cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g' } @@ -20,24 +24,36 @@ else _use_backup="" fi -if [ "$3" != "" ]; then - wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')" -else - wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')" -fi +archive_find_tar=$(find cache/ -name "$1.*" | grep -E ".tgz" | tail -n1) +archive_find_zip=$(find cache/ -name "$1.*" | grep -E ".zip" | tail -n1) -if [ $? == 0 ]; then - archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1) - archive_file_zip=$(find . -name "$1*.*" | grep -E ".zip" | tail -n1) - if [ "$archive_file_tar" != "" ]; then - tar -zxvf $archive_file_tar && rm $archive_file_tar - elif [ "$archive_file_zip" != "" ]; then - unzip $archive_file_zip && rm $archive_file_zip +if [ "$archive_find_tar" != "" ]; then + echo "Using cache for $1 ($archive_find_tar)" + tar -zxvf $archive_file_tar -C $SELF_DIR/source +elif [ "$archive_find_zip" != "" ]; then + echo "Using cache for $1 ($archive_find_zip)" + unzip $archive_find_zip -d $SELF_DIR/source +else + if [ "$3" != "" ]; then + wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')" else - echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!" + echo "Downloading" + wget -q --show-progress "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')" + fi + + if [ $? == 0 ]; then + archive_file_tar=$(find . -name "$1*.*" | grep -E ".tar|.gz|.tgz" | tail -n1) + archive_file_zip=$(find . -name "*.zip" | tail -n1) + if [ "$archive_file_tar" != "" ]; then + tar -zxvf $archive_file_tar && mv $archive_file_tar $SELF_DIR/source/cache/$1.tgz + elif [ "$archive_file_zip" != "" ]; then + unzip $archive_file_zip && mv $archive_file_zip $SELF_DIR/source/cache/$1.zip + else + echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!" + exit 1 + fi + else + echo "Download $1 failed! (at $?)" exit 1 fi -else - echo "Download failed! " - exit 1 fi \ No newline at end of file diff --git a/docker/extensions.txt b/docker/extensions.txt old mode 100644 new mode 100755 index 89ef16e3..e8b1b03f --- a/docker/extensions.txt +++ b/docker/extensions.txt @@ -22,6 +22,7 @@ posix redis simplexml sockets +sqlite3 swoole tokenizer xml diff --git a/docker/fast-compiler.sh b/docker/fast-compiler.sh new file mode 100755 index 00000000..8b2a7c30 --- /dev/null +++ b/docker/fast-compiler.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +VER_PHP="7.4.21" +USE_BACKUP="no" + +LINK_APK_REPO='mirrors.ustc.edu.cn' +LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org' + +if [ "${USE_BACKUP}" = "yes" ]; then \ + echo "Using backup address..." && sleep 1s + LINK_APK_REPO=${LINK_APK_REPO_BAK} +else + echo "Using original address..." && sleep 1s +fi + +sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories + +# build requirements +apk add bash wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses +# php zlib dependencies +apk add zlib-dev zlib-static +# php mbstring dependencies +apk add oniguruma-dev +# php openssl dependencies +apk add openssl-libs-static openssl-dev openssl +# php gd dependencies +apk add libpng-dev libpng-static +# curl c-ares dependencies +apk add c-ares-static c-ares-dev +# php event dependencies +apk add libevent libevent-dev libevent-static +# php sqlite3 dependencies +apk add sqlite sqlite-dev sqlite-libs sqlite-static + +chmod +x download.sh check-extensions.sh compile-php.sh + +./download.sh swoole ${USE_BACKUP} && \ + ./download.sh inotify ${USE_BACKUP} && \ + ./download.sh mongodb ${USE_BACKUP} && \ + ./download.sh event ${USE_BACKUP} && \ + ./download.sh redis ${USE_BACKUP} && \ + ./download.sh libxml2 ${USE_BACKUP} && \ + ./download.sh liblzma ${USE_BACKUP} && \ + ./download.sh curl ${USE_BACKUP} && \ + ./download.sh php ${USE_BACKUP} ${VER_PHP} && \ + ./check-extensions.sh check_before_configure && \ + ./compile-php.sh ${VER_PHP} +