From c3ef22a8b2cafd42209159f25c751499a2b6b0ab Mon Sep 17 00:00:00 2001 From: Allan Zhang <6740989+allan2@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:42:40 -0500 Subject: [PATCH 1/3] build: add changelogs for Linux packaging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit: - adds an upstream changelog to Debian and RPM packages - populates the packaging changelog for Debian (previously included but empty) - adds the packaging changelog for RPM Upstream changelogs are generated from the root CHANGELOG.md. Change notes for all products are included in each upstream changelog. Packaging changelogs are created in product folders within `package`. More details are found in the comments of `ci/linux-changelog.ps1`. Some additional changes are made for compliance: - Benoît is listed as the packager - revision number changed from `.0` to `.1` - this affects the names of the generated assets - `devolutions-agent_2024.3.6.0_amd64.deb` -> `devolutions-agent_2024.3.6-1_amd64.deb` - Debian changelog urgency changed from `low` to `medium` - `medium` is the standard value These small fixes are also included: - `dh_compress` level changed from 9 to 10 - this is to fix a warning; levels before 10 are deprecated - fixed a date format typo in root CHANGELOG.md Issue: DGW-237 --- CHANGELOG.md | 2 +- ci/linux-changelog.Tests.ps1 | 223 +++++++++++++ ci/linux-changelog.ps1 | 398 ++++++++++++++++++++++++ ci/tlk.ps1 | 80 +++-- package/AgentLinux/CHANGELOG.md | 5 + package/AgentLinux/agent/template/rules | 4 +- package/AgentLinux/template/changelog | 6 - package/AgentLinux/template/copyright | 9 - package/Linux/CHANGELOG.md | 5 + package/Linux/gateway/template/rules | 2 + package/Linux/template/changelog | 6 - 11 files changed, 699 insertions(+), 41 deletions(-) create mode 100644 ci/linux-changelog.Tests.ps1 create mode 100644 ci/linux-changelog.ps1 create mode 100644 package/AgentLinux/CHANGELOG.md delete mode 100644 package/AgentLinux/template/changelog delete mode 100644 package/AgentLinux/template/copyright create mode 100644 package/Linux/CHANGELOG.md delete mode 100644 package/Linux/template/changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e05a6214..6a1ab328b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ This document provides a list of notable changes introduced in Devolutions Gatew - _webapp_: the initial 401 error is shown when it should not ([#1102](https://github.com/Devolutions/devolutions-gateway/issues/1102)) ([b54a666776](https://github.com/Devolutions/devolutions-gateway/commit/b54a666776420106bb694d08700e7ae234b9ab51)) ([DGW-226](https://devolutions.atlassian.net/browse/DGW-226)) -## 2024.3.4 (2024-11-8) +## 2024.3.4 (2024-11-08) ### Features diff --git a/ci/linux-changelog.Tests.ps1 b/ci/linux-changelog.Tests.ps1 new file mode 100644 index 000000000..7c84aa090 --- /dev/null +++ b/ci/linux-changelog.Tests.ps1 @@ -0,0 +1,223 @@ +BeforeAll { + . $PSScriptRoot/linux-changelog.ps1 +} + +Describe 'Format-EntryLine' { + It 'Removes markdown links enclosed in parantheses' { + $Input = '([foo](http://foo.example))' + $Expected = '' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes links' { + $Input = '[foo](http://foo.example)' + $Expected = '' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes bold formatting' { + $Input = '**foo**' + $Expected = 'foo' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes italics (underscore)' { + $Input = '_foo_' + $Expected = 'foo' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes italics (asterisk)' { + $Input = '*foo*' + $Expected = 'foo' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes monospace' { + $Input = '`foo`' + $Expected = 'foo' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } + + It 'Removes blockquote marker' { + $Input = '> foo' + $Expected = 'foo' + $Actual = Format-EntryLine -Line $Input + $Actual | Should -Be $Expected + } +} + +Describe 'Format-DebEntry' { + It 'Formats a CHANGELOG.md entry into an Debian format' { + $Version = '0.1.0' + $Date = '2025-01-01' + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + $PackageName = 'my-package' + $Distro = 'focal' + $Body = " * Bug fixes`n" # body already formatted + + $Expected = @" +my-package (0.1.0-1) focal; urgency=medium + + * Bug fixes + + -- Maurice Wed, 01 Jan 2025 00:00:00 +0000 +"@ + + $Actual = Format-DebEntry -Version $Version -Date $Date -Packager $Packager -Email $Email -PackageName $PackageName -Distro $Distro -Body $Body + $Actual | Should -Be $Expected + } +} + +Describe 'Format-RpmUpstreamEntry' { + It 'Formats a CHANGELOG.md entry into an upstream RPM entry' { + $Version = '0.1.0' + $Date = '2025-01-01' + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + $Body = "* Bug fixes`n" # body already formatted + + $Expected = @" +0.1.0 (2025-01-01) Maurice + +* Bug fixes +"@ + + $Actual = Format-RpmUpstreamEntry -Version $Version -Date $Date -Packager $Packager -Email $Email -Body $Body + $Actual | Should -Be $Expected + } +} + +Describe 'Format-RpmPackagingEntry' { + It 'Formats a CHANGELOG.md entry into a packaging RPM entry' { + $Version = '0.1.0' + $Date = '2025-01-01' + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + $Body = "- Removed dependency`n" # body already formatted + + $Expected = @" +* Wed Jan 01 00:00:00 2025 Maurice - 0.1.0-1 +- Removed dependency +"@ + + $Actual = Format-RpmPackagingEntry -Version $Version -Date $Date -Packager $Packager -Email $Email -Body $Body + $Actual | Should -Be $Expected + } +} + + +Describe 'New-UpstreamChangelog' { + BeforeEach { + $tmpfile = New-TemporaryFile + Set-Content -Path $tmpfile.FullName -Value @" +## 0.2.0 (2025-01-01) + +### Features +- abc + - abcabc + +### Bug Fixes +- def + +## 0.1.0 (2024-01-01) +- ghi +"@ + } + + AfterEach { + # clean up + Remove-Item -Path $tmpfile.FullName -Force + } + + It 'Generates a Debian upstream changelog' { + $Date = '2025-01-01' + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + $PackageName = 'my-package' + $Distro = 'focal' + + $Actual = New-Changelog ` + -Format 'Deb' ` + -InputFile $tmpfile.FullName ` + -Packager $Packager ` + -Email $Email ` + -PackageName $PackageName ` + -Distro $Distro + + $Expected = @" +my-package (0.2.0-1) focal; urgency=medium + + * Features + - abc + - abcabc + * Bug Fixes + - def + + -- Maurice Wed, 01 Jan 2025 00:00:00 +0000 + +my-package (0.1.0-1) focal; urgency=medium + + * ghi + + -- Maurice Mon, 01 Jan 2024 00:00:00 +0000 +"@ + + $Actual | Should -Be $Expected + } + + It 'Generates an RPM upstream changelog' { + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + + $Actual = New-Changelog ` + -Format 'RpmUpstream' ` + -InputFile $tmpfile.FullName ` + -Packager $Packager ` + -Email $Email + + $Expected = @" +0.2.0 (2025-01-01) Maurice + +* abc + - abcabc +* def + +0.1.0 (2024-01-01) Maurice + +* ghi +"@ + + $Actual | Should -Be $Expected + } + + It 'Generates an RPM packaging changelog' { + $Packager = 'Maurice' + $Email = 'maurice@foo.example' + + $Actual = New-Changelog ` + -Format 'RpmPackaging' ` + -InputFile $tmpfile.FullName ` + -Packager $Packager ` + -Email $Email + + $Expected = @" +* Wed Jan 01 00:00:00 2025 Maurice - 0.2.0-1 +- abc +- abcabc +- def + +* Mon Jan 01 00:00:00 2024 Maurice - 0.1.0-1 +- ghi +"@ + + $Actual | Should -Be $Expected + } +} diff --git a/ci/linux-changelog.ps1 b/ci/linux-changelog.ps1 new file mode 100644 index 000000000..40276bd6f --- /dev/null +++ b/ci/linux-changelog.ps1 @@ -0,0 +1,398 @@ +#!/bin/env pwsh + +# This script contains functions for generating Linux package changelogs from a CHANGELOG.md file. `New-Changelog` generates upstream and packaging changelogs for Debian and RPM-based systems. +# +# Upstream changelogs are derived from the root CHANGELOG.md. +# Change notes for all products are included in each upstream changelog. +# +# Packaging changelogs are derived from package/Linux/gateway/CHANGELOG.md for +# Gateway and package/AgentLinux/CHANGELOG.md for Agent. +# +# ## Debian +# The upstream changelog is included as changelog.gz. +# The packaging changelog is included as changelog.Debian.gz. +# +# ## RPM-based systems +# +# The upstream changelog is included as ChangeLog. +# The packaging changelog is embedded in the spec file. +# +# The date used in the changelog is the date of the release in CHANGELOG.md. + + +function Format-EntryLine { + param( + [Parameter(Mandatory = $true)] + [string] + # The input string to format. + $Line + ) + + <# + .SYNOPSIS + Formats a line of text from an entry CHANGELOG.md. + + .DESCRIPTION + This function removes Markdown formatting such as links, links, boldface, and italics. + + .OUTPUTS + [string] - The formatted line of text. + + .EXAMPLE + PS> Format-EntryLine -Line "*Hello** _world_ ([link](url))" + Hello world + #> + + # remove markdown links enclosed in parantheses + $Line = $Line -replace '\(\[.+?\]\(.*?\)\)', '' + # remove links + $Line = $Line -replace '\[.*?\]\(.*?\)', '' + # remove bold + $Line = $Line -replace '\*\*(.*?)\*\*', '$1' + # remove italics + $Line = $Line -replace '_(.*?)_', '$1' + $Line = $Line -replace '\*(.*?)\*', '$1' + # remove monospace + $Line = $Line -replace '`(.*?)`', '$1' + # remove blockquote marker + $Line = $Line -replace '> ', '' + + # remove + return $Line +} + + +function Format-DebEntry { + param( + [Parameter(Mandatory = $true)] + [string] + # The package version. + $Version, + + [Parameter(Mandatory = $true)] + [string] + # The entry release date in "yyyy-MM-dd" format. + $Date, + + [Parameter(Mandatory = $true)] + [string] + # The packager's name. + $Packager, + + [Parameter(Mandatory = $true)] + [string] + # The packager's email address. + $Email, + + [Parameter(Mandatory = $true)] + [string] + # The package name. + $PackageName, + + [Parameter(Mandatory = $true)] + [string] + # The target distribution. + $Distro, + + [Parameter(Mandatory = $true)] + [string] + # The changelog body text, already formatted and indented. + $Body + ) + + <# + .SYNOPSIS + Formats an entry from CHANGELOG.md into the Debian style. + + .EXAMPLE + PS> Format-DebEntry -Version "0.1.0" -Date "2025-01-01" -Packager "Maurice" -Email "maurice@foo.example" -PackageName "mypackage" -Distro "focal" -Body "- Bug fixes" + mypackage (0.1.0-1) focal; urgency=medium + + * Bug fixes + + -- Maurice Wed, 01 Jan 2025 00:00:00 +0000 + #> + + # Remove the trailing newline. + $bdy = $Body.SubString(0, $Body.Length - 1) + + $dt = [datetime]::ParseExact($Date, "yyyy-MM-dd", $null) + $dt = $dt.ToString("ddd, dd MMM yyyy 00:00:00 +0000") + + return @" +$PackageName ($Version-1) $Distro; urgency=medium + +$bdy + + -- $Packager <$Email> $dt +"@ +} + + +function Format-RpmUpstreamEntry { + param( + [Parameter(Mandatory = $true)] + # The package version. + $Version, + + [Parameter(Mandatory = $true)] + [string] + # The entry release date in "yyyy-MM-dd" format. + $Date, + + [Parameter(Mandatory = $true)] + [string] + # The packager's name. + $Packager, + + [Parameter(Mandatory = $true)] + [string] + # The packager's email address. + $Email, + + [Parameter(Mandatory = $true)] + [string] + # The changelog body text, already formatted and indented. + $Body + ) + + <# + .SYNOPSIS + Formats an entry from CHANGELOG.md into a custom style for RPM. + + .OUTPUTS + [string] - A formatted Debian changelog entry. + + .EXAMPLE + PS> Format-RpmUpstreamEntry -Version "0.1.0" -Date "2025-01-01" -Packager "Maurice" -Email "maurice@foo.example" -Body "- Bug fixes" + 0.1.0 (2025-01-01) Maurice + + * Bug fixes + #> + + # Remove the trailing newline. + $bdy = $Body.SubString(0, $Body.Length - 1) + + return @" +$Version ($Date) $Packager <$Email> + +$bdy +"@ +} + + +function Format-RpmPackagingEntry { + param( + [Parameter(Mandatory = $true)] + # The package version. + $Version, + + [Parameter(Mandatory = $true)] + [string] + # The entry release date in "yyyy-MM-dd" format. + $Date, + + [Parameter(Mandatory = $true)] + [string] + # The packager's name. + $Packager, + + [Parameter(Mandatory = $true)] + [string] + # The packager's email address. + $Email, + + [Parameter(Mandatory = $true)] + [string] + # The changelog body text, already formatted and indented. + $Body + ) + + <# + .SYNOPSIS + Formats an entry from CHANGELOG.md into the packaging changelog style for RPM. + + .OUTPUTS + [string] - A formatted Debian changelog entry. + + .EXAMPLE + PS> Format-RpmPackagingEntry -Version "0.1.0" -Date "2025-01-01" -Packager "Maurice" -Email "maurice@foo.example" -Body "- Removed dependency" + * Wed Jan 01 00:00:00 2025 Maurice - 0.1.0-1 + - Removed dependency + #> + + # Remove the trailing newline. + $bdy = $Body.SubString(0, $Body.Length - 1) + + $dt = [datetime]::ParseExact($Date, "yyyy-MM-dd", $null) + $dt = $dt.ToString("ddd MMM dd 00:00:00 yyyy") + + return @" +* $dt $Packager <$Email> - $Version-1 +$bdy +"@ +} + + +function New-Changelog { + param( + [Parameter(Mandatory = $true)] + [ValidateSet("Deb", "RpmPackaging", "RpmUpstream")] + [string] + # The package format. + $Format, + + [Parameter(Mandatory = $true)] + [string] + # The path to CHANGELOG.md. + $InputFile, + + [Parameter(Mandatory = $true)] + [string] + # The packager's name. + $Packager, + + [Parameter(Mandatory = $true)] + [string] + # The packager's email address. + $Email, + + [string] + # The package name. Required for Debian. + $PackageName, + + [string] + # The target distribution. Required for Debian. + $Distro + ) + + <# + .SYNOPSIS + Generates an upstream changelog from CHANGELOG.md. + + .DESCRIPTION + This function reads CHANGELOG.md and generates an upstream changelog for the desired package format. + #> + + if ($Format -eq "Deb") { + if (-not $PackageName) { + throw '`PackageName` is required for deb format' + } + if (-not $Distro) { + throw '`Distro` is required for deb format' + } + } + + if (-not (Test-Path $InputFile)) { + throw "Input file not found: $InputFile" + } + + $versionRe = '## (\d+\.\d+\.\d+) \((\d{4}-\d{2}-\d{2})\)' + + # whether or not the line is part of a section (like `### Features`) + $inSection = $false + $currVersion = $null + $currDate = $null + # body of the current entry + $body = $null + + foreach ($line in Get-Content -Path $InputFile) { + if ($line -match $versionRe) { + # Reading a new entry; line like `## 2024.3.5 (2024-11-12)` + $version = [Version]$matches[1] + $date = $matches[2] + + # Append the current entry. + if ($currVersion) { + if ($Format -eq 'Deb') { + $output += Format-DebEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -PackageName $PackageName -Distro $Distro -Body $body + } + elseif ($Format -eq 'RpmUpstream') { + $output += Format-RpmUpstreamEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -Body $body + } + elseif ($Format -eq 'RpmPackaging') { + $output += Format-RpmPackagingEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -Body $body + } + + # Add a blank line between entries. + $output += "`n`n" + } + # Start processing a new entry. + $currVersion = $version + $currDate = $date + $inSection = $false + $body = '' + + } + elseif ($line.StartsWith('### ')) { + if ($Format -eq 'Deb') { + # Reading a section header; line like `### Features` + $sectionHeader = $line -replace '^### ', ' * ' + + $body += "$sectionHeader`n" + $inSection = $true + } + else { + # Omit section headers. + continue + } + } + elseif ($currVersion) { + # Reading a section list item + if ([string]::IsNullOrWhiteSpace($line)) { + continue + } + + $line = "$(Format-EntryLine -Line $line)"; + + if ($Format -eq 'Deb') { + if ($inSection) { + # A nested list-item. Add indent. + $body += " $line" + } + else { + # A first-level list item in Markdown + $line = $line -replace '^- ', ' * ' + $body += "$line" + } + } + elseif ($Format -eq 'RpmUpstream') { + $line = $line -replace '^- ', '* ' + $body += "$line" + } + elseif ($Format -eq 'RpmPackaging') { + # strip leading whitespace + $line = $line -replace '^\s+', '' + $body += "$line" + } + + $body += "`n" + } + } + + # Append the final entry. + if ($Format -eq 'Deb') { + $output += Format-DebEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -PackageName $PackageName -Distro $Distro -Body $body + } + elseif ($Format -eq 'RpmUpstream') { + $output += Format-RpmUpstreamEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -Body $body + } + elseif ($Format -eq 'RpmPackaging') { + $output += Format-RpmPackagingEntry -Version $currVersion -Date $currDate -Packager $Packager -Email $Email -Body $body + } + + if ([string]::IsNullOrWhiteSpace($output)) { + throw 'No output' + } + + return $output +} + + +# New-UpstreamChangelog -Format "Deb" -InputFile "CHANGELOG.md" -Packager "Maurice" -Email "abc@foo.com" -PackageName "my-package" -Distro "focal" + +$s = New-Changelog -Format 'RpmUpstream' -InputFile 'CHANGELOG.md' -Packager 'Maurice' -Email 'abc@foo.example' +Set-Content -Path "changelog_rpm_upstream.txt" -Value $s + +$s = New-Changelog -Format 'RpmPackaging' -InputFile 'package/AgentLinux/CHANGELOG.md' -Packager 'Maurice' -Email 'abc@foo.com' +Set-Content -Path 'changelog_rpm_packaging.txt' -Value $s diff --git a/ci/tlk.ps1 b/ci/tlk.ps1 index 3f4cdad65..ab3c4c354 100755 --- a/ci/tlk.ps1 +++ b/ci/tlk.ps1 @@ -9,6 +9,9 @@ if ($IsWindows) { [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; } +# load New-UpstreamChangelog +. (Join-Path $PSScriptRoot "linux-changelog.ps1") + function Get-DotEnvFile { param( [Parameter(Position=0,Mandatory=$true)] @@ -642,8 +645,8 @@ class TlkRecipe $DebianArchitecture = $this.Target.DebianArchitecture() $RpmArchitecture = $this.Target.Architecture - $Packager = "Devolutions Inc." - $Email = "support@devolutions.net" + $Packager = "Benoît Cortier" + $Email = "bcortier@devolutions.net" $Website = "https://devolutions.net" $PackageVersion = $this.Version $DistroCodeName = "focal" # Ubuntu 20.04 @@ -724,7 +727,8 @@ class TlkRecipe Set-Location $OutputPackagePath $PkgName = "devolutions-$($this.Product)" - $PkgNameVersion = "${PkgName}_$($this.Version).0" + $PkgVersion = "$($this.Version)-1" + $PkgNameVersion = "${PkgName}_${PkgVersion}" $DebPkgNameTarget = "${PkgNameVersion}_${DebianArchitecture}" $RpmPkgNameTarget = "${PkgNameVersion}_${RpmArchitecture}" $CopyrightFile = Join-Path $InputPackagePath "$($this.Product)/copyright" @@ -742,7 +746,7 @@ class TlkRecipe Set-Content -Path "$OutputDebianPath/docs" -Value "" # debian/compat - Set-Content -Path "$OutputDebianPath/compat" -Value "9" + Set-Content -Path "$OutputDebianPath/compat" -Value "10" # debian/README.debian Remove-Item -Path "$OutputDebianPath/README.debian" -ErrorAction 'SilentlyContinue' @@ -756,6 +760,9 @@ class TlkRecipe $DhShLibDepsOverride = "dh_shlibdeps" } + $tmpDir = [System.IO.Path]::GetTempPath() + $DebUpstreamChangelogFile = Join-Path $tmpDir "changelog_deb_upstream" + switch ($this.Product) { "gateway" { Merge-Tokens -TemplateFile $RulesTemplate -Tokens @{ @@ -765,6 +772,7 @@ class TlkRecipe dgateway_libxmf = $DGatewayLibXmf platform_dir = $InputPackagePath dh_shlibdeps = $DhShLibDepsOverride + upstream_changelog = $DebUpstreamChangelogFile } -OutputFile $RulesFile } "agent" { @@ -772,6 +780,7 @@ class TlkRecipe executable = $Executable platform_dir = $InputPackagePath dh_shlibdeps = $DhShLibDepsOverride + upstream_changelog = $DebUpstreamChangelogFile } -OutputFile $RulesFile } } @@ -788,29 +797,47 @@ class TlkRecipe description = $Description } -OutputFile $ControlFile + # This directory contains the copyright and changelog templates for both Gateway and Agent. + # Only the package name will differ. + $RequiredFilesDir = Join-Path $this.sourcePath "package/Linux/template" + # debian/copyright $CopyrightFile = Join-Path $OutputDebianPath "copyright" - $CopyrightTemplate = Join-Path $InputPackagePath "template/copyright" + $CopyrightTemplate = Join-Path $RequiredFilesDir "copyright" Merge-Tokens -TemplateFile $CopyrightTemplate -Tokens @{ package = $PkgName packager = $Packager year = $(Get-Date).Year + $PkgNameVersion = "${PkgName}_$($this.Version)-1" website = $Website } -OutputFile $CopyrightFile - # debian/changelog - $ChangelogFile = Join-Path $OutputDebianPath "changelog" - $ChangelogTemplate = Join-Path $InputPackagePath "template/changelog" + # input for upstream is the root CHANGELOG.md + $UpstreamChangelogFile = Join-Path $this.SourcePath "CHANGELOG.md" - Merge-Tokens -TemplateFile $ChangelogTemplate -Tokens @{ - package = $PkgName - distro = $DistroCodeName - email = $Email - packager = $Packager - version = "${PackageVersion}.0" - date = $($(Get-Date -UFormat "%a, %d %b %Y %H:%M:%S %Z00") -Replace '\.','') - } -OutputFile $ChangelogFile + # input for debian/changelog is the package-specific CHANGELOG.md + $PackagingChangelogFile = Join-Path $InputPackagePath "CHANGELOG.md" + + $s = New-Changelog ` + -Format 'Deb' ` + -InputFile $UpstreamChangelogFile ` + -Packager $Packager ` + -Email $Email ` + -PackageName $PkgName ` + -Distro $DistroCodeName + Set-Content -Path $DebUpstreamChangelogFile -Value $s + + # used by dh_make for the package + $DebPackagingChangelogFile = Join-Path $OutputDebianPath "changelog" + $s = New-Changelog ` + -Format 'Deb' ` + -InputFile $PackagingChangelogFile ` + -Packager $Packager ` + -Email $Email ` + -PackageName $PkgName ` + -Distro $DistroCodeName + Set-Content -Path $DebPackagingChangelogFile -Value $s $ScriptPath = Join-Path $InputPackagePath "$($this.Product)/debian" $PostInstFile = Join-Path $ScriptPath 'postinst' @@ -832,6 +859,22 @@ class TlkRecipe $Env:DEB_BUILD_OPTIONS = "nostrip" & 'dpkg-buildpackage' $DpkgBuildPackageArgs | Out-Host + $RpmUpstreamChangelogFile = Join-Path $tmpDir "changelog_rpm_upstream" + $s = New-Changelog ` + -Format 'RpmUpstream' ` + -InputFile $UpstreamChangelogFile ` + -Packager $Packager ` + -Email $Email + Set-Content -Path $RpmUpstreamChangelogFile -Value $s + + $RpmPackagingChangelogFile = Join-Path $tmpDir "changelog_rpm_packaging" + $s = New-Changelog ` + -Format 'RpmPackaging' ` + -InputFile $UpstreamChangelogFile ` + -Packager $Packager ` + -Email $Email + Set-Content -Path $RpmPackagingChangelogFile -Value $s + $FpmArgs = @( '--force', '-s', 'dir', @@ -844,6 +887,7 @@ class TlkRecipe '--url', $Website, '--license', 'Apache-2.0 OR MIT' '--rpm-attr', "755,root,root:/usr/bin/$PkgName" + '--rpm-changelog', $RpmPackagingChangelogFile ) if ($this.Product -eq "gateway") { @@ -857,8 +901,8 @@ class TlkRecipe $FpmArgs += @( '--' "$Executable=/usr/bin/$PkgName" - "$ChangeLogFile=/usr/share/$PkgName/changelog" - "$CopyrightFile=/usr/share/$PkgName/copyright" + "$RpmUpstreamChangelogFile=/usr/share/doc/$PkgName/ChangeLog" + "$CopyrightFile=/usr/share/doc/$PkgName/copyright" ) if ($this.Product -eq "gateway") { diff --git a/package/AgentLinux/CHANGELOG.md b/package/AgentLinux/CHANGELOG.md new file mode 100644 index 000000000..45f713842 --- /dev/null +++ b/package/AgentLinux/CHANGELOG.md @@ -0,0 +1,5 @@ +# Packaging changelog + +## 2024.3.6 (2024-12-02) + +- Add packaging changelog. \ No newline at end of file diff --git a/package/AgentLinux/agent/template/rules b/package/AgentLinux/agent/template/rules index 263c62d3a..9726936d4 100644 --- a/package/AgentLinux/agent/template/rules +++ b/package/AgentLinux/agent/template/rules @@ -11,4 +11,6 @@ override_dh_usrlocal: override_dh_install: dh_install override_dh_shlibdeps: - {{ dh_shlibdeps }} \ No newline at end of file + {{ dh_shlibdeps }} +override_dh_installchangelogs: + dh_installchangelogs {{ upstream_changelog }} \ No newline at end of file diff --git a/package/AgentLinux/template/changelog b/package/AgentLinux/template/changelog deleted file mode 100644 index a7630c312..000000000 --- a/package/AgentLinux/template/changelog +++ /dev/null @@ -1,6 +0,0 @@ -{{ package }} ({{ version }}) {{ distro }}; urgency=low - - * - - -- {{ packager }} <{{ email }}> {{ date }} - diff --git a/package/AgentLinux/template/copyright b/package/AgentLinux/template/copyright deleted file mode 100644 index b3eb01440..000000000 --- a/package/AgentLinux/template/copyright +++ /dev/null @@ -1,9 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: {{ package }} -Source: {{ website }} - -Files: * -Copyright: {{ year }} {{ packager }} -License: non-free - . - diff --git a/package/Linux/CHANGELOG.md b/package/Linux/CHANGELOG.md new file mode 100644 index 000000000..45f713842 --- /dev/null +++ b/package/Linux/CHANGELOG.md @@ -0,0 +1,5 @@ +# Packaging changelog + +## 2024.3.6 (2024-12-02) + +- Add packaging changelog. \ No newline at end of file diff --git a/package/Linux/gateway/template/rules b/package/Linux/gateway/template/rules index 29fa2045a..748813ac6 100644 --- a/package/Linux/gateway/template/rules +++ b/package/Linux/gateway/template/rules @@ -21,3 +21,5 @@ override_dh_install: cp {{ dgateway_libxmf }} $(LIBXMF_DIR)/libxmf.so override_dh_shlibdeps: {{ dh_shlibdeps }} +override_dh_installchangelogs: + dh_installchangelogs {{ upstream_changelog }} \ No newline at end of file diff --git a/package/Linux/template/changelog b/package/Linux/template/changelog deleted file mode 100644 index a7630c312..000000000 --- a/package/Linux/template/changelog +++ /dev/null @@ -1,6 +0,0 @@ -{{ package }} ({{ version }}) {{ distro }}; urgency=low - - * - - -- {{ packager }} <{{ email }}> {{ date }} - From 4c93d3226625af23d8085a1e39625f0ffbcc04d6 Mon Sep 17 00:00:00 2001 From: Allan Zhang <6740989+allan2@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:46:18 -0500 Subject: [PATCH 2/3] Remove test write commands --- ci/linux-changelog.ps1 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ci/linux-changelog.ps1 b/ci/linux-changelog.ps1 index 40276bd6f..dfd7ac470 100644 --- a/ci/linux-changelog.ps1 +++ b/ci/linux-changelog.ps1 @@ -387,12 +387,3 @@ function New-Changelog { return $output } - - -# New-UpstreamChangelog -Format "Deb" -InputFile "CHANGELOG.md" -Packager "Maurice" -Email "abc@foo.com" -PackageName "my-package" -Distro "focal" - -$s = New-Changelog -Format 'RpmUpstream' -InputFile 'CHANGELOG.md' -Packager 'Maurice' -Email 'abc@foo.example' -Set-Content -Path "changelog_rpm_upstream.txt" -Value $s - -$s = New-Changelog -Format 'RpmPackaging' -InputFile 'package/AgentLinux/CHANGELOG.md' -Packager 'Maurice' -Email 'abc@foo.com' -Set-Content -Path 'changelog_rpm_packaging.txt' -Value $s From 2b581eee0c19e356939c2fc9828b1cf0d09e774a Mon Sep 17 00:00:00 2001 From: Allan Zhang <6740989+allan2@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:46:51 -0500 Subject: [PATCH 3/3] Use output dir instead of temp dir --- ci/tlk.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/tlk.ps1 b/ci/tlk.ps1 index ab3c4c354..64e93a0f0 100755 --- a/ci/tlk.ps1 +++ b/ci/tlk.ps1 @@ -760,8 +760,7 @@ class TlkRecipe $DhShLibDepsOverride = "dh_shlibdeps" } - $tmpDir = [System.IO.Path]::GetTempPath() - $DebUpstreamChangelogFile = Join-Path $tmpDir "changelog_deb_upstream" + $DebUpstreamChangelogFile = Join-Path $OutputPath "changelog_deb_upstream" switch ($this.Product) { "gateway" { @@ -859,7 +858,7 @@ class TlkRecipe $Env:DEB_BUILD_OPTIONS = "nostrip" & 'dpkg-buildpackage' $DpkgBuildPackageArgs | Out-Host - $RpmUpstreamChangelogFile = Join-Path $tmpDir "changelog_rpm_upstream" + $RpmUpstreamChangelogFile = Join-Path $OutputPath "changelog_rpm_upstream" $s = New-Changelog ` -Format 'RpmUpstream' ` -InputFile $UpstreamChangelogFile ` @@ -867,7 +866,7 @@ class TlkRecipe -Email $Email Set-Content -Path $RpmUpstreamChangelogFile -Value $s - $RpmPackagingChangelogFile = Join-Path $tmpDir "changelog_rpm_packaging" + $RpmPackagingChangelogFile = Join-Path $OutputPath "changelog_rpm_packaging" $s = New-Changelog ` -Format 'RpmPackaging' ` -InputFile $UpstreamChangelogFile ` @@ -875,6 +874,7 @@ class TlkRecipe -Email $Email Set-Content -Path $RpmPackagingChangelogFile -Value $s + Write-Host("output destination: $OutputPath/${RpmPkgNameTarget}.rpm") $FpmArgs = @( '--force', '-s', 'dir',