Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 7, 2025

This PR implements source provenance documentation for Debian packages by automatically generating debian/README.Debian files that document where each source came from, similar to how RPM specs already include this information as comments.

Problem

RPM packages built with dalec include detailed source provenance documentation in the spec file comments, allowing consumers to understand and reproduce builds. However, Debian packages lacked this same functionality, making it difficult for users to understand the origins of package sources.

Solution

Added automatic generation of debian/README.Debian files during the Debian package build process. The implementation:

  • Leverages existing infrastructure: Uses the existing Source.Doc() method that's already implemented for all source types
  • Provides comprehensive documentation: Supports all source types including git repositories, HTTP archives, Docker images, and inline content
  • Follows Debian conventions: Places documentation in the standard debian/README.Debian location as recommended by Debian packaging guidelines
  • Maintains consistency: Provides similar information to what's already available in RPM specs
  • Optimizes for packages with sources: Only creates README.Debian files when sources are present, avoiding unnecessary files for packages without sources

Example Output

For a package with multiple source types, the generated debian/README.Debian looks like:

myapp for Debian
================

My Application - A sample application built with dalec

Source Provenance
-----------------

This package was built from the following sources:

Source: config.yaml
  Generated from an inline source:
  cat << EOF > config.yaml
  server:
    port: 8080
  EOF
  chmod 644 config.yaml

Source: myapp
  Generated from a git repository:
  Remote: https://github.com/example/myapp.git
  Ref: v1.0.0

Source: vendor-deps.tar.gz
  Generated from a http(s) source:
  URL: https://cdn.example.com/deps/myapp-deps-1.0.0.tar.gz

Implementation Details

  • Added generateReadmeDebian() function in packaging/linux/deb/debroot.go
  • Integrated README.Debian generation into the existing Debroot() function
  • Added comprehensive test coverage for various source types and edge cases
  • Maintains alphabetical source ordering for consistent output
  • Returns nil when no sources are present to avoid creating empty documentation files
  • Zero breaking changes to existing functionality

Fixes #556.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: cpuguy83 <799078+cpuguy83@users.noreply.github.com>
Copilot AI changed the title [WIP] [REQ] [deb] Document source provenance in debian/README.Debian Add source provenance documentation to debian/README.Debian Aug 7, 2025
Copilot AI requested a review from cpuguy83 August 7, 2025 23:07
// GenerateReadmeDebian creates the content for debian/README.Debian that documents
// source provenance, allowing consumers to understand where sources came from.
// This is exported for testing purposes.
func GenerateReadmeDebian(spec *dalec.Spec) []byte {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot Why do we need an exported function?

Co-authored-by: cpuguy83 <799078+cpuguy83@users.noreply.github.com>
fmt.Fprintf(buf, "-----------------\n\n")
fmt.Fprintf(buf, "This package was built from the following sources:\n\n")

if len(spec.Sources) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot this should return before we've written anything and just return a nil slice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in fed46d7. The function now returns nil immediately when there are no sources, avoiding creation of README.Debian file entirely. Updated calling code to handle nil return value and modified tests accordingly.

Co-authored-by: cpuguy83 <799078+cpuguy83@users.noreply.github.com>
@cpuguy83
Copy link
Collaborator

@copilot rebase

@cpuguy83 cpuguy83 closed this Nov 19, 2025
@cpuguy83 cpuguy83 reopened this Nov 19, 2025
"strings"
"testing"

"github.com/Azure/dalec"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot The import path is now github.com/project-dalec/dalec

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.

[REQ] [deb] Document source provenance in debian/README.Debian

2 participants