aboutsummaryrefslogtreecommitdiffstats
path: root/libopkg/pkg_depends.h
blob: 17e6686582f8ef1574b4d4e6aad57f735b9f8c96 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* vi: set expandtab sw=4 sts=4: */
/* pkg_depends.h - the opkg package management system

   Steven M. Ayer

   Copyright (C) 2002 Compaq Computer Corporation

   SPDX-License-Identifier: GPL-2.0-or-later

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
*/

#ifndef PKG_DEPENDS_H
#define PKG_DEPENDS_H

#ifdef __cplusplus
extern "C" {
#endif

#include "pkg.h"
#include "pkg_hash.h"

enum depend_type {
    PREDEPEND,
    DEPEND,
    CONFLICTS,
    GREEDY_DEPEND,
    RECOMMEND,
    SUGGEST,
    REPLACES
};
typedef enum depend_type depend_type_t;

enum version_constraint {
    NONE,
    EARLIER,
    EARLIER_EQUAL,
    EQUAL,
    LATER_EQUAL,
    LATER
};
typedef enum version_constraint version_constraint_t;

struct depend {
    version_constraint_t constraint;
    char *version;
    abstract_pkg_t *pkg;
};
typedef struct depend depend_t;

struct compound_depend {
    depend_type_t type;
    int possibility_count;
    struct depend **possibilities;
};
typedef struct compound_depend compound_depend_t;

void buildProvides(abstract_pkg_t * ab_pkg, pkg_t * pkg);
void buildConflicts(pkg_t * pkg);
void buildReplaces(abstract_pkg_t * ab_pkg, pkg_t * pkg);
void buildDepends(pkg_t * pkg);

/**
 * pkg_replaces returns 1 if pkg->replaces contains one of replacee's provides and 0
 * otherwise.
 */
int pkg_replaces(pkg_t * pkg, pkg_t * replacee);

/**
 * pkg_conflicts_abstract returns 1 if pkg->conflicts contains conflictee provides and 0
 * otherwise.
 */
int pkg_conflicts_abstract(pkg_t * pkg, abstract_pkg_t * conflicts);

/**
 * pkg_conflicts returns 1 if pkg->conflicts contains one of conflictee's provides and 0
 * otherwise.
 */
int pkg_conflicts(pkg_t * pkg, pkg_t * conflicts);

int pkg_breaks_reverse_dep(pkg_t * pkg);

char *pkg_depend_str(pkg_t * pkg, int index);
void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg);
int version_constraints_satisfied(depend_t * depends, pkg_t * pkg);
int pkg_constraint_satisfied(pkg_t *pkg, void *cdata);
int pkg_dependence_satisfiable(depend_t * depend);
const char *constraint_to_str(version_constraint_t c);
version_constraint_t str_to_constraint(const char **str);
void strip_pkg_name_and_version(const char *pkg_name, char **name, char **version,
                                version_constraint_t *constraint);

int is_pkg_in_pkg_vec(pkg_vec_t * vec, pkg_t * pkg);

#ifdef __cplusplus
}
#endif
#endif                          /* PKG_DEPENDS_H */