Skip to content

Commit 6e6a10c

Browse files
feat: Add deb.package_name config var (#321)
Co-authored-by: FabianLars-crabnebula <fabianlars@crabnebula.dev> Co-authored-by: Fabian-Lars <118197967+FabianLars-crabnebula@users.noreply.github.com>
1 parent 68c118f commit 6e6a10c

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed

.changes/deb-package-name.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cargo-packager": patch
3+
"@crabnebula/packager": patch
4+
---
5+
6+
Allow explicitly specifying the Package name for the .deb bundle.

bindings/packager/nodejs/schema.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343
},
4444
"identifier": {
45-
"description": "The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-), and periods (.).",
45+
"description": "The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).",
4646
"type": [
4747
"string",
4848
"null"
@@ -566,7 +566,7 @@
566566
]
567567
},
568568
"role": {
569-
"description": "The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
569+
"description": "The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
570570
"default": "editor",
571571
"allOf": [
572572
{
@@ -860,6 +860,13 @@
860860
"additionalProperties": {
861861
"type": "string"
862862
}
863+
},
864+
"packageName": {
865+
"description": "Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.",
866+
"type": [
867+
"string",
868+
"null"
869+
]
863870
}
864871
},
865872
"additionalProperties": false

bindings/packager/nodejs/src-ts/config.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export interface Config {
161161
*/
162162
binaries?: Binary[];
163163
/**
164-
* The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-), and periods (.).
164+
* The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).
165165
*/
166166
identifier?: string | null;
167167
/**
@@ -335,7 +335,7 @@ export interface FileAssociation {
335335
*/
336336
name?: string | null;
337337
/**
338-
* The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]
338+
* The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]
339339
*/
340340
role?: BundleTypeRole & string;
341341
}
@@ -493,6 +493,10 @@ export interface DebianConfig {
493493
files?: {
494494
[k: string]: string;
495495
} | null;
496+
/**
497+
* Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.
498+
*/
499+
packageName?: string | null;
496500
}
497501
/**
498502
* The Linux AppImage configuration.

crates/packager/schema.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343
},
4444
"identifier": {
45-
"description": "The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-), and periods (.).",
45+
"description": "The application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).",
4646
"type": [
4747
"string",
4848
"null"
@@ -566,7 +566,7 @@
566566
]
567567
},
568568
"role": {
569-
"description": "The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
569+
"description": "The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
570570
"default": "editor",
571571
"allOf": [
572572
{
@@ -860,6 +860,13 @@
860860
"additionalProperties": {
861861
"type": "string"
862862
}
863+
},
864+
"packageName": {
865+
"description": "Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.",
866+
"type": [
867+
"string",
868+
"null"
869+
]
863870
}
864871
},
865872
"additionalProperties": false

crates/packager/src/config/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct FileAssociation {
7575
pub description: Option<String>,
7676
/// The name. Maps to `CFBundleTypeName` on macOS. Defaults to the first item in `ext`
7777
pub name: Option<String>,
78-
/// The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
78+
/// The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
7979
/// Defaults to [`BundleTypeRole::Editor`]
8080
#[serde(default)]
8181
pub role: BundleTypeRole,
@@ -125,7 +125,7 @@ impl FileAssociation {
125125
self
126126
}
127127

128-
/// Set he apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
128+
/// Set he app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
129129
/// Defaults to [`BundleTypeRole::Editor`]
130130
pub fn role(mut self, role: BundleTypeRole) -> Self {
131131
self.role = role;
@@ -168,7 +168,7 @@ impl DeepLinkProtocol {
168168
self
169169
}
170170

171-
/// Set he apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
171+
/// Set he app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
172172
/// Defaults to [`BundleTypeRole::Editor`]
173173
pub fn role(mut self, role: BundleTypeRole) -> Self {
174174
self.role = role;
@@ -231,6 +231,10 @@ pub struct DebianConfig {
231231
/// List of custom files to add to the deb package.
232232
/// Maps a dir/file to a dir/file inside the debian package.
233233
pub files: Option<HashMap<String, String>>,
234+
/// Name to use for the `Package` field in the Debian Control file.
235+
/// Defaults to [`Config::product_name`] converted to kebab-case.
236+
#[serde(alias = "package-name", alias = "package_name")]
237+
pub package_name: Option<String>,
234238
}
235239

236240
impl DebianConfig {
@@ -1645,7 +1649,7 @@ pub struct Config {
16451649
pub binaries: Vec<Binary>,
16461650
/// The application identifier in reverse domain name notation (e.g. `com.packager.example`).
16471651
/// This string must be unique across applications since it is used in some system configurations.
1648-
/// This string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-),
1652+
/// This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-),
16491653
/// and periods (.).
16501654
#[cfg_attr(feature = "schema", schemars(regex(pattern = r"^[a-zA-Z0-9-\.]*$")))]
16511655
pub identifier: Option<String>,

crates/packager/src/package/deb/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ fn generate_control_file(
302302
// https://www.debian.org/doc/debian-policy/ch-controlfields.html
303303
let dest_path = control_dir.join("control");
304304
let mut file = util::create_file(&dest_path)?;
305-
writeln!(file, "Package: {}", AsKebabCase(&config.product_name))?;
305+
306+
let pkg_name = config
307+
.deb()
308+
.and_then(|deb| deb.package_name.clone())
309+
.unwrap_or_else(|| AsKebabCase(&config.product_name).to_string());
310+
311+
writeln!(file, "Package: {pkg_name}")?;
306312
writeln!(file, "Version: {}", &config.version)?;
307313
writeln!(file, "Architecture: {arch}")?;
308314
// Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size

0 commit comments

Comments
 (0)