Package the desktop app with electron-builder --dir on a Gentoo host:

- skip the CI-only beforePack/afterPack checks (dark build, native variants,
  Docker-built helpers, glibc 2.31 floor of the AppImage, daemon boot and
  packaged resources smoke tests); the ebuild builds the native helpers;
- with ORCA_SYSTEM_NODE set, do not bundle the pinned Node in
  resources/node-runtime, which the ebuild links to the system Node, and
  skip the beforeBuild rebuild, which fetches Electron into node_modules:
  the ebuild has built node-pty, an N-API addon, against the system one.

Based on the PF4Public overlay
(dev-util/orca/files/relax-ci-verification-hooks-r2.patch, with the
verifyPackagedPluginTypings line that its ebuild drops with sed).

--- a/config/electron-builder.config.cjs
+++ b/config/electron-builder.config.cjs
@@ -416,36 +416,11 @@
   },
   // electron-builder calls this with the context alone. The second parameter is the bundle root,
   // so a test can point the guard at a scratch bundle instead of needing the repo's out/ built.
-  beforePack: (
-    context,
-    mobileWebBundleDir = MOBILE_WEB_BUNDLE_DIR,
-    ensureWaylandClipboard = ensureBundledWaylandClipboard,
-    orcadTemplateDir = join(__dirname, '..', orcadTemplateExtraResource.from),
-    ensureProviderExec = ensureBundledProviderExec
-  ) => {
-    // The template is the server every SSH host gets, so a dark test template must never ship.
-    assertNotDarkBuild([join(__dirname, '..', 'out', 'main'), mobileWebBundleDir, orcadTemplateDir])
-    assertPackagedNativeVariantsInstalled(context.electronPlatformName, context.arch)
-    assertBundledRipgrepInstalled()
-    assertProcessHostOutputBuilt()
-    assertOrcadTemplateBuilt()
-    assertMobileWebBundleBuilt(mobileWebBundleDir)
-    if (context.electronPlatformName === 'linux') {
-      ensureWaylandClipboard(context.arch)
-    }
-    if (context.electronPlatformName !== 'win32') {
-      ensureProviderExec(context.electronPlatformName, context.arch)
-    }
-    return import('./scripts/native-build/build-journal-file-lock.mjs').then(
-      ({ buildJournalFileLock }) => {
-        const lockName =
-          context.electronPlatformName === 'win32' ? 'journal-file-lock.exe' : 'journal-file-lock'
-        const arch = normalizeElectronArchitecture(context.arch)
-        buildJournalFileLock(join(__dirname, '..', journalFileLockBuildDir, arch, lockName), arch, {
-          glibcFloor: context.electronPlatformName === 'linux' ? 'desktop' : false
-        })
-      }
-    )
+  beforePack: () => {
+    // Gentoo: skip upstream CI-only checks (dark-build, native-variant, bundled
+    // ripgrep, process-host, orcad template, mobile-web assertions) and the
+    // Docker-built native helpers (wayland clipboard, provider-exec, journal
+    // file-lock). The ebuild builds the helpers it needs natively.
   },
   afterPack: async (context) => {
     const resourcesDir =
@@ -518,14 +493,19 @@
     if (context.electronPlatformName === 'linux') {
       const targetArch = { 1: 'x64', 3: 'arm64' }[context.arch]
       // Before the floor gate, so the bundled Node is held to the same glibc floor.
-      appImageNodeRuntime = await placeAppImageNodeRuntime(resourcesDir, targetArch)
+      // Gentoo: resources/node-runtime/bin/node links to the system Node at install time.
+      if (!process.env.ORCA_SYSTEM_NODE) {
+        appImageNodeRuntime = await placeAppImageNodeRuntime(resourcesDir, targetArch)
+      }
       // Why the arch is passed: symbol-version checks pass happily on a wrong-architecture binary,
       // so a cross-built slice could ship the host's pty.node and only fail at runtime.
-      finalizePackagedWaylandClipboard(resourcesDir)
-      finalizePackagedProviderExec(resourcesDir, 'linux')
-      verifyLinuxGlibcFloor(context.appOutDir, { targetArch })
+      // Gentoo: the Wayland clipboard helper and the bundled provider exec are
+      // upstream Docker-built artifacts (the ebuild stages the helper in
+      // src_install when `wayland` is set); skip their finalize checks. A native
+      // build links the host glibc, so the 2.31 floor — a CI guard for the
+      // upstream Ubuntu 20.04 AppImage — does not apply.
     }
-    verifyPackagedMainRuntimeDeps(resourcesDir)
+    // Gentoo: skip the packaged main-runtime dependency check (CI guard).
     // Smoke only host-runnable slices: daemon JS loads target-arch node-pty. Arch enum ia32=0, x64=1, armv7l=2, arm64=3, universal=4.
     const archEnumByNodeArch = { ia32: 0, x64: 1, armv7l: 2, arm64: 3 }
     const hostArchEnum = archEnumByNodeArch[process.arch]
@@ -534,31 +514,15 @@
       verifyPackagedWindowsNodePty(resourcesDir, context.arch, { canExecuteTargetArch })
       verifyPackagedWindowsAgentHook(resourcesDir, context.arch)
     }
-    verifySkillsCliRuntime(join(resourcesDir, 'app.asar.unpacked', 'out'), resourcesDir, {
-      executeCommands: canExecuteTargetArch
-    })
+    // Gentoo: skip the skills CLI runtime verification (CI guard).
     if (!canExecuteTargetArch) {
       console.log(
         `[verify-skills-cli-runtime] skipped command probes on cross-arch slice (target ${context.arch}, host ${process.arch})`
       )
     }
-    if (canExecuteTargetArch) {
-      verifyPackagedDaemonEntryBoots(resourcesDir)
-      if (appImageNodeRuntime) {
-        await verifyAppImageNodeRuntimeServesPty(resourcesDir, appImageNodeRuntime)
-      }
-    } else {
-      // Cross-arch smoke cannot run, but missing unpacked entry is always a packaging error.
-      assertPackagedDaemonEntryExists(resourcesDir)
-      console.log(
-        `[verify-packaged-daemon-entry] skipped boot on cross-arch slice (target ${context.arch}, host ${process.arch})`
-      )
-    }
+    // Gentoo: skip the packaged daemon-entry boot verification (CI guard).
     // Validate real electron-builder output so broken extraResources mappings fail before shipping.
-    verifyPackagedPluginResources(resourcesDir)
-    verifyPackagedPluginTypings(resourcesDir)
-    assertPackagedWebClient(resourcesDir)
-    assertPackagedServeSelectionEntry(resourcesDir)
+    // Gentoo: skip the packaged plugin/web-client/serve-selection checks (CI guards).
     finalizePackagedRipgrep(resourcesDir)
     const agentBrowserDrivers = readdirSync(resourcesDir).filter((filename) =>
       filename.startsWith('agent-browser-')
@@ -849,7 +813,9 @@
     // Why: only an AppImage's files can vanish under a running daemon (see appimage-node-runtime.cjs).
     fpm: appImageNodeRuntimeFpmArgs
   },
-  beforeBuild: electronBuilderNativeRebuild,
+  // Gentoo: the ebuild has built node-pty, an N-API addon, against the system Electron; the
+  // hook would fetch Electron into node_modules to rebuild it.
+  beforeBuild: process.env.ORCA_SYSTEM_NODE ? () => false : electronBuilderNativeRebuild,
   // Dual-arch builds need target node-pty rebuilds or Intel Macs get arm64 binaries and posix_spawnp failure.
   // beforeBuild performs targeted rebuild then returns false to skip optional cpu-features.
   npmRebuild: true,
