From 42534e9fae9b57362345a8a523868435235791f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 24 Jul 2026 08:25:20 -0400 Subject: [PATCH 1/2] Fix sysroot recipe builds Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- cbake.psm1 | 7 +++++++ recipes/debian-10/Dockerfile | 7 +++++-- recipes/rhel8/Dockerfile | 2 +- tests/CBake.Tests.ps1 | 13 +++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cbake.psm1 b/cbake.psm1 index de6ef17..fa192b5 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -106,6 +106,9 @@ function Remove-CBakeExcludedFiles() { $ExcludeDirs | ForEach-Object { $ExcludeDir = Join-Path $RootPath $_.TrimStart('/', '\') + if ($IsLinux -and (Test-Path -LiteralPath $ExcludeDir)) { + Invoke-CBakeNativeCommand -FilePath 'chmod' -ArgumentList @('-R', 'u+w', '--', $ExcludeDir) + } Remove-Item -LiteralPath $ExcludeDir -Recurse -Force -ErrorAction 'SilentlyContinue' | Out-Null } } @@ -117,6 +120,10 @@ function Optimize-CBakeSysroot() { [string] $RootPath ) + if ($IsLinux) { + Invoke-CBakeNativeCommand -FilePath 'chmod' -ArgumentList @('-R', 'u+w', '--', $RootPath) + } + Convert-CBakeSymbolicLinks $RootPath Remove-CBakeExcludedFiles $RootPath diff --git a/recipes/debian-10/Dockerfile b/recipes/debian-10/Dockerfile index e947eb0..3d8a11c 100644 --- a/recipes/debian-10/Dockerfile +++ b/recipes/debian-10/Dockerfile @@ -2,8 +2,11 @@ FROM debian:buster-slim ARG DEBIAN_FRONTEND=noninteractive -RUN sed -i 's/deb.debian.com/debian.mirrors.ovh.net/g' /etc/apt/sources.list -RUN apt-get update -y +RUN printf '%s\n' \ + 'deb http://archive.debian.org/debian buster main' \ + 'deb http://archive.debian.org/debian-security buster/updates main' \ + > /etc/apt/sources.list +RUN apt-get -o Acquire::Check-Valid-Until=false update -y RUN apt-get install --no-install-recommends -y \ gcc \ diff --git a/recipes/rhel8/Dockerfile b/recipes/rhel8/Dockerfile index 9e7c5d0..fb1344c 100644 --- a/recipes/rhel8/Dockerfile +++ b/recipes/rhel8/Dockerfile @@ -4,7 +4,7 @@ RUN yum update -y RUN yum install -y \ gcc \ - g++ \ + gcc-c++ \ zlib-devel \ openssl-devel \ pam \ diff --git a/tests/CBake.Tests.ps1 b/tests/CBake.Tests.ps1 index fde2186..488bd88 100644 --- a/tests/CBake.Tests.ps1 +++ b/tests/CBake.Tests.ps1 @@ -96,6 +96,19 @@ Describe 'Remove-CBakeExcludedFiles' { Test-Path -LiteralPath $ExcludedPath | Should -BeFalse } + + It 'removes read-only excluded directories on Linux' -Skip:(-not $IsLinux) { + $RootPath = Join-Path $TestDrive 'sysroot' + $ExcludedPath = Join-Path $RootPath 'usr\bin' + $ExcludedFile = Join-Path $ExcludedPath 'tool' + New-Item -Path $ExcludedPath -ItemType Directory -Force | Out-Null + New-Item -Path $ExcludedFile -ItemType File -Force | Out-Null + & chmod 'a-w' $ExcludedPath + + Remove-CBakeExcludedFiles $RootPath + + Test-Path -LiteralPath $ExcludedPath | Should -BeFalse + } } Describe 'Invoke-CBakeNativeCommand' { From 58294eb59bf5f9755541e6b8aad8063ef852950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 24 Jul 2026 08:38:19 -0400 Subject: [PATCH 2/2] Handle read-only sysroot symlinks Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- cbake.psm1 | 12 ++++++++++-- tests/CBake.Tests.ps1 | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cbake.psm1 b/cbake.psm1 index fa192b5..03adb6d 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -18,14 +18,22 @@ function Convert-CBakeSymbolicLinks() { $Target = Join-Path $RootPath $_.LinkTarget.TrimStart('/') if (Test-Path -LiteralPath $Target) { $RelativeTarget = [IO.Path]::GetRelativePath($Directory, $Target) - Remove-Item -LiteralPath $Source | Out-Null + if ($IsLinux) { + Invoke-CBakeNativeCommand -FilePath 'rm' -ArgumentList @('-f', '--', $Source) + } else { + Remove-Item -LiteralPath $Source | Out-Null + } if ($IsDirectory) { [IO.Directory]::CreateSymbolicLink($Source, $RelativeTarget) | Out-Null } else { [IO.File]::CreateSymbolicLink($Source, $RelativeTarget) | Out-Null } } else { - Remove-Item -LiteralPath $Source -ErrorAction 'SilentlyContinue' | Out-Null + if ($IsLinux) { + Invoke-CBakeNativeCommand -FilePath 'rm' -ArgumentList @('-f', '--', $Source) + } else { + Remove-Item -LiteralPath $Source -ErrorAction 'SilentlyContinue' | Out-Null + } } } } diff --git a/tests/CBake.Tests.ps1 b/tests/CBake.Tests.ps1 index 488bd88..eb4edc6 100644 --- a/tests/CBake.Tests.ps1 +++ b/tests/CBake.Tests.ps1 @@ -71,6 +71,19 @@ Describe 'Convert-CBakeSymbolicLinks' { $Link.LinkTarget | Should -Be 'target' $Link.ResolveLinkTarget($true).FullName | Should -Be $TargetPath } + + It 'converts symlinks from a read-only sysroot on Linux' -Skip:(-not $IsLinux) { + $RootPath = Join-Path $TestDrive 'sysroot' + $TargetPath = Join-Path $RootPath 'target' + $SourcePath = Join-Path $RootPath 'link' + New-Item -Path $TargetPath -ItemType Directory -Force | Out-Null + [IO.Directory]::CreateSymbolicLink($SourcePath, '/target') | Out-Null + & chmod 'a-w' $RootPath + + Optimize-CBakeSysroot $RootPath + + (Get-Item -LiteralPath $SourcePath).LinkTarget | Should -Be 'target' + } } Describe 'Remove-CBakeExcludedFiles' {