Przeglądaj źródła

added installation support for Bazzite, Silverblue, Kinoite and other rpm-ostree systems, where dnf can't change the read-only

UwU 1 miesiąc temu
rodzic
commit
8a386977e7

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "we-manager",
-  "version": "0.8.0",
+  "version": "0.8.1",
   "type": "module",
   "description": "Wallpaper Engine workshop manager",
   "author": "UwU <260361707+WallpaperEngineLover@users.noreply.github.com>",

+ 20 - 3
src/main/services/lwe-prebuilt.service.ts

@@ -10,7 +10,7 @@ import { LWE_RELEASE_REPO } from '@shared/constants'
 import type { LweInstallProgress, LwePrebuiltTarget } from '@shared/types'
 import { isCommandAvailable } from '../utils/platform'
 import { getLwePrebuiltDir } from '../utils/paths'
-import { buildCleanBuildEnv, readPrebuiltRelease, resetLweDetection } from './lwe.service'
+import { buildCleanBuildEnv, isOstreeSystem, readPrebuiltRelease, resetLweDetection } from './lwe.service'
 
 const execFileAsync = promisify(execFile)
 
@@ -133,7 +133,15 @@ async function findMissingLibraries(binary: string): Promise<string[]> {
   return [...missing]
 }
 
-async function installMissingLibraries(distro: PrebuiltDistro, missing: string[]): Promise<void> {
+/** true when layered with rpm-ostree, which needs a reboot */
+async function installMissingLibraries(distro: PrebuiltDistro, missing: string[]): Promise<boolean> {
+  if (distro === 'fedora-44' && isOstreeSystem()) {
+    // --allow-inactive: a provider may already be in the base image
+    await execFileAsync('rpm-ostree', [
+      'install', '--idempotent', '--allow-inactive', ...missing.map(soname => `${soname}()(64bit)`)
+    ], { timeout: 1_200_000, maxBuffer: 10 * 1024 * 1024 })
+    return true
+  }
   const elevate = isCommandAvailable('pkexec') ? 'pkexec' : 'sudo'
   let command: string[]
   switch (distro) {
@@ -145,6 +153,7 @@ async function installMissingLibraries(distro: PrebuiltDistro, missing: string[]
       break
   }
   await execFileAsync(elevate, command, { timeout: 600_000, maxBuffer: 10 * 1024 * 1024 })
+  return false
 }
 
 export async function installLwePrebuilt(win: BrowserWindow): Promise<void> {
@@ -205,7 +214,15 @@ export async function installLwePrebuilt(win: BrowserWindow): Promise<void> {
         message: `Installing missing system libraries (sudo required): ${missing.join(', ')}`,
         percentage: 88
       })
-      await installMissingLibraries(distro, missing)
+      if (await installMissingLibraries(distro, missing)) {
+        resetLweDetection()
+        send({
+          stage: 'done',
+          message: `linux-wallpaperengine ${release.tag_name} installed. The missing system libraries (${missing.join(', ')}) were added with rpm-ostree, reboot once before using it.`,
+          percentage: 100
+        })
+        return
+      }
       missing = await findMissingLibraries(binary)
       if (missing.length > 0) {
         throw new Error(`These system libraries are still missing: ${missing.join(', ')}. Install them with your package manager, or build from source.`)

+ 12 - 1
src/main/services/lwe.service.test.ts

@@ -12,7 +12,7 @@ vi.mock('./config.service', () => ({
   getDisablePuppetAnimation: () => false
 }))
 
-const { buildCleanBuildEnv, buildHotswapLines, nodeDevelPackage, parseCustomArgs } = await import('./lwe.service')
+const { buildCleanBuildEnv, buildHotswapLines, nodeDevelPackage, parseCustomArgs, parseOsReleaseIds } = await import('./lwe.service')
 
 describe('parseCustomArgs', () => {
   it('splits on whitespace and keeps quoted values together', () => {
@@ -134,3 +134,14 @@ describe('nodeDevelPackage', () => {
     expect(nodeDevelPackage(['nodejs24-docs'])).toBe('nodejs-devel')
   })
 })
+
+describe('parseOsReleaseIds', () => {
+  it('lists ID before ID_LIKE', () => {
+    const bazzite = 'NAME="Bazzite"\nVERSION_ID="44"\nID=bazzite\nID_LIKE="fedora"\nVARIANT_ID=bazzite-deck\n'
+    expect(parseOsReleaseIds(bazzite)).toEqual(['bazzite', 'fedora'])
+  })
+
+  it('splits several parents and ignores VARIANT_ID', () => {
+    expect(parseOsReleaseIds('ID=pop\nID_LIKE="ubuntu debian"\nVARIANT_ID=x')).toEqual(['pop', 'ubuntu', 'debian'])
+  })
+})

+ 32 - 5
src/main/services/lwe.service.ts

@@ -208,16 +208,34 @@ export function resetLweDetection(): void {
   invalidateHelpText()
 }
 
+export function parseOsReleaseIds(release: string): string[] {
+  const ids: string[] = []
+  for (const line of release.split('\n')) {
+    const match = /^(ID|ID_LIKE)=(.*)$/.exec(line.trim())
+    if (match) ids.push(...match[2].replace(/^["']|["']$/g, '').toLowerCase().split(/\s+/).filter(Boolean))
+  }
+  return ids
+}
+
 export function detectDistro(): LinuxDistro {
+  let ids: string[]
   try {
-    const release = fs.readFileSync('/etc/os-release', 'utf8').toLowerCase()
-    if (release.includes('id=fedora') || release.includes('id=nobara') || release.includes('id=rhel') || release.includes('id=centos')) return 'fedora'
-    if (release.includes('id=arch') || release.includes('id=manjaro') || release.includes('id=endeavouros')) return 'arch'
-    if (release.includes('id=debian') || release.includes('id=ubuntu') || release.includes('id=linuxmint') || release.includes('id=pop')) return 'debian'
-  } catch { /* no os-release */ }
+    ids = parseOsReleaseIds(fs.readFileSync('/etc/os-release', 'utf8'))
+  } catch {
+    return 'unknown'
+  }
+  for (const id of ids) {
+    if (['fedora', 'nobara', 'rhel', 'centos'].includes(id)) return 'fedora'
+    if (['arch', 'manjaro', 'endeavouros'].includes(id)) return 'arch'
+    if (['debian', 'ubuntu', 'linuxmint', 'pop'].includes(id)) return 'debian'
+  }
   return 'unknown'
 }
 
+export function isOstreeSystem(): boolean {
+  return fs.existsSync('/run/ostree-booted')
+}
+
 // Aligned with https://github.com/Almamu/linux-wallpaperengine (README + Wayland + FBOProvider gmpxx)
 const DEPS_DEBIAN = [
   'git', 'build-essential', 'cmake', 'pkg-config',
@@ -292,6 +310,15 @@ export async function installLweDeps(win: BrowserWindow): Promise<void> {
     return
   }
 
+  if (isOstreeSystem()) {
+    send({
+      stage: 'error',
+      message: 'This is an image-based system (rpm-ostree, e.g. Bazzite or Silverblue), the build dependencies can\'t be installed with dnf here. Use the prebuilt download above instead, or build inside a toolbox/distrobox container.',
+      percentage: 0
+    })
+    return
+  }
+
   let pkgManager: string
   let installArgs: string[]
   let packages: string[]