Skip to content

Commit

Permalink
Update redis to 6.0.2, add alternative license file searcher (#539)
Browse files Browse the repository at this point in the history
* Update redis to 6.0.2, add alternative license file searcher

* Update docs about source module
  • Loading branch information
crazywhalecc authored Sep 9, 2024
1 parent c55ccf2 commit ad098d0
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 10 deletions.
7 changes: 5 additions & 2 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,14 @@
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "5.3.7",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": "COPYING"
"path": [
"LICENSE",
"COPYING"
]
}
},
"snappy": {
Expand Down
21 changes: 21 additions & 0 deletions docs/en/develop/source-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,24 @@ When an open source project has multiple licenses, multiple files can be specifi
}
}
```

When the license of an open source project uses different files between versions,
`path` can be used as an array to list the possible license files:

```json
{
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": [
"LICENSE",
"COPYING"
]
}
}
}
```
20 changes: 20 additions & 0 deletions docs/zh/develop/source-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,23 @@ pkg.json 存放的是非源码类型的文件资源,例如 musl-toolchain、UP
}
}
```

当一个开源项目的许可证在不同版本间使用不同的文件,`path` 参数可以使用数组将可能的许可证文件列出:

```json
{
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": [
"LICENSE",
"COPYING"
]
}
}
}
```
2 changes: 1 addition & 1 deletion src/SPC/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.3.3';
public const VERSION = '2.3.4';

public function __construct()
{
Expand Down
14 changes: 10 additions & 4 deletions src/SPC/util/LicenseDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,26 @@ private function getSourceLicenses(string $source_name): iterable
/**
* @throws RuntimeException
*/
private function loadSourceFile(string $source_name, int $index, ?string $in_path, ?string $custom_base_path = null): string
private function loadSourceFile(string $source_name, int $index, null|array|string $in_path, ?string $custom_base_path = null): string
{
if (is_null($in_path)) {
throw new RuntimeException('source [' . $source_name . '] license file is not set, please check config/source.json');
}

if (file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) {
return file_get_contents(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path);
if (!is_array($in_path)) {
$in_path = [$in_path];
}

foreach ($in_path as $item) {
if (file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $item)) {
return file_get_contents(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $item);
}
}

if (file_exists(BUILD_ROOT_PATH . '/source-licenses/' . $source_name . '/' . $index . '.txt')) {
return file_get_contents(BUILD_ROOT_PATH . '/source-licenses/' . $source_name . '/' . $index . '.txt');
}

throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist');
throw new RuntimeException('Cannot find any license file in source [' . $source_name . '] directory!');
}
}
6 changes: 3 additions & 3 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'imap,swoole-hook-sqlite,swoole',
'Windows' => 'igbinary,redis,session',
'Linux', 'Darwin' => 'redis,igbinary',
'Windows' => 'redis,igbinary',
};

// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '',
'Linux', 'Darwin' => 'liblz4',
'Windows' => '',
};

Expand Down

0 comments on commit ad098d0

Please sign in to comment.