Ver Fonte

.deb and .rpm support (#1500)

Lutz Roeder há 6 meses atrás
pai
commit
2f2b89d706

+ 2 - 0
.github/workflows/build.yml

@@ -49,6 +49,8 @@ jobs:
               CSC_IDENTITY_AUTO_DISCOVERY=false npx electron-builder --mac --universal --publish never -c.mac.identity=null
               ;;
             ubuntu*)
+              sudo apt-get install rpm --yes
+              npx electron-builder --linux deb --x64 --arm64 --publish never
               npx electron-builder --linux appimage --x64 --publish never
               npx electron-builder --linux snap --x64 --publish never
               ;;

+ 3 - 1
.github/workflows/publish.yml

@@ -59,8 +59,10 @@ jobs:
               npx electron-builder --mac --universal --publish always
               ;;
             ubuntu*)
-              sudo snap install snapcraft --classic
+              sudo apt-get install rpm --yes
+              npx electron-builder --linux deb rpm --x64 --arm64 --publish always
               npx electron-builder --linux appimage --x64 --publish always
+              sudo snap install snapcraft --classic
               npx electron-builder --linux snap --x64 --publish always
               ;;
             windows*)

+ 4 - 4
README.md

@@ -13,13 +13,13 @@ Netron has experimental support for TorchScript, torch.export, ExecuTorch, Tenso
 
 ## Install
 
