Allow specifying shell for running scriptlets
[pacman-ng.git] / lib / libalpm / package.h
blob172d2f362e0d599e98e62a8c107d7c9644c93dfb
1 /*
2 * package.h
4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@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>
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.
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.
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/>.
24 #ifndef _ALPM_PACKAGE_H
25 #define _ALPM_PACKAGE_H
27 #include <sys/types.h> /* off_t */
29 #include "alpm.h"
30 #include "backup.h"
31 #include "db.h"
32 #include "signing.h"
34 /** Package operations struct. This struct contains function pointers to
35 * all methods used to access data in a package to allow for things such
36 * as lazy package intialization (such as used by the file backend). Each
37 * backend is free to define a stuct containing pointers to a specific
38 * implementation of these methods. Some backends may find using the
39 * defined default_pkg_ops struct to work just fine for their needs.
41 struct pkg_operations {
42 const char *(*get_desc) (alpm_pkg_t *);
43 const char *(*get_url) (alpm_pkg_t *);
44 alpm_time_t (*get_builddate) (alpm_pkg_t *);
45 alpm_time_t (*get_installdate) (alpm_pkg_t *);
46 const char *(*get_packager) (alpm_pkg_t *);
47 const char *(*get_arch) (alpm_pkg_t *);
48 off_t (*get_isize) (alpm_pkg_t *);
49 alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
50 int (*has_scriptlet) (alpm_pkg_t *);
52 alpm_list_t *(*get_licenses) (alpm_pkg_t *);
53 alpm_list_t *(*get_groups) (alpm_pkg_t *);
54 alpm_list_t *(*get_depends) (alpm_pkg_t *);
55 alpm_list_t *(*get_optdepends) (alpm_pkg_t *);
56 alpm_list_t *(*get_conflicts) (alpm_pkg_t *);
57 alpm_list_t *(*get_provides) (alpm_pkg_t *);
58 alpm_list_t *(*get_replaces) (alpm_pkg_t *);
59 alpm_filelist_t *(*get_files) (alpm_pkg_t *);
60 alpm_list_t *(*get_backup) (alpm_pkg_t *);
62 void *(*changelog_open) (alpm_pkg_t *);
63 size_t (*changelog_read) (void *, size_t, const alpm_pkg_t *, void *);
64 int (*changelog_close) (const alpm_pkg_t *, void *);
66 int (*force_load) (alpm_pkg_t *);
69 /** The standard package operations struct. get fields directly from the
70 * struct itself with no abstraction layer or any type of lazy loading.
71 * The actual definition is in package.c so it can have access to the
72 * default accessor functions which are defined there.
74 extern struct pkg_operations default_pkg_ops;
76 struct __alpm_pkg_t {
77 unsigned long name_hash;
78 char *filename;
79 char *name;
80 char *version;
81 char *desc;
82 char *url;
83 char *packager;
84 char *md5sum;
85 char *sha256sum;
86 char *base64_sig;
87 char *arch;
89 alpm_time_t builddate;
90 alpm_time_t installdate;
92 off_t size;
93 off_t isize;
94 off_t download_size;
96 int scriptlet;
98 alpm_pkgreason_t reason;
99 alpm_dbinfrq_t infolevel;
100 alpm_pkgfrom_t origin;
101 /* origin == PKG_FROM_FILE, use pkg->origin_data.file
102 * origin == PKG_FROM_*DB, use pkg->origin_data.db */
103 union {
104 alpm_db_t *db;
105 char *file;
106 } origin_data;
107 alpm_handle_t *handle;
109 alpm_list_t *licenses;
110 alpm_list_t *replaces;
111 alpm_list_t *groups;
112 alpm_list_t *backup;
113 alpm_list_t *depends;
114 alpm_list_t *optdepends;
115 alpm_list_t *conflicts;
116 alpm_list_t *provides;
117 alpm_list_t *deltas;
118 alpm_list_t *delta_path;
119 alpm_list_t *removes; /* in transaction targets only */
121 struct pkg_operations *ops;
123 alpm_filelist_t files;
126 alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
127 int _alpm_files_cmp(const void *f1, const void *f2);
129 alpm_pkg_t* _alpm_pkg_new(void);
130 int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr);
131 void _alpm_pkg_free(alpm_pkg_t *pkg);
132 void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
134 int _alpm_pkg_validate_internal(alpm_handle_t *handle,
135 const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
136 alpm_siglist_t **sigdata);
137 alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
138 const char *pkgfile, int full);
140 int _alpm_pkg_cmp(const void *p1, const void *p2);
141 int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg);
142 alpm_pkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle);
143 int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
145 #endif /* _ALPM_PACKAGE_H */
147 /* vim: set ts=2 sw=2 noet: */