Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changes/deb-package-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cargo-packager": patch
"@crabnebula/packager": patch
---

Allow explicitly specifying the Package name for the .deb bundle.
11 changes: 9 additions & 2 deletions bindings/packager/nodejs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
},
"identifier": {
"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 (.).",
"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 (.).",
"type": [
"string",
"null"
Expand Down Expand Up @@ -566,7 +566,7 @@
]
},
"role": {
"description": "The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
"description": "The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
"default": "editor",
"allOf": [
{
Expand Down Expand Up @@ -860,6 +860,13 @@
"additionalProperties": {
"type": "string"
}
},
"packageName": {
"description": "Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
Expand Down
8 changes: 6 additions & 2 deletions bindings/packager/nodejs/src-ts/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface Config {
*/
binaries?: Binary[];
/**
* 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 (.).
* 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 (.).
*/
identifier?: string | null;
/**
Expand Down Expand Up @@ -335,7 +335,7 @@ export interface FileAssociation {
*/
name?: string | null;
/**
* The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]
* The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]
*/
role?: BundleTypeRole & string;
}
Expand Down Expand Up @@ -493,6 +493,10 @@ export interface DebianConfig {
files?: {
[k: string]: string;
} | null;
/**
* Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.
*/
packageName?: string | null;
}
/**
* The Linux AppImage configuration.
Expand Down
11 changes: 9 additions & 2 deletions crates/packager/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
},
"identifier": {
"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 (.).",
"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 (.).",
"type": [
"string",
"null"
Expand Down Expand Up @@ -566,7 +566,7 @@
]
},
"role": {
"description": "The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
"description": "The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS. Defaults to [`BundleTypeRole::Editor`]",
"default": "editor",
"allOf": [
{
Expand Down Expand Up @@ -860,6 +860,13 @@
"additionalProperties": {
"type": "string"
}
},
"packageName": {
"description": "Name to use for the `Package` field in the Debian Control file. Defaults to [`Config::product_name`] converted to kebab-case.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
Expand Down
12 changes: 8 additions & 4 deletions crates/packager/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct FileAssociation {
pub description: Option<String>,
/// The name. Maps to `CFBundleTypeName` on macOS. Defaults to the first item in `ext`
pub name: Option<String>,
/// The apps role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
/// The app's role with respect to the type. Maps to `CFBundleTypeRole` on macOS.
/// Defaults to [`BundleTypeRole::Editor`]
#[serde(default)]
pub role: BundleTypeRole,
Expand Down Expand Up @@ -125,7 +125,7 @@ impl FileAssociation {
self
}

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

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

impl DebianConfig {
Expand Down Expand Up @@ -1645,7 +1649,7 @@ pub struct Config {
pub binaries: Vec<Binary>,
/// 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 (-),
/// This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-),
/// and periods (.).
#[cfg_attr(feature = "schema", schemars(regex(pattern = r"^[a-zA-Z0-9-\.]*$")))]
pub identifier: Option<String>,
Expand Down
8 changes: 7 additions & 1 deletion crates/packager/src/package/deb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ fn generate_control_file(
// https://www.debian.org/doc/debian-policy/ch-controlfields.html
let dest_path = control_dir.join("control");
let mut file = util::create_file(&dest_path)?;
writeln!(file, "Package: {}", AsKebabCase(&config.product_name))?;

let pkg_name = config
.deb()
.and_then(|deb| deb.package_name.clone())
.unwrap_or_else(|| AsKebabCase(&config.product_name).to_string());

writeln!(file, "Package: {pkg_name}")?;
writeln!(file, "Version: {}", &config.version)?;
writeln!(file, "Architecture: {arch}")?;
// Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size
Expand Down
Loading