-**macOS**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.dmg` file or run `brew install --cask netron`
+**Browser**: [**Start**](https://netron.app) the browser version.
 
-**Linux**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.AppImage` file or run `snap install netron`
+**macOS**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.dmg` file or run `brew install --cask netron`.
 
-**Windows**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.exe` installer or run `winget install -s winget netron`
+**Linux**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.deb` or `.rpm` file.
 
-**Browser**: [**Start**](https://netron.app) the browser version.
+**Windows**: [**Download**](https://github.com/lutzroeder/netron/releases/latest) the `.exe` installer or run `winget install -s winget netron`.
 
 **Python**: `pip install netron`, then run `netron [FILE]` or `netron.start('[FILE]')`.
 

+ 2 - 2
package.js

@@ -278,7 +278,7 @@ const build = async (target) => {
             const table = new Map([
                 ['mac',     'npx electron-builder --mac --universal --publish never -c.mac.identity=null'],
                 ['windows', 'npx electron-builder --win --x64 --arm64 --publish never'],
-                ['linux',   'npx electron-builder --linux appimage --x64 --publish never']
+                ['linux',   'npx electron-builder --linux deb rpm --x64 --arm64 --publish never']
             ]);
             const targets = table.has(key) ? [table.get(key)] : Array.from(table.values());
             for (const target of targets) {
@@ -339,7 +339,7 @@ const publish = async (target) => {
             const table = new Map([
                 ['mac',     'npx electron-builder --mac --universal --publish always'],
                 ['windows', 'npx electron-builder --win --x64 --arm64 --publish always'],
-                ['linux',   'npx electron-builder --linux appimage --x64 --publish always']
+                ['linux',   'npx electron-builder --linux deb rpm --x64 --arm64 --publish always']
             ]);
             const targets = table.has(key) ? [table.get(key)] : Array.from(table.values());
             for (const target of targets) {

+ 1 - 1
publish/electron-builder.json

@@ -73,7 +73,7 @@
         { "provider": "github", "releaseType": "release" }
     ],
     "linux": {
-        "target": [ "AppImage", "snap" ],
+        "target": [ "deb", "rpm", "AppImage", "snap" ],
         "artifactName":"${productName}-${version}-${arch}.${ext}"
     },
     "mac": {

+ 36 - 7
source/desktop.mjs

@@ -1,5 +1,6 @@
 
 import * as base from './base.js';
+import * as child_process from 'child_process';
 import * as electron from 'electron';
 import * as fs from 'fs';
 import * as http from 'http';
@@ -49,13 +50,31 @@ desktop.Host = class {
         }
         const metadata = [];
         metadata.push(os.arch());
-        if (process.env.APPIMAGE) {
-            metadata.push('appimage');
-        } else if (process.env.SNAP) {
-            metadata.push('snap');
-        } else {
-            metadata.push('');
+        let packager = '';
+        if (process.platform === 'linux') {
+            if (!packager && process.env.APPIMAGE) {
+                packager = 'appimage';
+            } else if (!packager && process.env.SNAP) {
+                packager = 'snap';
+            } else if (!packager) {
+                try {
+                    child_process.execFileSync('dpkg', ['-S', process.execPath]);
+                    packager = 'deb';
+                } catch {
+                    // continue regardless of error
+                }
+            /* eslint-disable no-dupe-else-if */
+            } else if (!packager) {
+            /* eslint-enable no-dupe-else-if */
+                try {
+                    child_process.execFileSync("rpm", ["-qf", process.execPath]);
+                    packager = 'rpm';
+                } catch {
+                    // continue regardless of error
+                }
+            }
         }
+        metadata.push(packager);
         this._metadata = metadata.join('|');
     }
 
@@ -81,6 +100,16 @@ desktop.Host = class {
 
     async view(view) {
         this._view = view;
+        if (process.env.SNAP === 'skip') {
+            this.document.body.classList.remove('spinner');
+            await this.message('Please <a href="https://github.com/lutzroeder/netron/issues/1500" target="_blank">migrate</a> as Snap support will be discontinued.', null, 'OK');
+            this.document.body.classList.add('spinner');
+        }
+        if (process.env.APPIMAGE === 'skip') {
+            this.document.body.classList.remove('spinner');
+            await this.message('Please <a href="https://github.com/lutzroeder/netron/issues/1500" target="_blank">migrate</a> as AppImage support will be discontinued.', null, 'OK');
+            this.document.body.classList.add('spinner');
+        }
         const age = async () => {
             const days = (new Date() - new Date(this._environment.date)) / (24 * 60 * 60 * 1000);
             if (days > 180) {
@@ -582,7 +611,7 @@ desktop.Host = class {
     async message(message, alert, action) {
         return new Promise((resolve) => {
             const type = this.document.body.getAttribute('class');
-            this._element('message-text').innerText = message || '';
+            this._element('message-text').innerHTML = message || '';
             const button = this._element('message-button');
             if (action) {
                 button.style.removeProperty('display');

+ 6 - 0
source/index.html

@@ -51,6 +51,9 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .toolbar-icon:hover .fill { fill: #000000; }
 .message { display: none; opacity: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%; flex-direction: column; justify-content: flex-start; }
 .message-text { display: inline; text-align: center; width: 562px; font-size: 13px; line-height: 20px; margin-top: 50vh; padding-top: 56px; padding-bottom: 20px; margin-left: auto; margin-right: auto; user-select: text; -webkit-user-select: text; -moz-user-select: text; }
+.welcome .message-text a { text-decoration: none; color: #666666; }
+.welcome .message-text a:visited { color: inherit; }
+.welcome .message-text a:hover { color: #242424; text-decoration: underline; }
 .message-button { display: inline; text-align: center; width: 125px; margin-left: auto; margin-right: auto; }
 .logo-text { top: -57px; width: 582px; transition: 0.1s; }
 .logo-name { top: -170px; width: 582px; transition: 0.1s; }
@@ -155,6 +158,9 @@ button { font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI"
 .about .logo { background-color: #1e1e1e; color: #888888; }
 .about a { color: #c6c6c6; }
 .about a:hover { color: #565656; }
+.welcome .message-text a { color: #c6c6c6; }
+.welcome .message-text a:visited { color: #c6c6c6; }
+.welcome .message-text a:hover { color: #565656; }
 .toolbar-icon .border { stroke: #333333; }
 .toolbar-icon .stroke { stroke: #aaaaaa; }
 .toolbar-icon .fill { fill: #aaaaaa; }