diff --git a/src/deb/deb-builder.mts b/src/deb/deb-builder.mts index f2a6c30..a34aed9 100644 --- a/src/deb/deb-builder.mts +++ b/src/deb/deb-builder.mts @@ -52,10 +52,23 @@ function iterateDebs(repo: DebRepo, callback: (distribution: string, component: }); } +/** + * See {@link https://www.debian.org/doc/manuals/debian-faq/pkg-basics.en.html#pkgname|"Why are Debian package file names so long?"} + * @param name Package name, + * should be taken from {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-package|`Package`} field in case of binary packages + * @param version Package version, + * should be taken from {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version|`Version`} field. + * It could include `debian_revision` part + * @param arch Debian machine architecture this binary package was build for, + * should be taken from {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-architecture|`Architecture`} field + */ +function binaryPackageFileName(name: string, version: string, arch: string): string { + return `${name}-${version}_${arch}.deb`; +} + export interface Config { out: string, gpgKeyName: string; - applicationName: string; origin: string; repo: DebRepo; } @@ -95,10 +108,6 @@ export class DebBuilder implements Deployer { console.log(this); } - private debFileName(version: string, arch: string): string { - return `${this.config.applicationName}-${version}_${arch}.deb`; - } - // eslint-disable-next-line max-params private async makeReleaseFileAndSign(distribution: string, component: string, arch: string, indices: BinaryPackageIndexDescription[]): Promise { let releaseContent = ReleaseFileTemplate @@ -154,8 +163,9 @@ export class DebBuilder implements Deployer { .on('finish', () => { const controlMetaContent = readFileSync(path.join(whereExtract, 'control'), 'utf-8').replaceAll(':', '='); const controlMeta = ini.parse(controlMetaContent); - const arch = controlMeta['Architecture']; + const name = controlMeta['Package']; const version = controlMeta['Version']; + const arch = controlMeta['Architecture']; const archesSet = this.archesByDistComp.get(`${distribution}/${component}`); @@ -165,11 +175,14 @@ export class DebBuilder implements Deployer { this.archesByDistComp.set(`${distribution}/${component}`, new Set([arch])); } + const fileName = binaryPackageFileName(name, version, arch); + const targetMetaPath = path.join(this.distsPath, distribution, component, `binary-${arch}`, - `${this.debFileName(version, arch)}.meta`); + `${fileName}.meta`, + ); createDir(path.dirname(targetMetaPath)); renameSync(path.join(whereExtract, 'control'), targetMetaPath); @@ -177,10 +190,11 @@ export class DebBuilder implements Deployer { const debPath = path.join(this.poolPath, component, - `${this.config.applicationName[0]}`, - this.config.applicationName, + `${name[0]}`, + name, distribution, - this.debFileName(version, arch)); + fileName, + ); const relativeDebPath = path.relative(this.rootPath, debPath).replace(/\\/gu, '/'); const debSize = controlTar.headers['content-range']?.split('/')[1]; const sha1 = controlTar.headers['x-checksum-sha1'];