Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

feat: Enhance Linux packaging with consistent binary naming, improved desktop file generation including RPM support

Tw9349c785f903b0
diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts
index 77d7cb0b..372dd9de 100644
--- a/bin/builders/BaseBuilder.ts
+++ b/bin/builders/BaseBuilder.ts
@@ -7,7 +7,7 @@ import { PakeAppOptions } from '@/types';
import { checkRustInstalled, ensureRustEnv, installRust } from '@/helpers/rust';
import { mergeConfig } from '@/helpers/merge';
import tauriConfig from '@/helpers/tauriConfig';
-import { generateIdentifierSafeName } from '@/utils/name';
+import { generateIdentifierSafeName, generateLinuxPackageName } from '@/utils/name';
import { npmDirectory } from '@/utils/dir';
import { getSpinner } from '@/utils/info';
import { shellExec } from '@/utils/shell';
@@ -537,13 +537,9 @@ export default abstract class BaseBuilder {
protected getBinaryName(appName: string): string {
const extension = process.platform === 'win32' ? '.exe' : '';
- // Linux uses the unique binary name we set in merge.ts
- if (process.platform === 'linux') {
- return `pake-${generateIdentifierSafeName(appName)}${extension}`;
- }
-
- // Windows and macOS use 'pake' as binary name
- return `pake${extension}`;
+ // Use unique binary name for all platforms to avoid conflicts
+ const nameToUse = process.platform === 'linux' ? generateLinuxPackageName(appName) : generateIdentifierSafeName(appName);
+ return `pake-${nameToUse}${extension}`;
}
/**
diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts
index a88f94a7..1bf9135a 100644
--- a/bin/helpers/merge.ts
+++ b/bin/helpers/merge.ts
@@ -7,6 +7,7 @@ import {
generateSafeFilename,
generateIdentifierSafeName,
getSafeAppName,
+ generateLinuxPackageName,
} from '@/utils/name';
import { PakeAppOptions, PlatformMap, WindowConfig } from '@/types';
import { tauriConfigDirectory, npmDirectory } from '@/utils/dir';
@@ -110,9 +111,9 @@ export async function mergeConfig(
tauriConf.identifier = identifier;
tauriConf.version = appVersion;
- if (platform === 'linux') {
- tauriConf.mainBinaryName = `pake-${generateIdentifierSafeName(name)}`;
- }
+ // Always set mainBinaryName to ensure binary uniqueness
+ const linuxBinaryName = `pake-${generateLinuxPackageName(name)}`;
+ tauriConf.mainBinaryName = platform === 'linux' ? linuxBinaryName : `pake-${generateIdentifierSafeName(name)}`;
if (platform == 'win32') {
tauriConf.bundle.windows.wix.language[0] = installerLanguage;
@@ -171,9 +172,9 @@ export async function mergeConfig(
delete tauriConf.bundle.linux.deb.files;
// Generate correct desktop file configuration
- const appNameSafe = getSafeAppName(name);
- const identifier = `com.pake.${appNameSafe}`;
- const desktopFileName = `${identifier}.desktop`;
+ const linuxName = generateLinuxPackageName(name);
+ const desktopFileName = `com.pake.${linuxName}.desktop`;
+ const iconName = `${linuxName}_512`;
// Create desktop file content
// Determine if title contains Chinese characters for Name[zh_CN]
@@ -185,11 +186,12 @@ Type=Application
Name=${name}
${chineseName ? `Name[zh_CN]=${chineseName}` : ''}
Comment=${name}
-Exec=pake-${appNameSafe}
-Icon=${appNameSafe}_512
-Categories=Network;WebBrowser;
+Exec=${linuxBinaryName}
+Icon=${iconName}
+Categories=Network;WebBrowser;Utility;
MimeType=text/html;text/xml;application/xhtml_xml;
StartupNotify=true
+Terminal=false
`;
// Write desktop file to src-tauri/assets directory where Tauri expects it
@@ -200,8 +202,17 @@ StartupNotify=true
// Set up desktop file in bundle configuration
// Use absolute path from src-tauri directory to assets
+ const desktopInstallPath = `/usr/share/applications/${desktopFileName}`;
tauriConf.bundle.linux.deb.files = {
- [`/usr/share/applications/${desktopFileName}`]: `assets/${desktopFileName}`,
+ [desktopInstallPath]: `assets/${desktopFileName}`,
+ };
+
+ // Add desktop file support for RPM
+ if (!tauriConf.bundle.linux.rpm) {
+ tauriConf.bundle.linux.rpm = {};
+ }
+ tauriConf.bundle.linux.rpm.files = {
+ [desktopInstallPath]: `assets/${desktopFileName}`,
};
const validTargets = [
@@ -244,7 +255,7 @@ StartupNotify=true
},
linux: {
fileExt: '.png',
- path: `png/${safeAppName}_512.png`,
+ path: `png/${generateLinuxPackageName(name)}_512.png`,
defaultIcon: 'png/icon_512.png',
message: 'Linux icon must be .png and 512x512px.',
},
diff --git a/dist/cli.js b/dist/cli.js
old mode 100755
new mode 100644
index cd449a9f..83773e3d
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -504,9 +504,9 @@ async function mergeConfig(url, options, tauriConf) {
tauriConf.productName = name;
tauriConf.identifier = identifier;
tauriConf.version = appVersion;
- if (platform === 'linux') {
- tauriConf.mainBinaryName = `pake-${generateIdentifierSafeName(name)}`;
- }
+ // Always set mainBinaryName to ensure binary uniqueness
+ const linuxBinaryName = `pake-${generateLinuxPackageName(name)}`;
+ tauriConf.mainBinaryName = platform === 'linux' ? linuxBinaryName : `pake-${generateIdentifierSafeName(name)}`;
if (platform == 'win32') {
tauriConf.bundle.windows.wix.language[0] = installerLanguage;
}
@@ -551,9 +551,9 @@ async function mergeConfig(url, options, tauriConf) {
// Remove hardcoded desktop files and regenerate with correct app name
delete tauriConf.bundle.linux.deb.files;
// Generate correct desktop file configuration
- const appNameSafe = getSafeAppName(name);
- const identifier = `com.pake.${appNameSafe}`;
- const desktopFileName = `${identifier}.desktop`;
+ const linuxName = generateLinuxPackageName(name);
+ const desktopFileName = `com.pake.${linuxName}.desktop`;
+ const iconName = `${linuxName}_512`;
// Create desktop file content
// Determine if title contains Chinese characters for Name[zh_CN]
const chineseName = title && /[\u4e00-\u9fa5]/.test(title) ? title : null;
@@ -563,11 +563,12 @@ Type=Application
Name=${name}
${chineseName ? `Name[zh_CN]=${chineseName}` : ''}
Comment=${name}
-Exec=pake-${appNameSafe}
-Icon=${appNameSafe}_512
-Categories=Network;WebBrowser;
+Exec=${linuxBinaryName}
+Icon=${iconName}
+Categories=Network;WebBrowser;Utility;
MimeType=text/html;text/xml;application/xhtml_xml;
StartupNotify=true
+Terminal=false
`;
// Write desktop file to src-tauri/assets directory where Tauri expects it
const srcAssetsDir = path.join(npmDirectory, 'src-tauri/assets');
@@ -576,8 +577,16 @@ StartupNotify=true
await fsExtra.writeFile(srcDesktopFilePath, desktopContent);
// Set up desktop file in bundle configuration
// Use absolute path from src-tauri directory to assets
+ const desktopInstallPath = `/usr/share/applications/${desktopFileName}`;
tauriConf.bundle.linux.deb.files = {
- [`/usr/share/applications/${desktopFileName}`]: `assets/${desktopFileName}`,
+ [desktopInstallPath]: `assets/${desktopFileName}`,
+ };
+ // Add desktop file support for RPM
+ if (!tauriConf.bundle.linux.rpm) {
+ tauriConf.bundle.linux.rpm = {};
+ }
+ tauriConf.bundle.linux.rpm.files = {
+ [desktopInstallPath]: `assets/${desktopFileName}`,
};
const validTargets = [
'deb',
@@ -615,7 +624,7 @@ StartupNotify=true
},
linux: {
fileExt: '.png',
- path: `png/${safeAppName}_512.png`,
+ path: `png/${generateLinuxPackageName(name)}_512.png`,
defaultIcon: 'png/icon_512.png',
message: 'Linux icon must be .png and 512x512px.',
},
@@ -1083,12 +1092,9 @@ class BaseBuilder {
*/
getBinaryName(appName) {
const extension = process.platform === 'win32' ? '.exe' : '';
- // Linux uses the unique binary name we set in merge.ts
- if (process.platform === 'linux') {
- return `pake-${generateIdentifierSafeName(appName)}${extension}`;
- }
- // Windows and macOS use 'pake' as binary name
- return `pake${extension}`;
+ // Use unique binary name for all platforms to avoid conflicts
+ const nameToUse = process.platform === 'linux' ? generateLinuxPackageName(appName) : generateIdentifierSafeName(appName);
+ return `pake-${nameToUse}${extension}`;
}
/**
* Check if this build has architecture-specific target
diff --git a/package.json b/package.json
index 96c346d9..e25fcb9c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pake-cli",
- "version": "3.6.3",
+ "version": "3.6.4",
"description": "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。",
"engines": {
"node": ">=18.0.0"
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index d98c8eb0..9d3c4011 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2588,7 +2588,7 @@ dependencies = [
[[package]]
name = "pake"
-version = "3.6.3"
+version = "3.6.4"
dependencies = [
"serde",
"serde_json",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 2882e547..81852832 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pake"
-version = "3.6.3"
+version = "3.6.4"
description = "🤱🏻 Turn any webpage into a desktop app with Rust."
authors = ["Tw93"]
license = "MIT"
diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json
index 067a3caf..cb5eaf82 100644
--- a/src-tauri/tauri.linux.conf.json
+++ b/src-tauri/tauri.linux.conf.json
@@ -1,5 +1,4 @@
{
- "productName": "weekly",
"bundle": {
"icon": ["png/weekly_512.png"],
"active": true,