dalec icon indicating copy to clipboard operation
dalec copied to clipboard

Add PackageFiles support for make install workflows

Open Copilot opened this issue 6 months ago • 1 comments

This PR adds support for projects that use make install or similar installation commands to place artifacts, addressing the need for a simpler way to specify package contents without manually categorizing every file.

Problem

Previously, dalec required explicitly categorizing artifacts into specific types (binaries, manpages, config files, etc.). This worked well for projects that manually copy specific files, but was cumbersome for projects using standard installation mechanisms like make install. Users had to list every single file individually in the artifacts section because of the requirement to list files in the %files directive in RPM specs.

Solution

This PR introduces a new package_files field in the Artifacts struct that allows specifying package-specific file listings directly, letting projects use their native installation commands while still providing the necessary file lists for package creation.

Usage Example

build:
  steps:
    - command: |
        cd src
        make all
        make install DESTDIR=%{buildroot}

artifacts:
  package_files:
    rpm: |
      %{_bindir}/myapp
      %{_includedir}/myapp.h
      %{_mandir}/man1/myapp.1*

Key Features

  • Native Installation Support: Works seamlessly with make install, autotools, cmake, and other standard build systems
  • Package Format Flexibility: Supports different file listing formats for different package types (RPM, DEB, etc.)
  • Backward Compatible: Existing specs continue to work unchanged; this is an opt-in feature
  • Template Integration: RPM spec generation automatically uses custom file listings when available, falling back to traditional artifact categorization

Implementation Details

  • Added PackageFiles map[string]string field to Artifacts struct
  • Modified RPM template to use custom file listings when present
  • Updated IsEmpty() method to consider the new field
  • Maintained full backward compatibility with existing artifact specifications

Testing

  • Comprehensive unit tests for RPM template integration
  • Integration tests for complete spec generation
  • YAML parsing and loading tests
  • Working example fixture demonstrating real-world usage
  • All existing tests continue to pass

This simplifies builds for projects following standard installation patterns while providing the fine-grained control needed for package creation.

Fixes #614.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Aug 07 '25 22:08 Copilot

@cpuguy83 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot avatar Aug 07 '25 22:08 Copilot