diff --git a/electron/main/backend/update-center/index.ts b/electron/main/backend/update-center/index.ts index c0eb19c9..808dd7d9 100644 --- a/electron/main/backend/update-center/index.ts +++ b/electron/main/backend/update-center/index.ts @@ -52,7 +52,10 @@ const categoryCache = new Map>(); const APTSS_LIST_UPGRADABLE_COMMAND = { command: "bash", - args: ["-lc", "env LANGUAGE=en_US aptss list --upgradable"], + args: [ + "-lc", + "env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist=/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/aptss.list -o Dir::Etc::sourceparts=/dev/null -o APT::Get::List-Cleanup=0 | awk 'NR>1'", + ], }; const DPKG_QUERY_INSTALLED_COMMAND = { @@ -363,9 +366,10 @@ const isCommandAvailable = async ( }; export const loadUpdateCenterItems = async ( - runCommand: UpdateCenterCommandRunner = runCommandCapture, storeFilter: StoreFilter = "both", + runCommand: UpdateCenterCommandRunner = runCommandCapture, ): Promise => { + console.log(`[UpdateCenter] loadUpdateCenterItems called with storeFilter=${storeFilter}`); const [sparkEnabled, apmEnabled] = await Promise.all([ isSourceEnabled(storeFilter, "spark") ? isCommandAvailable(runCommand, "aptss") @@ -374,6 +378,7 @@ export const loadUpdateCenterItems = async ( ? isCommandAvailable(runCommand, "apm") : Promise.resolve(false), ]); + console.log(`[UpdateCenter] sparkEnabled=${sparkEnabled}, apmEnabled=${apmEnabled}`); const [aptssResult, apmResult, aptssInstalledResult, apmInstalledResult] = await Promise.all([ @@ -397,6 +402,11 @@ export const loadUpdateCenterItems = async ( : Promise.resolve({ code: 0, stdout: "", stderr: "" }), ]); + console.log(`[UpdateCenter] aptssResult: code=${aptssResult.code}, stdout=${aptssResult.stdout.substring(0, 500)}, stderr=${aptssResult.stderr.substring(0, 500)}`); + console.log(`[UpdateCenter] apmResult: code=${apmResult.code}, stdout=${apmResult.stdout.substring(0, 500)}, stderr=${apmResult.stderr.substring(0, 500)}`); + console.log(`[UpdateCenter] aptssInstalledResult: code=${aptssInstalledResult.code}, stdout=${aptssInstalledResult.stdout.substring(0, 500)}`); + console.log(`[UpdateCenter] apmInstalledResult: code=${apmInstalledResult.code}, stdout=${apmInstalledResult.stdout.substring(0, 500)}`); + const aptssAvailable = sparkEnabled && (aptssResult.code === 0 || aptssInstalledResult.code === 0); @@ -421,6 +431,8 @@ export const loadUpdateCenterItems = async ( apmEnabled && apmResult.code === 0 ? parseApmUpgradableOutput(apmResult.stdout) : []; + console.log(`[UpdateCenter] parsed aptssItems count=${aptssItems.length}`, aptssItems.map((i) => `${i.pkgname} ${i.currentVersion}->${i.nextVersion}`)); + console.log(`[UpdateCenter] parsed apmItems count=${apmItems.length}`, apmItems.map((i) => `${i.pkgname} ${i.currentVersion}->${i.nextVersion}`)); const installedSources = buildInstalledSourceMap( aptssAvailable && aptssInstalledResult.code === 0 @@ -428,6 +440,7 @@ export const loadUpdateCenterItems = async ( : "", apmInstalledResult.code === 0 ? apmInstalledResult.stdout : "", ); + console.log(`[UpdateCenter] installedSources size=${installedSources.size}`); const [categorizedAptssItems, categorizedApmItems] = await Promise.all([ aptssAvailable ? enrichItemCategories(aptssItems) : Promise.resolve([]), @@ -441,13 +454,18 @@ export const loadUpdateCenterItems = async ( ? enrichApmItems(categorizedApmItems, runCommand) : Promise.resolve({ items: [], warnings: [] }), ]); + console.log(`[UpdateCenter] enrichedAptssItems: count=${enrichedAptssItems.items.length}, warnings=${enrichedAptssItems.warnings.length}`, enrichedAptssItems.warnings); + console.log(`[UpdateCenter] enrichedApmItems: count=${enrichedApmItems.items.length}, warnings=${enrichedApmItems.warnings.length}`, enrichedApmItems.warnings); + + const mergedItems = mergeUpdateSources( + enrichItemIcons(enrichedAptssItems.items), + enrichItemIcons(enrichedApmItems.items), + installedSources, + ); + console.log(`[UpdateCenter] mergedItems count=${mergedItems.length}`, mergedItems.map((i) => `${i.pkgname} (${i.source}) ${i.currentVersion}->${i.nextVersion}`)); return { - items: mergeUpdateSources( - enrichItemIcons(enrichedAptssItems.items), - enrichItemIcons(enrichedApmItems.items), - installedSources, - ), + items: mergedItems, warnings: [ ...warnings, ...enrichedAptssItems.warnings, diff --git a/electron/main/backend/update-center/query.ts b/electron/main/backend/update-center/query.ts index def20b47..9b4a7899 100644 --- a/electron/main/backend/update-center/query.ts +++ b/electron/main/backend/update-center/query.ts @@ -262,10 +262,19 @@ const compareVersions = (left: string, right: string): number => { export const parseAptssUpgradableOutput = ( output: string, -): UpdateCenterItem[] => parseUpgradableOutput(output, "aptss"); +): UpdateCenterItem[] => { + console.log(`[UpdateCenter] parseAptssUpgradableOutput input (first 1000 chars): ${output.substring(0, 1000)}`); + const result = parseUpgradableOutput(output, "aptss"); + console.log(`[UpdateCenter] parseAptssUpgradableOutput result count=${result.length}`); + return result; +}; -export const parseApmUpgradableOutput = (output: string): UpdateCenterItem[] => - parseUpgradableOutput(output, "apm"); +export const parseApmUpgradableOutput = (output: string): UpdateCenterItem[] => { + console.log(`[UpdateCenter] parseApmUpgradableOutput input (first 1000 chars): ${output.substring(0, 1000)}`); + const result = parseUpgradableOutput(output, "apm"); + console.log(`[UpdateCenter] parseApmUpgradableOutput result count=${result.length}`); + return result; +}; export const parsePrintUrisOutput = ( output: string, @@ -273,8 +282,11 @@ export const parsePrintUrisOutput = ( UpdateCenterItem, "downloadUrl" | "fileName" | "size" | "sha512" > | null => { - const match = output.trim().match(PRINT_URIS_PATTERN); + const trimmed = output.trim(); + console.log(`[UpdateCenter] parsePrintUrisOutput input (first 500 chars): ${trimmed.substring(0, 500)}`); + const match = trimmed.match(PRINT_URIS_PATTERN); if (!match) { + console.log(`[UpdateCenter] parsePrintUrisOutput: no match found for pattern ${PRINT_URIS_PATTERN}`); return null; } diff --git a/electron/main/backend/update-center/service.ts b/electron/main/backend/update-center/service.ts index 2ac6f785..2a425293 100644 --- a/electron/main/backend/update-center/service.ts +++ b/electron/main/backend/update-center/service.ts @@ -166,22 +166,27 @@ export const createUpdateCenterService = ( storeFilter: StoreFilter = currentStoreFilter, ): Promise => { currentStoreFilter = storeFilter; + console.log(`[UpdateCenter] service.refresh called with storeFilter=${storeFilter}`); queue.startRefresh(); emit(); try { const ignoredEntries = await loadIgnored(); + console.log(`[UpdateCenter] ignoredEntries count=${ignoredEntries.size}`); const loadedItems = normalizeLoadedItems( await options.loadItems(currentStoreFilter), ); + console.log(`[UpdateCenter] loadItems returned: items=${loadedItems.items.length}, warnings=${loadedItems.warnings.length}`, loadedItems.warnings); const items = sortIgnoredItems( applyIgnoredEntries(loadedItems.items, ignoredEntries), ); + console.log(`[UpdateCenter] after applying ignored: items=${items.length}`); queue.setItems(items); queue.finishRefresh(loadedItems.warnings); return emit(); } catch (error) { const message = error instanceof Error ? error.message : String(error); + console.error(`[UpdateCenter] refresh error:`, error); queue.setItems([]); applyWarning(message); return emit(); diff --git a/src/__tests__/unit/update-center/load-items.test.ts b/src/__tests__/unit/update-center/load-items.test.ts index b231bc2a..5e8fdaef 100644 --- a/src/__tests__/unit/update-center/load-items.test.ts +++ b/src/__tests__/unit/update-center/load-items.test.ts @@ -11,7 +11,7 @@ type RemoteStoreResponse = | Array>; const APTSS_LIST_UPGRADABLE_KEY = - "bash -lc env LANGUAGE=en_US aptss list --upgradable"; + "bash -lc env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist=/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/aptss.list -o Dir::Etc::sourceparts=/dev/null -o APT::Get::List-Cleanup=0 | awk 'NR>1'"; const DPKG_QUERY_INSTALLED_KEY = "dpkg-query -W -f=${Package}\t${db:Status-Want} ${db:Status-Status} ${db:Status-Eflag}\n"; @@ -191,7 +191,7 @@ describe("update-center load items", () => { ], }); - const result = await loadUpdateCenterItems(async (command, args) => { + const result = await loadUpdateCenterItems("both", async (command, args) => { const key = `${command} ${args.join(" ")}`; const match = commandResults.get(key); if (!match) { @@ -233,7 +233,7 @@ describe("update-center load items", () => { ], }); - const result = await loadUpdateCenterItems(async (command, args) => { + const result = await loadUpdateCenterItems("both", async (command, args) => { const key = `${command} ${args.join(" ")}`; if (key === WHICH_APTSS_KEY) { @@ -360,7 +360,7 @@ describe("update-center load items", () => { throw new Error(`Unexpected command ${key}`); }; - const firstResult = await loadUpdateCenterItems(runCommand); + const firstResult = await loadUpdateCenterItems("both", runCommand); expect(firstResult.items).toEqual([ { @@ -384,7 +384,7 @@ describe("update-center load items", () => { "https://erotica.spark-app.store/amd64-store/office/applist.json" ] = [{ Name: "Spark Notes", Pkgname: "spark-notes" }]; - const secondResult = await loadUpdateCenterItems(runCommand); + const secondResult = await loadUpdateCenterItems("both", runCommand); expect(secondResult.items).toEqual([ { @@ -416,7 +416,7 @@ describe("update-center load items", () => { ], }); - const result = await loadUpdateCenterItems(async (command, args) => { + const result = await loadUpdateCenterItems("both", async (command, args) => { const key = `${command} ${args.join(" ")}`; if (key === WHICH_APTSS_KEY) { @@ -531,7 +531,7 @@ describe("update-center load items", () => { throw new Error(`Unexpected command ${key}`); }); - await loadUpdateCenterItems(runCommand, "apm"); + await loadUpdateCenterItems("apm", runCommand); expect(runCommand).not.toHaveBeenCalledWith( "bash", @@ -590,7 +590,7 @@ describe("update-center load items", () => { throw new Error(`Unexpected command ${key}`); }); - await loadUpdateCenterItems(runCommand, "spark"); + await loadUpdateCenterItems("spark", runCommand); expect(runCommand).not.toHaveBeenCalledWith("apm", [ "list",