Skip to content

Commit b91ddc6

Browse files
authored
Merge pull request #152 from dotnet-campus/t/lindexi/StandardVersion
加上更多注释
2 parents dd4dfaa + a10865c commit b91ddc6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

DebUOS/Packaging.DebUOS/Contexts/Configurations/DebUOSConfiguration.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -216,26 +216,37 @@ public string DebControlStandardsVersion
216216
set => SetValue(value);
217217
get
218218
{
219+
// 参考 https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-standards-version
220+
// > 5.6.11. Standards-Version
221+
// > The most recent version of the standards (the policy manual and associated texts) with which the package complies. See Standards conformance.
222+
// > The version number has four components: major and minor version number and major and minor patch level. When the standards change in a way that requires every package to change the major number will be changed. Significant changes that will require work in many packages will be signaled by a change to the minor number. The major patch level will be changed for any change to the meaning of the standards, however small; the minor patch level will be changed when only cosmetic, typographical or other edits are made which neither change the meaning of the document nor affect the contents of packages.
223+
//
224+
// > Thus only the first three components of the policy version are significant in the Standards-Version control field, and so either these three components or all four components may be specified. 5
225+
//
226+
// > udebs and source packages that only produce udebs do not use Standards-Version.
219227
var result = GetString();
220228

221229
if (result is not null)
222230
{
223231
return result;
224232
}
225233

234+
// 尝试使用 UOSDebVersion 进行兼容,但是要求前提是这里的版本号是传统的非语义版本号
226235
if (System.Version.TryParse(UOSDebVersion, out var version))
227236
{
228237
string standardVersion;
229238

239+
// 以下为兼容 UOSDebVersion 写的是 a.b.c.d 和 a.b.c 和 a.b 的写法
230240
var major = version.Major;
231241
var minor = version.Minor;
232242
var build = version.Build;
233243
var revision = version.Revision;
234244

235245
major = Math.Max(0, major);
236-
minor = Math.Max(0, minor);
246+
minor = Math.Max(0, minor); // 如果没有版本号,则为 -1 的值,使用 Max 可确保不写默认为 0 而不是负数
237247
build = Math.Max(0, build);
238248

249+
// 是否有最后一位,根据 Debian 维护者指导文档和 Debian 政策手册,要求使用 3-4 位的版本号
239250
if (revision >= 0)
240251
{
241252
standardVersion = $"{major}.{minor}.{build}.{revision}";
@@ -248,6 +259,7 @@ public string DebControlStandardsVersion
248259
return standardVersion;
249260
}
250261

262+
// 为什么默认返回 3.9.6 呢?因为是从 https://www.debian.org/doc/manuals/debmake-doc/ch09.en.html 里面抄的代码。且返回一个非 1.0.0 的版本号会比较方便大家想设置时,去找到是在哪里配置的
251263
return "3.9.6";
252264
}
253265
}

0 commit comments

Comments
 (0)