-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib_pkgset.c
137 lines (99 loc) · 3.37 KB
/
lib_pkgset.c
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
Copyright (C) 2000 - 2008 Pawel A. Gajda <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2 as
published by the Free Software Foundation (see file COPYING for details).
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <fnmatch.h>
#include <trurl/nmalloc.h>
#include <trurl/nassert.h>
#include "compiler.h"
#include "vfile/vfile.h"
#include "sigint/sigint.h"
#include "pkgdir/source.h"
#include "pkgdir/pkgdir.h"
#include "pkgset.h"
#include "pkgmisc.h"
#include "conf.h"
#include "log.h"
#include "misc.h"
#include "i18n.h"
#include "poldek.h"
#include "poldek_intern.h"
#include "pm/pm.h"
#include "split.h"
int poldek__load_sources_internal(struct poldek_ctx *ctx)
{
struct pkgset *ps;
struct poldek_ts *ts;
unsigned ps_flags = 0, ldflags = 0;
n_assert(ctx->pmctx);
n_assert(ctx->ps == NULL);
ts = ctx->ts;
if ((ps = pkgset_new(ctx->pmctx)) == NULL)
return 0;
if (pm_get_dbdepdirs(ctx->pmctx, ctx->ts->rootdir, NULL, ps->depdirs) >= 0)
ps->flags |= PSET_DBDIRS_LOADED;
if (ctx->ts->getop(ctx->ts, POLDEK_OP_IGNORE))
ldflags |= PKGDIR_LD_DOIGNORE;
if (ctx->ts->getop(ctx->ts, POLDEK_OP_LDFULLFILELIST))
ldflags |= PKGDIR_LD_FULLFLIST;
if (ctx->ts->getop(ctx->ts, POLDEK_OP_LDALLDESC))
ldflags |= PKGDIR_LD_ALLDESC;
#if 0 /* XXX now files are loaded on demand */
if (strcmp(pm_get_name(ctx->pmctx), "pset") == 0)
ldflags |= PKGDIR_LD_FULLFLIST;
#endif
if (ctx->ts->getop(ctx->ts, POLDEK_OP_AUTODIRDEP))
ldflags |= PKGDIR_LD_DIRINDEX;
if (!pkgset_load(ps, ldflags, ctx->sources))
logn(LOGWARN, _("no packages loaded"));
MEMINF("after load");
if (ps == NULL)
return 0;
if (ctx->ts->getop(ctx->ts, POLDEK_OP_HOLD))
packages_score(ps->pkgs, ctx->ts->hold_patterns, PKG_HELD);
if (ctx->ts->getop(ctx->ts, POLDEK_OP_IGNORE))
packages_score_ignore(ps->pkgs, ctx->ts->ign_patterns, 1);
ctx->pkgdirs = n_ref(ps->pkgdirs);
if (ts->getop(ts, POLDEK_OP_UNIQN))
ps_flags |= PSET_UNIQ_PKGNAME;
pkgset_setup(ps, ps_flags);
if (ctx->ts->prifile)
packages_set_priorities(ps->pkgs, ctx->ts->prifile);
ctx->ps = ps;
MEMINF("after ps setup");
return 1;
}
tn_array *poldek_get_avail_packages(struct poldek_ctx *ctx)
{
return poldek_search_avail_packages(ctx, POLDEK_ST_RECNO, NULL);
}
tn_array *poldek_search_avail_packages(struct poldek_ctx *ctx,
enum poldek_search_tag tag,
const char *value)
{
if (!poldek_load_sources(ctx))
return NULL;
return pkgset_search(ctx->ps, tag, value);
}
tn_array *poldek_get_sources(struct poldek_ctx *ctx)
{
return ctx->sources ? n_ref(ctx->sources) : NULL;
}
tn_array *poldek_get_pkgdirs(struct poldek_ctx *ctx)
{
return ctx->pkgdirs ? n_ref(ctx->pkgdirs) : NULL;
}
struct pkgdb;
struct pkgdb *poldek_open_installeddb(struct poldek_ctx *ctx)
{
return poldek_ts_dbopen(ctx->ts, 0);
}