Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian: package name and Release file creation date #8

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/deb/deb-builder.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,25 @@ 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;
date: Date;
repo: DebRepo;
}

Expand Down Expand Up @@ -95,18 +109,14 @@ 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
.replace('$ORIGIN', this.config.origin)
.replace('$DISTRIBUTION', distribution)
.replace('$ARCH', arch)
.replace('$COMPONENT', component)
.replace('$DATE', new Date().toUTCString());
.replace('$DATE', this.config.date.toUTCString());

releaseContent += 'SHA256:\n';
for (const { address, size, name } of indices) {
Expand Down Expand Up @@ -154,8 +164,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 +176,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
Loading