diff --git a/.github/workflows/test-pack-lib.yml b/.github/workflows/test-pack-lib.yml new file mode 100644 index 00000000..2c9c367c --- /dev/null +++ b/.github/workflows/test-pack-lib.yml @@ -0,0 +1,88 @@ +name: Tests for PHP Pack Lib + +on: + pull_request: + branches: [ "main" ] + paths: + - 'src/**' + - 'config/**' + - '.github/workflows/tests.yml' + - 'bin/**' + - 'composer.json' + - 'box.json' + - '.php-cs-fixer.php' + +permissions: + contents: read + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: "Pack Lib Test (${{ matrix.lib }} for ${{ matrix.os.name }}-${{ matrix.os.arch }})" + runs-on: ${{ matrix.os.runs-on }} + timeout-minutes: 120 + strategy: + matrix: + os: + - runs-on: ubuntu-latest + name: "linux" + arch: "x86_64" + - runs-on: macos-13 + name: "darwin" + arch: "x86_64" + - runs-on: windows-latest + name: "windows" + arch: "x86_64" + - runs-on: macos-14 + name: "darwin" + arch: "aarch64" + lib: + - pkg-config + - zlib + - bzip2 + - gmp + fail-fast: false + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + + - name: "Cache composer packages" + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + # Cache downloaded source + - id: cache-download + uses: actions/cache@v4 + with: + path: downloads + key: pack-lib-dependencies + + - name: "Install Dependencies" + run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - run: bin/spc doctor --auto-fix + + - run: bin/spc download --for-libs=${{ matrix.lib }} --debug --retry=5 --shallow-clone + + - run: bin/spc dev:pack-lib --debug ${{ matrix.lib }} + + - name: "Upload packed lib (${{ matrix.lib }} for ${{ matrix.os.name }}-${{ matrix.os.arch }})" + uses: actions/upload-artifact@v2 + with: + path: dist/${{ matrix.lib }}-${{ matrix.os.arch }}-${{ matrix.os.name }}.tar.gz + name: ${{ matrix.lib }}-${{ matrix.os.arch }}-${{ matrix.os.name }} \ No newline at end of file diff --git a/config/source.json b/config/source.json index af82b9ef..f3814324 100644 --- a/config/source.json +++ b/config/source.json @@ -38,6 +38,7 @@ "type": "filelist", "url": "https://sourceware.org/pub/bzip2/", "regex": "/href=\"(?bzip2-(?[^\"]+)\\.tar\\.gz)\"/", + "provide-pre-built": true, "license": { "type": "text", "text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved. \n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement." @@ -182,6 +183,7 @@ "gmp": { "type": "url", "url": "https://dl.static-php.dev/static-php-cli/deps/gmp/gmp-6.3.0.tar.xz", + "provide-pre-built": true, "alt": { "type": "ghtagtar", "repo": "alisw/GMP" diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 32085567..363fe344 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -404,7 +404,7 @@ class Downloader $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; } // If lock file exists, skip downloading - if (isset($lock[$name]) && !$force) { + if (isset($lock[$name]) && !$force && ($lock[$name]['lock_as'] ?? SPC_LOCK_SOURCE) === $lock_as) { if ($lock[$name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename'])) { logger()->notice("source [{$name}] already downloaded: " . $lock[$name]['filename']); return;