diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fe7c4c..38e6684 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: with: go-version: '>=1.9' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build GearBox binaries run: | mkdir -p dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ee15..4a1122d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,49 @@ CHANGELOG ========= +## v0.12.0 + +- Add PHP sqlite3 support + +## v0.11.5 + +- Update sqlsrv max version for PHP8.0 + +## v0.11.4 + +- Update composer install script + - Add command `composer22` (composer `v2.2.x`) for PHP < `7.2.5` + +## v0.11.3 + +- Update composer install script (get checksum from remote URL) + +## v0.11.2 + +- Update composer install script + +## v0.11.1 + +- Update installed package versions + - GoLang: 1.19.7 + - nvm: 0.39.3 + - PHP: 8.2 + +## v0.11.0 + +- Fix Nginx compile script +- Update sqlsrv max version for PHP7.4 +- Add a new support WSL distribution "Ubuntu-22.04" + +## v0.10.1 + +- Show supported versions in "phpvm" command + +## v0.10.0 + +- Normalize configuration for PHP versions +- Update packages to the newest versions + ## v0.9.7 - Update scripts that install Ansible diff --git a/README.md b/README.md index a9f4839..be642ae 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,18 @@ GearBox helps to easily create the same web development environment in Windows(W - Ubuntu - Ubuntu-18.04 - Ubuntu-20.04 + - Ubuntu-22.04 - Linux distributions: - Ubuntu 2. Install packages: - PHP - - Install multiple versions of PHP, v5.6 ~ v8.1 + - Install multiple versions of PHP, v5.6 ~ v8.2 - Provide a `phpvm` command to switch PHP versions. Usage: ``` Usage: phpvm use + + Supported versions: 5.6, 7.2, 7.4, 8.2 + Example1: phpvm use 5.6 then run "php --version" will get "PHP 5.6.x" Example2: phpvm use 7.4 diff --git a/ansible/playbooks.go b/ansible/playbooks.go index 6a05e7d..4ab95e6 100644 --- a/ansible/playbooks.go +++ b/ansible/playbooks.go @@ -2,6 +2,7 @@ package ansible import ( "LeoOnTheEarth/GearBox/configuration" + "bytes" "crypto/md5" "embed" "errors" @@ -123,6 +124,8 @@ func installPlaybookFile(f *file, installDir string) (result *InstallResult, err return result, err } + content = bytes.Replace(content, []byte{'\r', '\n'}, []byte{'\n'}, -1) + if err = os.WriteFile(targetPath, content, 0644); nil != err { return result, err } else { diff --git a/ansible/playbooks/ubuntu/11-php.yml b/ansible/playbooks/ubuntu/11-php.yml index fbe9e57..5abb50c 100644 --- a/ansible/playbooks/ubuntu/11-php.yml +++ b/ansible/playbooks/ubuntu/11-php.yml @@ -3,7 +3,7 @@ hosts: localhost become: true vars: - support_php_versions: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1" ] + support_php_versions: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ] tasks: - name: Add phpvm command to switch PHP versions copy: @@ -30,6 +30,9 @@ esac echo Usage: phpvm use \ + echo + echo 'Supported versions: {{ ', '.join(php.versions) }}' + echo echo 'Example1: phpvm use 5.6' echo ' then run "php --version" will get "PHP 5.6.x"' echo 'Example2: phpvm use 7.4' @@ -52,13 +55,14 @@ become: true vars: php_sqlsrv_extensions: - '7.0': { name: 'sqlsrv-5.3.0', dir: '/usr/lib/php/20151012' } - '7.1': { name: 'sqlsrv-5.6.1', dir: '/usr/lib/php/20160303' } - '7.2': { name: 'sqlsrv-5.8.1', dir: '/usr/lib/php/20170718' } - '7.3': { name: 'sqlsrv-5.9.0', dir: '/usr/lib/php/20180731' } - '7.4': { name: 'sqlsrv', dir: '/usr/lib/php/20190902' } - '8.0': { name: 'sqlsrv', dir: '/usr/lib/php/20200930' } - '8.1': { name: 'sqlsrv', dir: '/usr/lib/php/20210902' } + '7.0': { name: 'sqlsrv-5.3.0', dir: '/usr/lib/php/20151012' } + '7.1': { name: 'sqlsrv-5.6.1', dir: '/usr/lib/php/20160303' } + '7.2': { name: 'sqlsrv-5.8.1', dir: '/usr/lib/php/20170718' } + '7.3': { name: 'sqlsrv-5.9.0', dir: '/usr/lib/php/20180731' } + '7.4': { name: 'sqlsrv-5.10.1', dir: '/usr/lib/php/20190902' } + '8.0': { name: 'sqlsrv-5.11.1', dir: '/usr/lib/php/20200930' } + '8.1': { name: 'sqlsrv', dir: '/usr/lib/php/20210902' } + '8.2': { name: 'sqlsrv', dir: '/usr/lib/php/20220829' } tasks: - name: 'Install Microsoft ODBC drivers and unixODBC development headers' apt: @@ -101,16 +105,37 @@ - name: Install Composer shell: | + EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - php composer-setup.php - php -r "unlink('composer-setup.php');" + ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + + if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] + then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 + fi + + php composer-setup.php --quiet + rm composer-setup.php mv composer.phar /usr/local/bin/composer args: creates: /usr/local/bin/composer when: not composer_stat_result.stat.exists + - name: 'Check composer22 is installed' + stat: + path: '/usr/local/bin/composer22' + register: composer22_stat_result + + - name: Install Composer 2.2.x for PHP < 7.2.5 + get_url: + url: https://getcomposer.org/download/latest-2.2.x/composer.phar + dest: /usr/local/bin/composer22 + mode: '+x' + when: not composer22_stat_result.stat.exists + - name: Install Blackfire Agent and PHP extensions hosts: localhost become: true diff --git a/ansible/playbooks/ubuntu/12-nodejs.yml b/ansible/playbooks/ubuntu/12-nodejs.yml index 62b7d27..eacc2a2 100644 --- a/ansible/playbooks/ubuntu/12-nodejs.yml +++ b/ansible/playbooks/ubuntu/12-nodejs.yml @@ -3,7 +3,7 @@ vars: version: '{{ nodejs.version|default("lts")|lower }}' version_text: "{% if 'lts' == version %}LTS{% else %}v{{ version }}{% endif %}" - nvm_version: '{{ nodejs.nvm_version|default("0.39.1") }}' + nvm_version: '{{ nodejs.nvm_version|default("0.39.3") }}' tasks: - name: 'Install nvm v{{ nvm_version }}' shell: 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v{{ nvm_version }}/install.sh | bash' diff --git a/ansible/playbooks/ubuntu/13-nginx-compile.yml b/ansible/playbooks/ubuntu/13-nginx-compile.yml index dc97d39..47773c0 100644 --- a/ansible/playbooks/ubuntu/13-nginx-compile.yml +++ b/ansible/playbooks/ubuntu/13-nginx-compile.yml @@ -76,7 +76,9 @@ group: root loop: - /etc/nginx/conf.d + - /usr/lib/nginx/modules - /var/cache/nginx + - /var/log/nginx - name: Compiling Nginx source files command: '{{ playbook_dir }}/scripts/compile-nginx.sh {{ nginx_source_dir }}' diff --git a/ansible/playbooks/ubuntu/scripts/compile-nginx.sh b/ansible/playbooks/ubuntu/scripts/compile-nginx.sh index bf36f23..3760e29 100644 --- a/ansible/playbooks/ubuntu/scripts/compile-nginx.sh +++ b/ansible/playbooks/ubuntu/scripts/compile-nginx.sh @@ -44,7 +44,7 @@ cd "$NGINX_SOURCE_DIR" --with-stream_realip_module \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ - --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' \ + --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC -Wno-error -Wno-deprecated-declarations' \ --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' make diff --git a/ansible/playbooks/ubuntu/tasks/php.yml b/ansible/playbooks/ubuntu/tasks/php.yml index 5970b79..cf779de 100644 --- a/ansible/playbooks/ubuntu/tasks/php.yml +++ b/ansible/playbooks/ubuntu/tasks/php.yml @@ -26,6 +26,7 @@ - 'php{{ php_version }}-mysql' - 'php{{ php_version }}-odbc' - 'php{{ php_version }}-pgsql' + - 'php{{ php_version }}-sqlite3' - 'php{{ php_version }}-redis' - 'php{{ php_version }}-snmp' - 'php{{ php_version }}-soap' diff --git a/configuration/configuration.go b/configuration/configuration.go index 59e3195..27ff9b2 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -92,8 +92,8 @@ func New() *Configuration { return &Configuration{ PHP: confPHP{ Install: true, - Versions: []string{"8.1"}, - DefaultVersion: "8.1", + Versions: []string{"8.2"}, + DefaultVersion: "8.2", EnableService: true, }, Blackfire: confBlackfire{ @@ -108,11 +108,11 @@ func New() *Configuration { NodeJS: confNodeJS{ Install: true, Version: "lts", - NvmVersion: "0.39.1", + NvmVersion: "0.39.3", }, GoLang: confGoLang{ Install: false, - Version: "1.19", + Version: "1.19.7", }, Nginx: confNginx{ Install: true, @@ -145,6 +145,17 @@ func (c *Configuration) OnlyRunExtraAnsiblePlaybooks() bool { return c.onlyRunExtraAnsiblePlaybooks } +func (c *Configuration) Normalize() { + phpVersions := make([]string, 0) + for _, version := range c.PHP.Versions { + if version != c.PHP.DefaultVersion { + phpVersions = append(phpVersions, version) + } + } + phpVersions = append(phpVersions, c.PHP.DefaultVersion) + c.PHP.Versions = phpVersions +} + // Load loads configuration from config.json file. func Load() (c *Configuration, err error) { var content []byte @@ -165,6 +176,8 @@ func Load() (c *Configuration, err error) { } } + c.Normalize() + if content, err = json.MarshalIndent(c, "", " "); nil != err { return nil, err } diff --git a/version/latest b/version/latest index 2bf6ba2..3061e9e 100644 --- a/version/latest +++ b/version/latest @@ -1 +1 @@ -v0.9.7 \ No newline at end of file +v0.12.0 \ No newline at end of file diff --git a/wsl/wsl.go b/wsl/wsl.go index 3a2d3a0..cc38250 100644 --- a/wsl/wsl.go +++ b/wsl/wsl.go @@ -15,6 +15,7 @@ var playbookNames = map[string]string{ "Ubuntu": "ubuntu", "Ubuntu-18.04": "ubuntu", "Ubuntu-20.04": "ubuntu", + "Ubuntu-22.04": "ubuntu", } type WSL struct {