mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-30 03:10:16 +08:00
feat(update-center): 统一使用下载包文件进行安装
- 移除 buildLegacySparkUpgradeCommand,所有更新现在需要先下载 deb 包 - 为 APTSS 添加元数据查询功能 - 优化 aria2c 下载参数,使用 metalink URL - 版本号更新至 5.0.0beta4
This commit is contained in:
@@ -66,6 +66,14 @@ const getApmPrintUrisCommand = (pkgname: string) => ({
|
||||
],
|
||||
});
|
||||
|
||||
const getAptssPrintUrisCommand = (pkgname: string) => ({
|
||||
command: "bash",
|
||||
args: [
|
||||
"-lc",
|
||||
`/usr/bin/apt download ${pkgname} --print-uris -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf -o Dir::Etc::sourcelist=/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/aptss.list -o Dir::Etc::sourceparts=/dev/null`,
|
||||
],
|
||||
});
|
||||
|
||||
const runCommandCapture: UpdateCenterCommandRunner = async (
|
||||
command,
|
||||
args,
|
||||
@@ -140,6 +148,42 @@ const loadApmItemMetadata = async (
|
||||
};
|
||||
};
|
||||
|
||||
const loadAptssItemMetadata = async (
|
||||
item: UpdateCenterItem,
|
||||
runCommand: UpdateCenterCommandRunner,
|
||||
): Promise<
|
||||
| { item: UpdateCenterItem; warning?: undefined }
|
||||
| { item: null; warning: string }
|
||||
> => {
|
||||
const printUrisCommand = getAptssPrintUrisCommand(item.pkgname);
|
||||
const metadataResult = await runCommand(
|
||||
printUrisCommand.command,
|
||||
printUrisCommand.args,
|
||||
);
|
||||
const commandError = getCommandError(
|
||||
`aptss metadata query for ${item.pkgname}`,
|
||||
metadataResult,
|
||||
);
|
||||
if (commandError) {
|
||||
return { item: null, warning: commandError };
|
||||
}
|
||||
|
||||
const metadata = parsePrintUrisOutput(metadataResult.stdout);
|
||||
if (!metadata) {
|
||||
return {
|
||||
item: null,
|
||||
warning: `aptss metadata query for ${item.pkgname} returned no package metadata`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
item: {
|
||||
...item,
|
||||
...metadata,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const enrichApmItems = async (
|
||||
items: UpdateCenterItem[],
|
||||
runCommand: UpdateCenterCommandRunner,
|
||||
@@ -156,6 +200,22 @@ const enrichApmItems = async (
|
||||
};
|
||||
};
|
||||
|
||||
const enrichAptssItems = async (
|
||||
items: UpdateCenterItem[],
|
||||
runCommand: UpdateCenterCommandRunner,
|
||||
): Promise<UpdateCenterLoadItemsResult> => {
|
||||
const results = await Promise.all(
|
||||
items.map((item) => loadAptssItemMetadata(item, runCommand)),
|
||||
);
|
||||
|
||||
return {
|
||||
items: results.flatMap((result) => (result.item ? [result.item] : [])),
|
||||
warnings: results.flatMap((result) =>
|
||||
result.warning ? [result.warning] : [],
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const getStoreArch = (
|
||||
item: Pick<UpdateCenterItem, "source" | "arch">,
|
||||
): string => {
|
||||
@@ -299,18 +359,22 @@ export const loadUpdateCenterItems = async (
|
||||
enrichItemCategories(aptssItems),
|
||||
enrichItemCategories(apmItems),
|
||||
]);
|
||||
const enrichedApmItems = await enrichApmItems(
|
||||
categorizedApmItems,
|
||||
runCommand,
|
||||
);
|
||||
const [enrichedAptssItems, enrichedApmItems] = await Promise.all([
|
||||
enrichAptssItems(categorizedAptssItems, runCommand),
|
||||
enrichApmItems(categorizedApmItems, runCommand),
|
||||
]);
|
||||
|
||||
return {
|
||||
items: mergeUpdateSources(
|
||||
enrichItemIcons(categorizedAptssItems),
|
||||
enrichItemIcons(enrichedAptssItems.items),
|
||||
enrichItemIcons(enrichedApmItems.items),
|
||||
installedSources,
|
||||
),
|
||||
warnings: [...warnings, ...enrichedApmItems.warnings],
|
||||
warnings: [
|
||||
...warnings,
|
||||
...enrichedAptssItems.warnings,
|
||||
...enrichedApmItems.warnings,
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user