libalpm
Arch Linux Package Manager Library
package.h
Go to the documentation of this file.
1/*
2 * package.h
3 *
4 * Copyright (c) 2006-2024 Pacman Development Team <pacman-dev@lists.archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7 * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
8 * Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
9 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24#ifndef ALPM_PACKAGE_H
25#define ALPM_PACKAGE_H
26
27#include <sys/types.h> /* off_t */
28
29/* libarchive */
30#include <archive.h>
31#include <archive_entry.h>
32
33#include "alpm.h"
34#include "backup.h"
35#include "db.h"
36#include "signing.h"
37
38/** Package operations struct. This struct contains function pointers to
39 * all methods used to access data in a package to allow for things such
40 * as lazy package initialization (such as used by the file backend). Each
41 * backend is free to define a struct containing pointers to a specific
42 * implementation of these methods. Some backends may find using the
43 * defined default_pkg_ops struct to work just fine for their needs.
44 */
46 const char *(*get_base) (alpm_pkg_t *);
47 const char *(*get_desc) (alpm_pkg_t *);
48 const char *(*get_url) (alpm_pkg_t *);
49 alpm_time_t (*get_builddate) (alpm_pkg_t *);
50 alpm_time_t (*get_installdate) (alpm_pkg_t *);
51 const char *(*get_packager) (alpm_pkg_t *);
52 const char *(*get_arch) (alpm_pkg_t *);
53 off_t (*get_isize) (alpm_pkg_t *);
54 alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
55 int (*get_validation) (alpm_pkg_t *);
56 int (*has_scriptlet) (alpm_pkg_t *);
57
58 alpm_list_t *(*get_licenses) (alpm_pkg_t *);
59 alpm_list_t *(*get_groups) (alpm_pkg_t *);
60 alpm_list_t *(*get_depends) (alpm_pkg_t *);
61 alpm_list_t *(*get_optdepends) (alpm_pkg_t *);
62 alpm_list_t *(*get_checkdepends) (alpm_pkg_t *);
63 alpm_list_t *(*get_makedepends) (alpm_pkg_t *);
64 alpm_list_t *(*get_conflicts) (alpm_pkg_t *);
65 alpm_list_t *(*get_provides) (alpm_pkg_t *);
66 alpm_list_t *(*get_replaces) (alpm_pkg_t *);
67 alpm_filelist_t *(*get_files) (alpm_pkg_t *);
68 alpm_list_t *(*get_backup) (alpm_pkg_t *);
69
70 alpm_list_t *(*get_xdata) (alpm_pkg_t *);
71
72 void *(*changelog_open) (alpm_pkg_t *);
73 size_t (*changelog_read) (void *, size_t, const alpm_pkg_t *, void *);
74 int (*changelog_close) (const alpm_pkg_t *, void *);
75
76 struct archive *(*mtree_open) (alpm_pkg_t *);
77 int (*mtree_next) (const alpm_pkg_t *, struct archive *, struct archive_entry **);
78 int (*mtree_close) (const alpm_pkg_t *, struct archive *);
79
80 int (*force_load) (alpm_pkg_t *);
81};
82
83/** The standard package operations struct. get fields directly from the
84 * struct itself with no abstraction layer or any type of lazy loading.
85 * The actual definition is in package.c so it can have access to the
86 * default accessor functions which are defined there.
87 */
88extern const struct pkg_operations default_pkg_ops;
89
90struct _alpm_pkg_t {
91 unsigned long name_hash;
92 char *filename;
93 char *base;
94 char *name;
95 char *version;
96 char *desc;
97 char *url;
98 char *packager;
99 char *md5sum;
100 char *sha256sum;
101 char *base64_sig;
102 char *arch;
103
104 alpm_time_t builddate;
105 alpm_time_t installdate;
106
107 off_t size;
108 off_t isize;
109 off_t download_size;
110
111 alpm_handle_t *handle;
112
113 alpm_list_t *licenses;
114 alpm_list_t *replaces;
115 alpm_list_t *groups;
116 alpm_list_t *backup;
117 alpm_list_t *depends;
118 alpm_list_t *optdepends;
119 alpm_list_t *checkdepends;
120 alpm_list_t *makedepends;
121 alpm_list_t *conflicts;
122 alpm_list_t *provides;
123 alpm_list_t *removes; /* in transaction targets only */
124 alpm_pkg_t *oldpkg; /* in transaction targets only */
125
126 const struct pkg_operations *ops;
127
128 alpm_filelist_t files;
129
130 /* origin == PKG_FROM_FILE, use pkg->origin_data.file
131 * origin == PKG_FROM_*DB, use pkg->origin_data.db */
132 union {
133 alpm_db_t *db;
134 char *file;
135 } origin_data;
136
137 alpm_pkgfrom_t origin;
138 alpm_pkgreason_t reason;
139 int scriptlet;
140
141 alpm_list_t *xdata;
142
143 /* Bitfield from alpm_dbinfrq_t */
144 int infolevel;
145 /* Bitfield from alpm_pkgvalidation_t */
146 int validation;
147};
148
149alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
150
151alpm_pkg_t *_alpm_pkg_new(void);
152int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr);
153void _alpm_pkg_free(alpm_pkg_t *pkg);
154void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
155
156int _alpm_pkg_validate_internal(alpm_handle_t *handle,
157 const char *pkgfile, alpm_pkg_t *syncpkg, int level,
158 alpm_siglist_t **sigdata, int *validation);
159alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
160 const char *pkgfile, int full);
161
162int _alpm_pkg_cmp(const void *p1, const void *p2);
163int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg);
164
165alpm_pkg_xdata_t *_alpm_pkg_parse_xdata(const char *string);
166void _alpm_pkg_xdata_free(alpm_pkg_xdata_t *pd);
167
168int _alpm_pkg_check_meta(alpm_pkg_t *pkg);
169
170#endif /* ALPM_PACKAGE_H */
File in a package.
Definition alpm.h:134
Package filelist container.
Definition alpm.h:144
A doubly linked list.
Definition alpm_list.h:51
int64_t alpm_time_t
The time type used by libalpm.
Definition alpm.h:126
alpm_pkgreason_t
Package install reasons.
Definition alpm.h:2328
alpm_pkgfrom_t
Location a package object was loaded from.
Definition alpm.h:2338
Signature list.
Definition alpm.h:480
The extended data type used to store non-standard package data fields.
Definition alpm.h:119
int(* has_scriptlet)(alpm_pkg_t *)
Definition package.h:56
int(* force_load)(alpm_pkg_t *)
Definition package.h:80
int(* get_validation)(alpm_pkg_t *)
Definition package.h:55
int(* mtree_close)(const alpm_pkg_t *, struct archive *)
Definition package.h:78
off_t(* get_isize)(alpm_pkg_t *)
Definition package.h:53
int(* changelog_close)(const alpm_pkg_t *, void *)
Definition package.h:74
const struct pkg_operations default_pkg_ops
The standard package operations struct.
Definition package.c:143
alpm_pkgreason_t(* get_reason)(alpm_pkg_t *)
Definition package.h:54
alpm_time_t(* get_installdate)(alpm_pkg_t *)
Definition package.h:50
int(* mtree_next)(const alpm_pkg_t *, struct archive *, struct archive_entry **)
Definition package.h:77
alpm_time_t(* get_builddate)(alpm_pkg_t *)
Definition package.h:49
size_t(* changelog_read)(void *, size_t, const alpm_pkg_t *, void *)
Definition package.h:73
Package operations struct.
Definition package.h:45
alpm_loglevel_t level
Definition sandbox.h:40