Skip to content

Commit 35bd9dd

Browse files
feat: add mainBinaryName option (#10977)
* feat: add `mainBinaryName` option * remove unused imports [skip ci] * enhance error message [skip ci] * migrate `mainBinaryName` * change file * revert bin src_path * add link --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent 3ad2427 commit 35bd9dd

File tree

32 files changed

+188
-135
lines changed

32 files changed

+188
-135
lines changed

.changes/changelog-path-deb.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'major:breaking'
3+
---
4+
5+
Changed changelog file location in `deb` to `usr/share/doc/<product_name>/changelog.gz` instead of `usr/share/doc/<main_binary_name>/changelog.gz`. For tauri v1 users, the path is unchanged as `product_name` and `main_binary_name` used the same value.

.changes/main_binary_name.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri": "patch:feat"
3+
"tauri-utils": "patch:feat"
4+
"tauri-cli": "patch:feat"
5+
"tauri-bundler": "patch:feat"
6+
---
7+
8+
Add `mainBinaryName` config option to set the file name for the main binary.

.changes/resources-path-deb-rpm.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'major:breaking'
3+
---
4+
5+
Changed resources directory location in `deb` and `rpm` to `/usr/lib/<product_name>` instead of `/usr/lib/<main_binary_name>`. For tauri v1 users, the path is unchanged as `product_name` and `main_binary_name` used the same value.

crates/tauri-bundler/src/bundle/linux/appimage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
5656
// setup data to insert into shell script
5757
let mut sh_map = BTreeMap::new();
5858
sh_map.insert("arch", settings.target().split('-').next().unwrap());
59-
sh_map.insert("crate_name", settings.main_binary_name());
59+
sh_map.insert("product_name", settings.product_name());
6060
sh_map.insert("appimage_filename", &appimage_filename);
6161

6262
let tauri_tools_path = settings

crates/tauri-bundler/src/bundle/linux/debian.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ pub fn generate_data(
133133
fn generate_changelog_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
134134
if let Some(changelog_src_path) = &settings.deb().changelog {
135135
let mut src_file = File::open(changelog_src_path)?;
136-
let bin_name = settings.main_binary_name();
137-
let dest_path = data_dir.join(format!("usr/share/doc/{}/changelog.gz", bin_name));
136+
let product_name = settings.product_name();
137+
let dest_path = data_dir.join(format!("usr/share/doc/{product_name}/changelog.gz"));
138138

139139
let changelog_file = common::create_file(&dest_path)?;
140140
let mut gzip_encoder = GzEncoder::new(changelog_file, Compression::new(9));
@@ -306,7 +306,7 @@ fn generate_md5sums(control_dir: &Path, data_dir: &Path) -> crate::Result<()> {
306306
/// Copy the bundle's resource files into an appropriate directory under the
307307
/// `data_dir`.
308308
fn copy_resource_files(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
309-
let resource_dir = data_dir.join("usr/lib").join(settings.main_binary_name());
309+
let resource_dir = data_dir.join("usr/lib").join(settings.product_name());
310310
settings.copy_resources(&resource_dir)
311311
}
312312

crates/tauri-bundler/src/bundle/linux/freedesktop.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ pub fn list_icon_files(
4444
data_dir: &Path,
4545
) -> crate::Result<BTreeMap<Icon, PathBuf>> {
4646
let base_dir = data_dir.join("usr/share/icons/hicolor");
47+
let main_binary_name = settings.main_binary_name()?;
4748
let get_dest_path = |width: u32, height: u32, is_high_density: bool| {
4849
base_dir.join(format!(
4950
"{}x{}{}/apps/{}.png",
5051
width,
5152
height,
5253
if is_high_density { "@2" } else { "" },
53-
settings.main_binary_name()
54+
main_binary_name
5455
))
5556
};
5657
let mut icons = BTreeMap::new();
@@ -97,8 +98,9 @@ pub fn generate_desktop_file(
9798
custom_template_path: &Option<PathBuf>,
9899
data_dir: &Path,
99100
) -> crate::Result<(PathBuf, PathBuf)> {
100-
let bin_name = settings.main_binary_name();
101-
let desktop_file_name = format!("{bin_name}.desktop");
101+
let bin_name = settings.main_binary_name()?;
102+
let product_name = settings.product_name();
103+
let desktop_file_name = format!("{product_name}.desktop");
102104
let path = PathBuf::from("usr/share/applications").join(desktop_file_name);
103105
let dest_path = PathBuf::from("/").join(&path);
104106
let file_path = data_dir.join(&path);

crates/tauri-bundler/src/bundle/linux/rpm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
141141

142142
// Add resources
143143
if settings.resource_files().count() > 0 {
144-
let resource_dir = Path::new("/usr/lib").join(settings.main_binary_name());
144+
let resource_dir = Path::new("/usr/lib").join(settings.product_name());
145145
// Create an empty file, needed to add a directory to the RPM package
146146
// (cf https://github.com/rpm-rs/rpm/issues/177)
147147
let empty_file_path = &package_dir.join("empty");
148148
File::create(empty_file_path)?;
149-
// Then add the resource directory `/usr/lib/<binary_name>` to the package.
149+
// Then add the resource directory `/usr/lib/<product_name>` to the package.
150150
builder = builder.with_file(
151151
empty_file_path,
152152
FileOptions::new(resource_dir.to_string_lossy()).mode(FileMode::Dir { permissions: 0o755 }),

crates/tauri-bundler/src/bundle/linux/templates/appimage

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ else
1717
linuxdeploy_arch="$ARCH"
1818
fi
1919

20-
mkdir -p "{{crate_name}}.AppDir"
21-
cp -r ../appimage_deb/data/usr "{{crate_name}}.AppDir"
20+
mkdir -p "{{product_name}}.AppDir"
21+
cp -r ../appimage_deb/data/usr "{{product_name}}.AppDir"
2222

23-
cd "{{crate_name}}.AppDir"
23+
cd "{{product_name}}.AppDir"
2424
mkdir -p "usr/bin"
2525
mkdir -p "usr/lib"
2626

@@ -56,14 +56,14 @@ find -L /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p "$(dirname
5656
( cd "{{tauri_tools_path}}" && ( wget -q -4 -N https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH} || wget -q -4 -N https://github.com/AppImage/AppImageKit/releases/download/12/AppRun-${ARCH} ) )
5757
chmod +x "{{tauri_tools_path}}/AppRun-${ARCH}"
5858

59-
# We need AppRun to be installed as {{crate_name}}.AppDir/AppRun.
59+
# We need AppRun to be installed as {{product_name}}.AppDir/AppRun.
6060
# Otherwise the linuxdeploy scripts will default to symlinking our main bin instead and will crash on trying to launch.
6161
cp "{{tauri_tools_path}}/AppRun-${ARCH}" AppRun
6262

6363
cp "{{icon_path}}" .DirIcon
64-
ln -sf "{{icon_path}}" "{{crate_name}}.png"
64+
ln -sf "{{icon_path}}" "{{product_name}}.png"
6565

66-
ln -sf "usr/share/applications/{{crate_name}}.desktop" "{{crate_name}}.desktop"
66+
ln -sf "usr/share/applications/{{product_name}}.desktop" "{{product_name}}.desktop"
6767

6868
cd ..
6969

@@ -83,4 +83,4 @@ chmod +x "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage"
8383

8484
dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage"
8585

86-
OUTPUT="{{appimage_filename}}" "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage" --appimage-extract-and-run --appdir "{{crate_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage
86+
OUTPUT="{{appimage_filename}}" "{{tauri_tools_path}}/linuxdeploy-${linuxdeploy_arch}.AppImage" --appimage-extract-and-run --appdir "{{product_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage

crates/tauri-bundler/src/bundle/macos/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn create_info_plist(
200200
plist.insert("CFBundleDisplayName".into(), settings.product_name().into());
201201
plist.insert(
202202
"CFBundleExecutable".into(),
203-
settings.main_binary_name().into(),
203+
settings.main_binary_name()?.into(),
204204
);
205205
if let Some(path) = bundle_icon_file {
206206
plist.insert(

crates/tauri-bundler/src/bundle/macos/ios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn generate_info_plist(
170170
writeln!(
171171
file,
172172
" <key>CFBundleExecutable</key>\n <string>{}</string>",
173-
settings.main_binary_name()
173+
settings.main_binary_name()?
174174
)?;
175175
writeln!(
176176
file,

0 commit comments

Comments
 (0)