Skip to content

Ship initrd.img in MSI using build-time generation via powershell script#14424

Merged
benhillis merged 6 commits intomasterfrom
user/benhill/build-time-initrd
Mar 13, 2026
Merged

Ship initrd.img in MSI using build-time generation via powershell script#14424
benhillis merged 6 commits intomasterfrom
user/benhill/build-time-initrd

Conversation

@benhillis
Copy link
Member

@benhillis benhillis commented Mar 12, 2026

Replace the install-time CreateInitrd/RemoveInitrd custom actions with a build-time step that generates initrd.img using the a powershell script and ships it directly in the MSI.

Changes:

  • Add CMake custom command to generate initrd.img via a powershell script
  • Add initrd.img as a regular file in the MSI tools component
  • Remove CreateInitrd/RemoveInitrd custom actions from WiX, DllMain, and wslinstall.def
  • Remove CreateCpioInitrd helper and its tests (no longer needed)
  • Update pipeline build targets to build initramfs instead of init

Replace the install-time CreateInitrd/RemoveInitrd custom actions with a
build-time step that generates initrd.img using the Windows built-in
tar.exe (libarchive/bsdtar) and ships it directly in the MSI.

The install-time approach had a race condition: wsl.exe could launch
before the CreateInitrd custom action completed, causing
ERROR_FILE_NOT_FOUND for initrd.img.

Changes:
- Add CMake custom command to generate initrd.img via tar.exe --format=newc
- Add initrd.img as a regular file in the MSI tools component
- Remove CreateInitrd/RemoveInitrd custom actions from WiX, DllMain,
  and wslinstall.def
- Remove CreateCpioInitrd helper and its tests (no longer needed)
- Update pipeline build targets to build initramfs instead of init
OneBlue
OneBlue previously approved these changes Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR shifts initrd.img handling from an MSI installer-time custom action to a build-time generated artifact that is shipped directly in the MSI, removing the associated helper implementation and tests.

Changes:

  • Generate initrd.img during the Linux init build via a new initramfs CMake target and include it in MSI packaging.
  • Remove installer custom actions/exports (CreateInitrd/RemoveInitrd) and the Windows-side CreateCpioInitrd helper.
  • Remove test coverage that previously validated initrd creation and lifecycle behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/linux/init/CMakeLists.txt Adds initramfs target to generate initrd.img via tar.exe --format=newc.
msipackage/CMakeLists.txt Adds initrd.img to MSI inputs and makes msipackage depend on initramfs.
msipackage/package.wix.in Ships initrd.img as a file in the tools component; removes related custom actions.
src/windows/wslinstall/DllMain.cpp Removes MSI custom action implementations for initrd create/remove.
src/windows/wslinstall/wslinstall.def Removes exported symbols for initrd create/remove actions.
src/windows/common/filesystem.hpp Removes CreateCpioInitrd declaration.
src/windows/common/filesystem.cpp Removes CreateCpioInitrd implementation.
test/windows/SimpleTests.cpp Removes unit test for CreateCpioInitrd.
test/windows/InstallerTests.cpp Removes installer lifecycle test for initrd.img.
.pipelines/build-stage.yml Updates pipeline target list to build initramfs instead of init.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 12, 2026 00:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

test/windows/InstallerTests.cpp:499

  • The PR removes the InitrdImgLifecycle installer test, but the change also makes initrd.img a required packaged artifact (built during initramfs and shipped in the MSI). With this test gone, there doesn’t appear to be any remaining validation that tools\\initrd.img is actually installed (and removed) as expected. Consider adding a lightweight check (e.g., existence + non-empty) as part of the install validation to keep coverage for this critical boot dependency.
    TEST_METHOD(UpgradeInstallsTheMsiPackage)
    {
        // Remove the MSIX package
        UninstallMsix();
        VERIFY_IS_FALSE(IsMsixInstalled());

        // Validate that upgrading the MSI installs the MSIX again
        InstallMsi();
        VERIFY_IS_TRUE(IsMsiPackageInstalled());
        VERIFY_IS_TRUE(IsMsixInstalled());
        VERIFY_IS_FALSE(IsMsixInstallerInstalled());
        ValidatePackageInstalledProperly();

You can also share your feedback on Copilot code review. Take the survey.

@benhillis benhillis changed the title Ship initrd.img in MSI using build-time generation via tar.exe Ship initrd.img in MSI using build-time generation via powershell script Mar 12, 2026
@benhillis benhillis requested a review from Copilot March 12, 2026 06:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

}
finally
{
$out.Close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed ? The script would exit either way right ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, probably not needed, but also not harmful

@benhillis benhillis merged commit e5cb458 into master Mar 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants