Skip to content

Commit

Permalink
fix(debian): get package name from Package field in control file
Browse files Browse the repository at this point in the history
  • Loading branch information
Nipheris committed Apr 11, 2024
1 parent 2e7bd7c commit 0add784
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/deb/deb-builder.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<void> {
let releaseContent = ReleaseFileTemplate
Expand Down Expand Up @@ -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}`);

Expand All @@ -165,22 +175,26 @@ export class DebBuilder implements Deployer {
this.archesByDistComp.set(`${distribution}/${component}`, new Set<string>([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);

removeDir(whereExtract);

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'];
Expand Down

0 comments on commit 0add784

Please sign in to comment.