summaryrefslogtreecommitdiff
path: root/resolve.h
blob: 6a5b38c8f9589e89889003fe14346e912edc8a4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * pkg - Dependency resolver
 * Uses Kahn's algorithm for topological sort
 * https://rawnix.org
 *
 * Copyright (c) 2025 zorz@gmx.com
 * SPDX-License-Identifier: BSD-2-Clause
 */

#ifndef RESOLVE_H
#define RESOLVE_H

#include "pkg.h"
#include "repo.h"
#include "pkgdb.h"
#include "locker.h"

/* Resolution result */
typedef struct {
    strarray_t *order;      /* Ordered list to install */
    strarray_t *missing;    /* Missing dependencies */
    strarray_t *cycle;      /* Packages in cycle */
    bool has_cycle;
    bool has_missing;
} resolution_t;

/* Create/free result */
resolution_t *resolution_new(void);
void resolution_free(resolution_t *res);

/*
 * Resolve dependencies for a package.  An installed dependency is
 * only treated as satisfied when it is current against its port,
 * locked, or has no port at all; outdated ones enter the order and
 * get upgraded.  Same rule sysup applies.
 */
resolution_t *resolve(repo_t *repo, const char *pkg, pkgdb_t *pkgdb,
                      locker_t *locker, bool makedeps);

/* True if the installed version differs from the port's version-release */
bool version_differs(installed_pkg_t *ip, port_t *p);


#endif /* RESOLVE_H */