Debian Codegraph @

pkg/lib/_internal/dnf5daemon.ts

raw
1 /*
2 * Copyright (C) 2025 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 import cockpit from "cockpit";
7 import { superuser } from 'superuser';
8 import { InstallProgressCB, MissingPackages, PackageManager, ProgressCB, ResolveError, InstallProgressType, UpdateDetail, Update, Severity, History } from './packagemanager-abstract';
9
10 let _dbus_client: cockpit.DBusClient | null = null;
11
12 /**
13 * Get dnf5daemon D-Bus client
14 *
15 * This will get lazily initialized and re-initialized after dnf5daemon
16 * disconnects (due to a crash or idle timeout).
17 */
18 function dbus_client() {
19 if (_dbus_client === null) {
20 _dbus_client = cockpit.dbus("org.rpm.dnf.v0", { superuser: "try", track: true });
21 _dbus_client.addEventListener("close", () => {
22 console.warn("dnf5daemon went away from D-Bus");
23 _dbus_client = null;
24 });
25 }
26
27 return _dbus_client;
28 }
29
30 // Reconnect when privileges change
31 superuser.addEventListener("changed", () => {
32 if (_dbus_client)
33 _dbus_client.close();
34 _dbus_client = null;
35 });
36
37 async function open_session(): Promise<string> {
38 const [session] = await call("/org/rpm/dnf/v0", "org.rpm.dnf.v0.SessionManager",
39 "open_session", [{}]) as string[];
40 return session;
41 }
42
43 function close_session(session: string) {
44 return call("/org/rpm/dnf/v0", "org.rpm.dnf.v0.SessionManager",
45 "close_session", [session]);
46 }
47
48 interface ListPackage {
49 arch: { t: "s", v: string }
50 download_size: { t: "t", "v": number }
51 id: { t: "i"; v: number };
52 is_installed: { t: "b"; v: boolean };
53 name: { t: "s"; v: string };
54 release: { t: "s"; v: string };
55 version: { t: "s"; v: string };
56 nevra?: { t: "s"; v: string };
57 }
58
59 interface CollectionPackage {
60 // arch
61 a: { t: "s"; v: string };
62 // epoch
63 e: { t: "s"; v: string };
64 // name
65 n: { t: "s"; v: string };
66 nevra: { t: "s"; v: string };
67 // release
68 r: { t: "s"; v: string };
69 // version
70 v: { t: "s"; v: string };
71 }
72
73 type AdvisoryType = "bugfix" | "enhancement" | "security" | "newpackage";
74
75 interface ListAdvisory {
76 advisoryid: { t: "i", v: number };
77 name: { t: "s", v: string };
78 description: { t: "s", v: string };
79 status: { t: "s", v: string };
80 severity: { t: "s", v: Severity };
81 type: { t: "s", v: AdvisoryType };
82 collections: { t: "aa{sv}", v: [ { packages: { t: "aa{sv}", v: CollectionPackage[] } } ] }
83 // Array of id, type, title, url
84 references: { t: "a(ssss)", v: [string, string, string, string] }
85 }
86
87 interface ResolvePackage {
88 arch: { t: "s"; v: string };
89 download_size: { t: "t"; v: number };
90 epoch: { t: "s"; v: string };
91 evr: { t: "s"; v: string };
92 from_repo_id: { t: "s"; v: string };
93 id: { t: "i"; v: number };
94 install_size: { t: "t"; v: number };
95 name: { t: "s"; v: string };
96 reason: { t: "s"; v: string };
97 release: { t: "s"; v: string };
98 repo_id: { t: "s"; v: string };
99 version: { t: "s"; v: string };
100 }
101
102 interface TransactionProblem {
103 action: { t: "u", v: number };
104 additional_data: { t: "as", "v": string[] };
105 goal_job_settings: { t: "a{vs}", "v": { to_repo_ids: { t: "as", v: string[] } } };
106 problem: { t: "u", v: number };
107 spec: { t: "s", v: "appstream-data" };
108 }
109
110 interface RepoListResult {
111 cache_updated: { t: "x", "v": number };
112 }
113
114 interface HistoryListPackage {
115 arch: { t: "s", v: string }
116 evr: { t: "s", v: string }
117 name: { t: "s", v: string }
118 }
119
120 interface HistoryListResult {
121 id: { t: "x", "v": number };
122 start: { t: "x", "v": number };
123 end: { t: "x", "v": number };
124 user_id: { t: "u", "v": number };
125 status: { t: "s", "v": string };
126 description: { t: "s", "v": string };
127 downgraded: { t: "aa{sv}", "v": HistoryListPackage[] };
128 installed: { t: "aa{sv}", "v": HistoryListPackage[] };
129 reinstalled: { t: "aa{sv}", "v": HistoryListPackage[] };
130 removed: { t: "aa{sv}", "v": HistoryListPackage[] };
131 upgraded: { t: "aa{sv}", "v": HistoryListPackage[] };
132 }
133
134 enum GoalProblem {
135 ALREADY_INSTALLED = (1 << 12)
136 }
137
138 // TransactionItemType
139 type object_type = "Package" | "Group" | "Environment" | "Module" | "Skipped";
140 // TransactionItemAction
141 type action = "Install" | "Upgrade" | "Downgrade" | "Reinstall" | "Remove" | "Replaced" | "Reset" | "Enable" | "Disable" | "Reason Change" | "Switch"
142 // TransactionItemReason
143 type reason = "User" | "Dependency" | "Clean" | "Group" | "None" | "Weak Dependency" | "External User"
144 type TransactionItem = [
145 object_type,
146 action,
147 reason,
148 unknown,
149 ResolvePackage
150 ]
151
152 type InstallResolveResult = [TransactionItem[], number]
153 type RemoveResolveResult = [TransactionItem[], number]
154 type UpgradeResolveResult = [TransactionItem[], number]
155
156 type SignalCB = (_path: string, _iface: string, signal: string, args: unknown[]) => void
157
158 /**
159 * Call a dnf5daemon method
160 */
161 function call(objectPath: string, iface: string, method: string, args?: unknown[], opts?: cockpit.DBusCallOptions) {
162 return dbus_client().call(objectPath, iface, method, args, opts);
163 }
164
165 export class Dnf5DaemonManager implements PackageManager {
166 name: string;
167
168 constructor() {
169 this.name = 'dnf5daemon';
170 }
171
172 private async with_session(executor: (session: string) => Promise<void>, signal_handler?: SignalCB): Promise<void> {
173 let session: string | null = null;
174 let subscription: { remove: () => void } | null = null;
175
176 const client = dbus_client();
177 if (signal_handler)
178 subscription = client.subscribe({}, signal_handler);
179
180 try {
181 session = await open_session();
182 await executor(session);
183 } finally {
184 if (session)
185 await close_session(session);
186 if (subscription)
187 subscription.remove();
188 }
189 }
190
191 async check_missing_packages(pkgnames: string[], progress_cb?: ProgressCB): Promise<MissingPackages> {
192 const data: MissingPackages = {
193 extra_names: [],
194 missing_ids: [],
195 missing_names: [],
196 unavailable_names: [],
197 remove_names: [],
198 download_size: 0,
199 };
200
201 if (pkgnames.length === 0)
202 return data;
203
204 async function resolve(session: string) {
205 const installed_names = new Set();
206 const seen_names = new Set();
207 const package_attrs = ["name", "is_installed"];
208
209 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Rpm", "list", [
210 {
211 package_attrs: { t: 'as', v: package_attrs },
212 scope: { t: 's', v: "all" },
213 patterns: { t: 'as', v: pkgnames }
214 }
215 ]) as ListPackage[][];
216
217 for (const pkg of results) {
218 if (seen_names.has(pkg.name.v))
219 continue;
220
221 if (pkg.is_installed.v) {
222 installed_names.add(pkg.name.v);
223 } else {
224 data.missing_ids.push(pkg.name.v);
225 data.missing_names.push(pkg.name.v);
226 }
227
228 seen_names.add(pkg.name.v);
229 }
230
231 pkgnames.forEach((name: string) => {
232 if (!installed_names.has(name) && data.missing_names.indexOf(name) == -1)
233 data.unavailable_names.push(name);
234 });
235 }
236
237 async function simulate(session: string) {
238 if (data.missing_ids.length === 0 || data.unavailable_names.length > 0) {
239 return null;
240 }
241
242 await call(session, "org.rpm.dnf.v0.rpm.Rpm", "install", [pkgnames, {}]);
243 const [transaction_items, result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]) as InstallResolveResult;
244 if (result !== 0) {
245 const [problems] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems", []) as TransactionProblem[][];
246 // If all the problems relating to the check for missing packages is about it already being installed, clear it
247 if (problems.every((p: TransactionProblem) => p.problem.v === GoalProblem.ALREADY_INSTALLED)) {
248 await call(session, "org.rpm.dnf.v0.Goal", "reset", []);
249 } else {
250 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
251 throw new ResolveError(`Resolving install failed with result=${result}. ${problem}`);
252 }
253 }
254
255 for (const transaction_item of transaction_items) {
256 const [object_type, action, reason, _transaction_item_attributes, pkg] = transaction_item;
257 const name = pkg.name.v;
258
259 if (object_type !== "Package") {
260 console.error(`Simulated install for ${pkgnames} resolved an unexpected object_type=${object_type}`);
261 continue;
262 }
263
264 data.download_size += pkg.download_size.v;
265
266 if (reason == "Dependency") {
267 if (data.missing_names.indexOf(name) == -1)
268 data.extra_names.push(name);
269 }
270
271 if (action == "Replaced") {
272 if (data.remove_names.indexOf(name) == -1)
273 data.remove_names.push(name);
274 }
275 }
276
277 // Call reset() as we don't intend to complete the transaction using `do_transaction`
278 await call(session, "org.rpm.dnf.v0.Goal", "reset", []);
279 }
280
281 function signal_emitted(_path: string, _iface: string, _signal: string, _args: unknown[]) {
282 // HACK: dnf5daemon doesn't give us an useful progress indicator so the progress percentage is hardcoded to 0.
283 if (progress_cb) {
284 progress_cb({
285 waiting: false,
286 percentage: 0,
287 cancel: null,
288 });
289 }
290 }
291
292 await this.refresh(false);
293 await this.with_session(async (session) => {
294 try {
295 await resolve(session);
296 await simulate(session);
297 } catch (err) {
298 console.warn("check_missing_packages", err);
299 throw err;
300 }
301 }, signal_emitted);
302
303 return data;
304 }
305
306 async install_missing_packages(data: MissingPackages, progress_cb?: InstallProgressCB): Promise<void> {
307 if (!data || data.missing_ids.length === 0)
308 return;
309
310 let last_info: number;
311 let last_progress = 0;
312 let last_name: string;
313 let total_packages: number;
314
315 function signal_emitted(_path: string, _iface: string, signal: string, args: unknown[]) {
316 switch (signal) {
317 // download_add_new(o session_object_path, s download_id, s description, x total_to_download)
318 case 'download_add_new': {
319 last_info = InstallProgressType.DOWNLOADING;
320 last_name = args[2] as string;
321 break;
322 }
323 // download_progress(o session_object_path, s download_id, x total_to_download, x downloaded)
324 case 'download_progress': {
325 last_info = InstallProgressType.DOWNLOADING;
326 break;
327 }
328 // download_end(o session_object_path, s download_id, u transfer_status, s message)
329 case 'download_end':
330 last_info = 0;
331 last_name = "";
332 break;
333 // transaction_before_begin(o session_object_path, t total)
334 case 'transaction_before_begin':
335 [, total_packages] = args as [string, number];
336 last_info = InstallProgressType.INSTALLING;
337 break;
338 // transaction_elem_progress(o session_object_path, s nevra, t processed, t total)
339 case 'transaction_elem_progress': {
340 let processed = 0;
341 [, last_name, processed,] = args as [string, string, number, number];
342 last_progress = processed / total_packages * 100;
343 break;
344 }
345 }
346
347 if (progress_cb)
348 progress_cb({
349 cancel: null,
350 info: last_info,
351 package: last_name,
352 percentage: last_progress,
353 waiting: false,
354 });
355 }
356
357 await this.with_session(async (session) => {
358 try {
359 await call(session, "org.rpm.dnf.v0.rpm.Rpm", "install", [data.missing_names, {}]);
360 const [, resolve_result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]);
361
362 if (resolve_result !== 0) {
363 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
364 throw new ResolveError(`Resolving install failed with result=${resolve_result} ${problem}`);
365 }
366 await call(session, "org.rpm.dnf.v0.Goal", "do_transaction", [{}]);
367 } catch (err) {
368 console.warn("install error", err);
369 }
370 }, signal_emitted);
371 }
372
373 async refresh(_force: boolean, _progress_cb?: ProgressCB): Promise<void> {
374 await this.with_session(async (session) => {
375 // refresh dnf5daemon state
376 await call(session, "org.rpm.dnf.v0.Base", "read_all_repos", []);
377 const [, resolve_result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]) as [unknown[], number];
378 if (resolve_result !== 0) {
379 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
380 throw new ResolveError(`Resolving read_all_repos failed with result=${resolve_result} - ${problem}`);
381 }
382
383 await call(session, "org.rpm.dnf.v0.Goal", "do_transaction", [{}]);
384 });
385 }
386
387 async is_installed(pkgnames: string[]): Promise<boolean> {
388 const uninstalled = new Set(pkgnames);
389
390 await this.with_session(async (session) => {
391 const package_attrs = ["name", "is_installed"];
392
393 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Rpm", "list", [
394 {
395 package_attrs: { t: 'as', v: package_attrs },
396 scope: { t: 's', v: "all" },
397 patterns: { t: 'as', v: pkgnames }
398 }
399 ]) as ListPackage[][];
400
401 for (const pkg of results) {
402 if (pkg.is_installed.v) {
403 uninstalled.delete(pkg.name.v);
404 }
405 }
406 });
407
408 return uninstalled.size === 0;
409 }
410
411 async install_packages(pkgnames: string[], progress_cb?: ProgressCB): Promise<void> {
412 let last_progress = 0;
413 let total_packages: number;
414
415 function signal_emitted(_path: string, _iface: string, signal: string, args: unknown[]) {
416 switch (signal) {
417 case 'transaction_before_begin':
418 [, total_packages] = args as [string, number];
419 break;
420 case 'transaction_elem_progress': {
421 const [, _last_name, processed,] = args as [string, string, number, number];
422 last_progress = processed / total_packages * 100;
423 break;
424 }
425 }
426
427 if (progress_cb) {
428 progress_cb({
429 waiting: false,
430 percentage: last_progress,
431 cancel: null,
432 });
433 }
434 }
435
436 await this.with_session(async (session) => {
437 await call(session, "org.rpm.dnf.v0.rpm.Rpm", "install", [pkgnames, {}]);
438 const [_transaction_items, result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]) as InstallResolveResult;
439 if (result !== 0) {
440 const [problems] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems", []) as TransactionProblem[][];
441 if (problems.every((p: TransactionProblem) => p.problem.v == GoalProblem.ALREADY_INSTALLED)) {
442 await call(session, "org.rpm.dnf.v0.Goal", "reset", []);
443 return;
444 }
445
446 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
447 throw new ResolveError(`Resolving install failed with result=${result}. ${problem}`);
448 }
449 await call(session, "org.rpm.dnf.v0.Goal", "do_transaction", [{}]);
450 }, signal_emitted);
451 }
452
453 async remove_packages(pkgnames: string[], progress_cb?: ProgressCB): Promise<void> {
454 let last_progress = 0;
455 let total_packages: number;
456
457 function signal_emitted(_path: string, _iface: string, signal: string, args: unknown[]) {
458 switch (signal) {
459 case 'transaction_before_begin':
460 [, total_packages] = args as [string, number];
461 break;
462 case 'transaction_elem_progress': {
463 const [, _last_name, processed,] = args as [string, string, number, number];
464 last_progress = processed / total_packages * 100;
465 break;
466 }
467 }
468
469 if (progress_cb) {
470 progress_cb({
471 waiting: false,
472 percentage: last_progress,
473 cancel: null,
474 });
475 }
476 }
477
478 await this.with_session(async (session) => {
479 await call(session, "org.rpm.dnf.v0.rpm.Rpm", "remove", [pkgnames, {}]);
480 const [_transaction_items, result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]) as RemoveResolveResult;
481 if (result !== 0) {
482 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
483 throw new ResolveError(`Resolving remove failed with result=${result}. ${problem}`);
484 }
485 await call(session, "org.rpm.dnf.v0.Goal", "do_transaction", [{}]);
486 }, signal_emitted);
487 }
488
489 async find_file_packages(files: string[], progress_cb?: ProgressCB): Promise<string[]> {
490 const installed: string[] = [];
491
492 await this.with_session(async (session) => {
493 const package_attrs = ["name"];
494
495 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Rpm", "list", [
496 {
497 package_attrs: { t: 'as', v: package_attrs },
498 scope: { t: 's', v: "installed" },
499 patterns: { t: 'as', v: files },
500 with_filenames: { t: 'b', v: true },
501 }
502 ]) as ListPackage[][];
503 for (const result of results) {
504 installed.push(result.name.v);
505 }
506
507 // HACK: no usable progress event, but we need to send something to make refresh work.
508 if (progress_cb)
509 progress_cb({ percentage: 100, waiting: false, cancel: null });
510 });
511
512 return installed;
513 }
514
515 async get_updates<T extends boolean>(detail: T, _progress_cb?: ProgressCB): Promise<T extends true ? UpdateDetail[] : Update[]> {
516 const update_map = new Map<string, Update | UpdateDetail>();
517 const package_attrs = ["name", "version", "arch", "epoch", "nevra"];
518
519 await this.with_session(async (session) => {
520 const pkgnames = [];
521 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Rpm", "list", [
522 {
523 package_attrs: { t: 'as', v: package_attrs },
524 scope: { t: 's', v: "upgrades" },
525 }
526 ]) as ListPackage[][];
527
528 for (const result of results) {
529 cockpit.assert(result.nevra, "nevra not set");
530
531 pkgnames.push(result.name.v);
532 update_map.set(result.nevra.v, {
533 id: result.name.v,
534 name: result.name.v,
535 arch: result.arch.v,
536 version: result.version.v,
537 });
538 }
539
540 if (detail) {
541 const advisory_attrs = ["advisoryid", "name", "title", "type", "severity", "description", "references", "collections", "message"];
542 const [advisories] = await call(session, "org.rpm.dnf.v0.Advisory", "list", [
543 {
544 advisory_attrs: { t: 'as', v: advisory_attrs },
545 availability: { t: 's', v: "upgrades" },
546 contains_pkgs: { t: 'as', v: pkgnames },
547 }
548 ]) as ListAdvisory[][];
549
550 for (const advisory of advisories) {
551 for (const collection of advisory.collections.v) {
552 for (const pkg of collection.packages.v) {
553 let update = update_map.get(pkg.nevra.v);
554 if (!update)
555 continue;
556
557 const bug_urls: string[] = [];
558 const cve_urls: string[] = [];
559 const vendor_urls: string[] = [];
560
561 for (const [, type, _title, url] of advisory.references.v) {
562 switch (type) {
563 case "bugzilla":
564 bug_urls.push(url);
565 break;
566 case "cve":
567 cve_urls.push(url);
568 break;
569 case "vendor":
570 vendor_urls.push(url);
571 break;
572 }
573 }
574
575 // Map the advisory type to the severity which PackageKit uses
576 // Critical == Security update
577 // Important == Bug fix
578 // Moderate == Enhancement
579 let severity = Severity.LOW;
580 switch (advisory.type.v) {
581 case "bugfix":
582 severity = Severity.IMPORTANT;
583 break;
584 case "enhancement":
585 severity = Severity.MODERATE;
586 break;
587 case "security":
588 severity = Severity.CRITICAL;
589 break;
590 }
591
592 update = {
593 ...update,
594 description: advisory.description.v,
595 severity,
596 markdown: false,
597 bug_urls,
598 cve_urls,
599 vendor_urls,
600 };
601 update_map.set(pkg.nevra.v, update);
602
603 break;
604 }
605 }
606 }
607 }
608 });
609
610 return Array.from(update_map.values()) as T extends true ? UpdateDetail[] : Update[];
611 }
612
613 async update_packages(updates: Update[] | UpdateDetail[], progress_cb?: ProgressCB, _transaction_path?: string): Promise<void> {
614 const pkgnames = updates.map(update => update.id);
615 let last_progress = 0;
616 let total_packages: number;
617
618 function signal_emitted(_path: string, _iface: string, signal: string, args: unknown[]) {
619 switch (signal) {
620 case 'transaction_before_begin':
621 [, total_packages] = args as [string, number];
622 break;
623 case 'transaction_elem_progress': {
624 const [, _last_name, processed,] = args as [string, string, number, number];
625 last_progress = processed / total_packages * 100;
626 break;
627 }
628 }
629
630 if (progress_cb) {
631 progress_cb({
632 waiting: false,
633 percentage: last_progress,
634 cancel: null,
635 });
636 }
637 }
638
639 await this.with_session(async (session) => {
640 await call(session, "org.rpm.dnf.v0.rpm.Rpm", "upgrade", [pkgnames, {}]);
641 const [_transaction_items, result] = await call(session, "org.rpm.dnf.v0.Goal", "resolve", [{}]) as UpgradeResolveResult;
642 if (result !== 0) {
643 const [problem] = await call(session, "org.rpm.dnf.v0.Goal", "get_transaction_problems_string", []);
644 throw new ResolveError(`Resolving upgrade failed with result=${result}. ${problem}`);
645 }
646 await call(session, "org.rpm.dnf.v0.Goal", "do_transaction", [{}]);
647 }, signal_emitted);
648 }
649
650 async get_backend(): Promise<string> {
651 return "dnf5";
652 }
653
654 async get_last_refresh_time(): Promise<number> {
655 let last_time = 0;
656 await this.with_session(async (session) => {
657 // Bug? Does this need load repo? As the result was somehow -1 at one point.
658 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Repo", "list", [{ repo_attrs: { t: 'as', v: ['cache_updated'] } }]) as RepoListResult[][];
659 for (const result of results) {
660 if (result.cache_updated.v > last_time)
661 last_time = result.cache_updated.v;
662 }
663 });
664
665 const now = parseInt(await cockpit.spawn(["date", "+%s"]), 10);
666 return now - last_time;
667 }
668
669 async get_history(): Promise<History[]> {
670 const history: History[] = [];
671
672 await this.with_session(async (session) => {
673 // TODO: arbitrary 50 limit, the history API has no limit
674 const [results] = await call(session, "org.rpm.dnf.v0.History", "list", [{ limit: { t: 'x', v: 50 } }]) as HistoryListResult[][];
675 for (const result of results) {
676 // The PackageKit page only shows dnf upgrades, filter out the rest
677 if (result.upgraded.v.length === 0)
678 continue;
679
680 const timestamp = result.end.v;
681 const pkgs = { timestamp, packages: {} } as History;
682
683 for (const pkg of result.upgraded.v) {
684 pkgs.packages[pkg.name.v] = pkg.evr.v;
685 }
686
687 history.push(pkgs);
688 }
689 });
690 return history;
691 }
692
693 async is_available(pkgnames: string[]): Promise<boolean> {
694 const available = new Set<string>();
695
696 await this.with_session(async (session) => {
697 const [results] = await call(session, "org.rpm.dnf.v0.rpm.Rpm", "list", [
698 {
699 package_attrs: { t: 'as', v: ["name"] },
700 scope: { t: 's', v: "available" },
701 patterns: { t: 'as', v: pkgnames }
702 }
703 ]) as ListPackage[][];
704
705 for (const pkg of results) {
706 available.add(pkg.name.v);
707 }
708 });
709
710 return available.size === new Set(pkgnames).size;
711 }
712 }