Skip to content

Commit a79564f

Browse files
committed
Fix docker doctor fix pkgroot volume overwrite bug
1 parent 38ec03f commit a79564f

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

bin/spc-alpine-docker

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
# This file is using docker to run commands
6-
SPC_DOCKER_VERSION=v5
6+
SPC_DOCKER_VERSION=v6
77

88
# Detect docker can run
99
if ! which docker >/dev/null; then
@@ -122,6 +122,9 @@ ADD ./src /app/src
122122
COPY ./composer.* /app/
123123
ADD ./bin /app/bin
124124
RUN composer install --no-dev
125+
ADD ./config /app/config
126+
RUN PKG_ROOT_PATH=/app/pkgroot-private bin/spc doctor --auto-fix
127+
RUN PKG_ROOT_PATH=/app/pkgroot-private bin/spc install-pkg upx
125128
EOF
126129
fi
127130

bin/spc-gnu-docker

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
# This file is using docker to run commands
6-
SPC_DOCKER_VERSION=v5
6+
SPC_DOCKER_VERSION=v6
77

88
# Detect docker can run
99
if ! which docker >/dev/null; then
@@ -112,7 +112,8 @@ ENV SPC_LIBC=glibc
112112
ENV PATH="/app/bin:/cmake/bin:/opt/rh/devtoolset-10/root/usr/bin:\$PATH"
113113
114114
ADD ./config /app/config
115-
RUN CC=gcc bin/spc doctor --auto-fix --debug
115+
RUN CC=gcc PKG_ROOT_PATH=/app/pkgroot-private bin/spc doctor --auto-fix --debug
116+
RUN PKG_ROOT_PATH=/app/pkgroot-private bin/spc install-pkg upx
116117
RUN if [ -f /app/buildroot/bin/re2c ]; then \
117118
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
118119
fi

src/SPC/doctor/item/PkgConfigCheck.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ public function checkPkgConfig(): CheckResult
2929
return CheckResult::ok($pkgconf);
3030
}
3131

32+
#[AsCheckItem('if pkg-config is working', level: 799)]
33+
public function checkPkgConfigFunctional(): CheckResult
34+
{
35+
$pkgconf = PkgConfigUtil::findPkgConfig();
36+
// check if pkg-config is functional
37+
[$ret, $output] = shell()->execWithResult("{$pkgconf} --version", false);
38+
if ($ret === 0) {
39+
return CheckResult::ok(implode(' ', $output));
40+
}
41+
return CheckResult::fail('pkg-config is not functional', 'install-pkgconfig');
42+
}
43+
3244
#[AsFixItem('install-pkgconfig')]
3345
public function installPkgConfig(): bool
3446
{

src/SPC/util/GlobalEnvManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public static function init(): void
4040
if (is_unix()) {
4141
self::addPathIfNotExists(BUILD_BIN_PATH);
4242
self::addPathIfNotExists(PKG_ROOT_PATH . '/bin');
43+
// internally use `WORKING_DIR/pkgroot-private` to avoid volume mount issues in Docker
44+
if (is_dir(WORKING_DIR . '/pkgroot-private/bin')) {
45+
self::addPathIfNotExists(WORKING_DIR . '/pkgroot-private/bin');
46+
}
4347
self::putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
4448
}
4549

src/SPC/util/PkgConfigUtil.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static function findPkgConfig(): ?string
2323
{
2424
// Find pkg-config executable
2525
$find_list = [
26+
WORKING_DIR . '/pkgroot-private/bin/pkg-config', // used in Docker build, which is installed inside the container to avoid volume mounting issues
2627
PKG_ROOT_PATH . '/bin/pkg-config',
2728
BUILD_BIN_PATH . '/pkg-config',
2829
];

0 commit comments

Comments
 (0)