diff --git a/.changes/excluded-libs-appiamge.md b/.changes/excluded-libs-appiamge.md new file mode 100644 index 00000000..a12a88e6 --- /dev/null +++ b/.changes/excluded-libs-appiamge.md @@ -0,0 +1,6 @@ +--- +"cargo-packager": minor +"@crabnebula/packager": minor +--- + +Added config option to control excluded libs when packaging AppImage diff --git a/bindings/packager/nodejs/schema.json b/bindings/packager/nodejs/schema.json index 9482eda3..a1578058 100644 --- a/bindings/packager/nodejs/schema.json +++ b/bindings/packager/nodejs/schema.json @@ -810,6 +810,16 @@ "additionalProperties": { "type": "string" } + }, + "excludedLibs": { + "description": "List of globs of libraries to exclude from the final APpImage. For example, to exclude libnss3.so, you'd specify `libnss3*`", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } } }, "additionalProperties": false diff --git a/bindings/packager/nodejs/src-ts/config.d.ts b/bindings/packager/nodejs/src-ts/config.d.ts index f5d27edd..48ef334e 100644 --- a/bindings/packager/nodejs/src-ts/config.d.ts +++ b/bindings/packager/nodejs/src-ts/config.d.ts @@ -450,6 +450,10 @@ export interface AppImageConfig { linuxdeployPlugins?: { [k: string]: string; } | null; + /** + * List of globs of libraries to exclude from the final APpImage. For example, to exclude libnss3.so, you'd specify `libnss3*` + */ + excludedLibs?: string[] | null; } /** * The Linux pacman configuration. diff --git a/crates/packager/schema.json b/crates/packager/schema.json index 9482eda3..a1578058 100644 --- a/crates/packager/schema.json +++ b/crates/packager/schema.json @@ -810,6 +810,16 @@ "additionalProperties": { "type": "string" } + }, + "excludedLibs": { + "description": "List of globs of libraries to exclude from the final APpImage. For example, to exclude libnss3.so, you'd specify `libnss3*`", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } } }, "additionalProperties": false diff --git a/crates/packager/src/config/mod.rs b/crates/packager/src/config/mod.rs index 178b3b9c..ab62ee40 100644 --- a/crates/packager/src/config/mod.rs +++ b/crates/packager/src/config/mod.rs @@ -267,6 +267,10 @@ pub struct AppImageConfig { /// you'd specify `gtk` as the key and its url as the value. #[serde(alias = "linuxdeploy-plugins", alias = "linuxdeploy_plugins")] pub linuxdeploy_plugins: Option>, + /// List of globs of libraries to exclude from the final AppImage. + /// For example, to exclude libnss3.so, you'd specify `libnss3*` + #[serde(alias = "excluded-libraries", alias = "excluded_libraries")] + pub excluded_libs: Option>, } impl AppImageConfig { diff --git a/crates/packager/src/package/appimage/appimage b/crates/packager/src/package/appimage/appimage index 0270ef3f..01a8b681 100644 --- a/crates/packager/src/package/appimage/appimage +++ b/crates/packager/src/package/appimage/appimage @@ -41,4 +41,4 @@ cd .. # and so appimagelauncher doesn't inject itself and the binary runs directly dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="{{packager_tools_path}}/linuxdeploy-{{linuxdeploy_arch}}.AppImage" -OUTPUT="{{appimage_path}}" "{{packager_tools_path}}/linuxdeploy-{{linuxdeploy_arch}}.AppImage" --appimage-extract-and-run --appdir "{{app_name}}.AppDir" {{linuxdeploy_plugins}} --output appimage +OUTPUT="{{appimage_path}}" "{{packager_tools_path}}/linuxdeploy-{{linuxdeploy_arch}}.AppImage" --appimage-extract-and-run --appdir "{{app_name}}.AppDir" {{linuxdeploy_plugins}} {{excluded_libs}} --output appimage diff --git a/crates/packager/src/package/appimage/mod.rs b/crates/packager/src/package/appimage/mod.rs index 59b2fffd..8db69128 100644 --- a/crates/packager/src/package/appimage/mod.rs +++ b/crates/packager/src/package/appimage/mod.rs @@ -136,6 +136,16 @@ pub(crate) fn package(ctx: &Context) -> crate::Result> { .join(" "); sh_map.insert("linuxdeploy_plugins", to_json(linuxdeploy_plugins)); + let excluded_libraries = config + .appimage() + .and_then(|a| a.excluded_libs.clone()) + .unwrap_or_default() + .into_iter() + .map(|library| format!("--exclude-library {}", library)) + .collect::>() + .join(" "); + sh_map.insert("excluded_libs", to_json(excluded_libraries)); + let larger_icon = icons .iter() .filter(|i| i.width == i.height)