Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

This PR implements RPM and DEB package creation support for DSC, addressing issue #1200.

Overview

The build system now supports creating RPM and DEB packages for Linux distributions using the -packageType rpm or -packageType deb parameters. This enables easier installation and distribution of DSC on both RPM-based Linux systems (like Fedora, RHEL, SUSE) and Debian-based systems (like Ubuntu, Debian).

Changes

build.ps1

  • Added 'rpm' and 'deb' as valid options for the -packageType parameter
  • Implemented comprehensive RPM packaging logic that:
    • Validates platform requirements (Linux only)
    • Checks for rpmbuild availability with helpful error messages
    • Creates standard RPM build directory structure (BUILD, RPMS, SOURCES, SPECS, SRPMS)
    • Stages Linux package files from the build output
    • Maps Rust target architectures to RPM architectures (musl/gnu → x86_64/aarch64)
    • Supports 'current' architecture auto-detection using uname -m
    • Processes the spec file template with version and architecture substitution
    • Builds the RPM using rpmbuild
    • Copies the final package to the bin directory
  • Implemented comprehensive DEB packaging logic that:
    • Validates platform requirements (Linux only)
    • Checks for dpkg-deb availability with helpful error messages
    • Creates standard Debian package directory structure (DEBIAN, opt/dsc, usr/bin)
    • Stages Linux package files from the build output
    • Maps Rust target architectures to DEB architectures (musl/gnu → amd64/arm64)
    • Supports 'current' architecture auto-detection using uname -m
    • Processes the control file template with version and architecture substitution
    • Builds the DEB using dpkg-deb
    • Moves the final package to the bin directory

packaging/rpm/dsc.spec

  • Created new RPM specification file following standard format
  • Uses environment variables ($RPM_BUILD_ROOT, $RPM_SOURCE_DIR) instead of macros to ensure compatibility across all RPM-based distributions, not just RedHat/Fedora
  • Installs DSC to /opt/dsc with a symlink at /usr/bin/dsc for easy access
  • Includes proper metadata: Name, Version, License (MIT), URL, Summary, Description
  • Documents initial release in changelog

packaging/deb/control

  • Created new Debian control file following standard format
  • Includes proper metadata: Package, Version, Section, Priority, Architecture, Maintainer, Homepage, Description
  • Installs DSC to /opt/dsc with a symlink at /usr/bin/dsc for easy access (same as RPM)

Usage

# First build the binaries for your target architecture
./build.ps1 -Release -architecture x86_64-unknown-linux-musl

# Then create the RPM package with specific architecture
./build.ps1 -packageType rpm -architecture x86_64-unknown-linux-musl

# Or create the DEB package with specific architecture
./build.ps1 -packageType deb -architecture x86_64-unknown-linux-musl

# Or use 'current' to auto-detect the system architecture
./build.ps1 -packageType rpm -architecture current
./build.ps1 -packageType deb -architecture current

The RPM will be created in the bin/ directory as dsc-<version>-1.<arch>.rpm
The DEB will be created in the bin/ directory as dsc_<version>-1_<arch>.deb

Supported Architectures

RPM:

  • x86_64 (via x86_64-unknown-linux-musl or x86_64-unknown-linux-gnu)
  • aarch64 (via aarch64-unknown-linux-musl or aarch64-unknown-linux-gnu)
  • current (auto-detects and maps to x86_64 or aarch64)

DEB:

  • amd64 (via x86_64-unknown-linux-musl or x86_64-unknown-linux-gnu)
  • arm64 (via aarch64-unknown-linux-musl or aarch64-unknown-linux-gnu)
  • current (auto-detects and maps to amd64 or arm64)

Installation

Users can install the RPM package using:

sudo rpm -i dsc-<version>-1.<arch>.rpm
# Or with package managers
sudo dnf install dsc-<version>-1.<arch>.rpm

Users can install the DEB package using:

sudo dpkg -i dsc_<version>-1_<arch>.deb
# Or with package managers
sudo apt install ./dsc_<version>-1_<arch>.deb

Testing

  • PowerShell syntax validation: ✅ Passed
  • Parameter validation: ✅ Confirmed 'rpm' and 'deb' are accepted
  • CodeQL security scan: ✅ No issues found

This implementation follows the same patterns as the existing tgz packaging, ensuring consistency and maintainability.

Fixes #1200

Original prompt

This section details on the original issue you should resolve

<issue_title>Create RPM package</issue_title>
<issue_description>### Summary of the new feature / enhancement

Update build.ps1 with new parameter value rpm for the -packageType parameter. Create a RPMSPEC file in the repo under a new rpm folder under packaging folder. Don't assume using RedHat Linux therefore don't use any macros that may not exist.

Proposed technical implementation details (optional)

No response</issue_description>

<agent_instructions>Follow the instructions in the summary of the issue</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1200


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

Copilot AI and others added 2 commits October 22, 2025 18:13
Co-authored-by: SteveL-MSFT <11859881+SteveL-MSFT@users.noreply.github.com>
…c dependencies

Co-authored-by: SteveL-MSFT <11859881+SteveL-MSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Add RPM package creation functionality Add RPM package support to build system Oct 22, 2025
Copilot AI requested a review from SteveL-MSFT October 22, 2025 18:18
Copilot finished work on behalf of SteveL-MSFT October 22, 2025 18:18
@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review October 22, 2025 18:19
@SteveL-MSFT SteveL-MSFT requested a review from Copilot October 22, 2025 18: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

This PR adds RPM package creation support to the build system, enabling DSC distribution on RPM-based Linux systems. The implementation follows the existing tgz packaging pattern and includes proper validation and error handling.

Key Changes:

  • Added rpm as a valid package type option with comprehensive build logic
  • Created RPM spec file using environment variables for broad distribution compatibility
  • Implemented architecture mapping from Rust targets to RPM architectures

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
build.ps1 Added RPM package type validation and complete packaging logic including platform checks, directory structure creation, and rpmbuild integration
packaging/rpm/dsc.spec New RPM specification file defining package metadata, installation paths, and file listings using environment variables for compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@SteveL-MSFT
Copy link
Member

@copilot do the same changes to support deb packages

Co-authored-by: SteveL-MSFT <11859881+SteveL-MSFT@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 22, 2025

@copilot do the same changes to support deb packages

DEB package support has been added in commit 03a0eb0. The implementation follows the same pattern as RPM packaging:

  • Added 'deb' to the packageType parameter
  • Created packaging/deb/control file with Debian package metadata
  • Implemented build logic that creates DEB packages with dpkg-deb
  • Supports amd64 and arm64 architectures
  • Installs to /opt/dsc with symlink at /usr/bin/dsc

Usage:

./build.ps1 -packageType deb -architecture x86_64-unknown-linux-musl

Copilot AI changed the title Add RPM package support to build system Add RPM and DEB package support to build system Oct 22, 2025
Copilot finished work on behalf of SteveL-MSFT October 22, 2025 22:27
Copilot AI requested a review from SteveL-MSFT October 22, 2025 22:27
Co-authored-by: SteveL-MSFT <11859881+SteveL-MSFT@users.noreply.github.com>
Copilot finished work on behalf of SteveL-MSFT October 22, 2025 22:32
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.

Create RPM package

2 participants