@@ -170,13 +170,27 @@ def __AddManifestOptions(self) -> None:
170170 help = "Name of the organization/person that created the "
171171 "orig tarball." )
172172
173- manifestGroup .add_argument (
174- "--use-legacy-manifest-format" ,
175- dest = "UseLegacyManifestFormat" ,
173+ manifestFormatGroup = manifestGroup .add_mutually_exclusive_group ()
174+
175+ manifestFormatGroup .add_argument (
176+ "--force-no-manifest" ,
177+ dest = "ForceNoManifest" ,
178+ action = "store_true" ,
179+ help = "Force that no release manifest file will be created." )
180+
181+ manifestFormatGroup .add_argument (
182+ "--force-use-legacy-manifest-format" ,
183+ dest = "ForceUseLegacyManifestFormat" ,
176184 action = "store_true" ,
177- help = "Use the legacy (release.info) release manifest format used "
178- "by earlier Canonical packages. Without this option a "
179- "manifest.json file will be created." )
185+ help = "Force the use of the legacy release manifest file format "
186+ "(release.info)." )
187+
188+ manifestFormatGroup .add_argument (
189+ "--force-use-json-manifest-format" ,
190+ dest = "ForceUseJsonManifestFormat" ,
191+ action = "store_true" ,
192+ help = "Force the use of the newer json based release manifest file "
193+ "format (release.json)." )
180194
181195 def __AddBootstrappingOption (self ) -> None :
182196 bootstrappinGroup = self .add_argument_group ("bootstrapping options" )
@@ -277,7 +291,19 @@ def __init__(self, args: argparse.Namespace, hostDpkgArchitecture: str):
277291 LogWarning ("Specified .NET security partners repository "
278292 "access token was not used" )
279293
280- self .UseLegacyManifestFormat : bool = args .UseLegacyManifestFormat
294+ self .ReleaseManifestFormat : str | None = None
295+
296+ if args .ForceNoManifest :
297+ self .ReleaseManifestFormat = None
298+ elif args .ForceUseJsonManifestFormat :
299+ self .ReleaseManifestFormat = "json"
300+ elif args .ForceUseLegacyManifestFormat :
301+ self .ReleaseManifestFormat = "legacy"
302+ elif self .DotnetMajorVersion >= 10 :
303+ self .ReleaseManifestFormat = "json"
304+ elif self .DotnetMajorVersion >= 8 :
305+ self .ReleaseManifestFormat = "legacy"
306+
281307 self .VendorName : str | None = args .VendorName
282308 self .SourceLinkRepository : str | None = args .SourceLinkRepository
283309
@@ -415,7 +441,7 @@ def PrintState(self) -> None:
415441- TarballName={ self .TarballName }
416442
417443Manifest options:
418- - UseLegacyManifestFormat ={ self .UseLegacyManifestFormat }
444+ - ReleaseManifestFormat ={ self .ReleaseManifestFormat }
419445- SourceLinkRepository={ self .SourceLinkRepository }
420446- VendorName={ self .VendorName }
421447- BuildId={ self .BuildId }
@@ -731,18 +757,22 @@ def GetHeadCommitSha1Hash(context: InvocationContext) -> str:
731757
732758
733759def CreateReleaseManifest (context : InvocationContext ) -> None :
760+ if context .ReleaseManifestFormat is None :
761+ return
762+
734763 sourceRepository = context .SourceLinkRepository
735764 sourceVersion = GetHeadCommitSha1Hash (context )
736765 buildIdUnused = False
737766
738- if context .UseLegacyManifestFormat :
767+ if context .ReleaseManifestFormat == "legacy" :
768+ releaseManifestFileName = "release.info"
739769 releaseManifestFileContent = (
740770 f"RM_GIT_REPO={ sourceRepository } \n "
741771 f"RM_GIT_COMMIT={ sourceVersion } " )
742772
743- releaseManifestFileName = "release.info"
744773 buildIdUnused = context .BuildId is not None
745- else :
774+ elif context .ReleaseManifestFormat == "json" :
775+ releaseManifestFileName = "release.json"
746776 releaseManifestData = {
747777 "sourceRepository" : sourceRepository ,
748778 "sourceVersion" : sourceVersion ,
@@ -759,7 +789,9 @@ def CreateReleaseManifest(context: InvocationContext) -> None:
759789 buildIdUnused = context .BuildId is not None
760790
761791 releaseManifestFileContent = json .dumps (releaseManifestData , indent = 4 )
762- releaseManifestFileName = "release.json"
792+ else :
793+ LogErrorAndExit ("Unsupported release manifest format "
794+ f"'{ context .ReleaseManifestFormat } '." )
763795
764796 if buildIdUnused :
765797 LogWarning (f"Build id '{ context .BuildId } ' is unused" )
0 commit comments