Skip to content

feat(source-files): add custom origin type for mock-based source generation#261

Open
Tonisal-byte wants to merge 2 commits into
microsoft:mainfrom
Tonisal-byte:asalinas/custom-mock-generate-origin
Open

feat(source-files): add custom origin type for mock-based source generation#261
Tonisal-byte wants to merge 2 commits into
microsoft:mainfrom
Tonisal-byte:asalinas/custom-mock-generate-origin

Conversation

@Tonisal-byte

@Tonisal-byte Tonisal-byte commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Introduces a new origin.type = "custom" for component source-files entries. Instead of downloading a pre-built artifact, azldev runs a user-supplied shell script inside a fresh mock chroot and packages the output directory as a deterministic archive.

Example:

[[components.yara.source-files]]
filename         = "yara-4.5.4.tar.gz"
origin           = { type = "custom" }
script           = "modify_source.sh"
mock-packages    = ["curl", "tar", "gzip", "coreutils"]
hash-type        = "SHA512"
hash             = "somehash"

Script contract: the script must write all desired archive contents to /azldev-gen/output/. azldev mounts the script read-only at /azldev-gen/script/ and the output directory read-write at /azldev-gen/output/, then packages the output into the declared filename using CreateDeterministicArchive.

Example:

echo "[N/N] Repacking deterministically as ${MODIFIED_NAME}"
# azldev packages /azldev-gen/output/ into a deterministic archive.
# Place the stripped source tree there so the archive contains the same
# yara-4.5.4/ top-level directory the upstream tarball had.
mv "${EXTRACTED_DIRNAME}" "/azldev-gen/output/${EXTRACTED_DIRNAME}"

Copilot AI review requested due to automatic review settings June 30, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new origin.type = "custom" mode for source-files entries, enabling azldev to generate a source artifact by running a user-provided script inside a fresh mock chroot and then packaging /azldev-gen/output as a deterministic archive.

Changes:

  • Extend project config/schema to support origin.type = "custom" plus script and mock-packages, with validation.
  • Add a new file-source provider that runs the script in mock and archives its output deterministically.
  • Extend the mock runner API (CmdInChroot) to optionally pipe output directly to the user and update call sites.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
schemas/azldev.schema.json Adds custom origin enum + script/mock-packages fields to the JSON schema.
scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap Updates schema snapshot output for the new fields.
scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap Updates schema snapshot output for the new fields.
internal/rpm/mock/mock.go Adds pipeOutput support to Runner.CmdInChroot for real-time output passthrough.
internal/rpm/mock/mock_test.go Updates tests for the new CmdInChroot signature.
internal/providers/sourceproviders/sourcemanager.go Introduces FileSourceProvider dispatch, ErrNotFound, and custom-origin handling/fallback behavior.
internal/providers/sourceproviders/customsourceprovider.go Implements custom-origin source generation via mock + deterministic archiving.
internal/providers/sourceproviders/customsourceprovider_internal_test.go Adds unit tests for custom provider helpers and validation behavior.
internal/projectconfig/configfile.go Adds validation rules for custom origin (script, mock-packages, and rejecting uri).
internal/projectconfig/configfile_test.go Adds validation test coverage for the new custom-origin rules.
internal/projectconfig/component.go Adds OriginTypeCustom, script, mock-packages, and HashInclude behavior for fingerprinting.
internal/buildenv/mockroot.go Updates CmdInChroot call to pass pipeOutput=false.
internal/app/azldev/core/sources/mockprocessor.go Updates CmdInChroot call to pass pipeOutput=false.
internal/app/azldev/cmds/component/preparesources.go Refactors preparer option assembly; notes custom origin is auto-enabled when mock-config exists.
internal/app/azldev/cmds/advanced/mock.go Updates CmdInChroot call to pass pipeOutput=false.

Comment thread internal/providers/sourceproviders/sourcemanager.go
Comment thread internal/providers/sourceproviders/sourcemanager.go
Comment thread internal/projectconfig/component.go
Comment thread internal/providers/sourceproviders/customsourceprovider.go
Comment thread internal/providers/sourceproviders/customsourceprovider.go Outdated
Comment thread internal/providers/sourceproviders/customsourceprovider.go Outdated
Copilot AI review requested due to automatic review settings July 1, 2026 18:13
@Tonisal-byte Tonisal-byte force-pushed the asalinas/custom-mock-generate-origin branch from 1b56d46 to 24c1de2 Compare July 1, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 16 out of 16 changed files in this pull request and generated 3 comments.

Comment thread internal/providers/sourceproviders/customsourceprovider.go
Comment thread internal/providers/sourceproviders/customsourceprovider.go
Comment thread internal/app/azldev/cmds/advanced/mock.go
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.

2 participants