libalpm
Arch Linux Package Manager Library
|
00001 /* 00002 * package.h 00003 * 00004 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> 00005 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> 00006 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> 00007 * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org> 00008 * Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu> 00009 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 #ifndef _ALPM_PACKAGE_H 00025 #define _ALPM_PACKAGE_H 00026 00027 #include <sys/types.h> /* off_t */ 00028 00029 #include "alpm.h" 00030 #include "backup.h" 00031 #include "db.h" 00032 #include "signing.h" 00033 00034 /** Package operations struct. This struct contains function pointers to 00035 * all methods used to access data in a package to allow for things such 00036 * as lazy package intialization (such as used by the file backend). Each 00037 * backend is free to define a stuct containing pointers to a specific 00038 * implementation of these methods. Some backends may find using the 00039 * defined default_pkg_ops struct to work just fine for their needs. 00040 */ 00041 struct pkg_operations { 00042 const char *(*get_desc) (alpm_pkg_t *); 00043 const char *(*get_url) (alpm_pkg_t *); 00044 alpm_time_t (*get_builddate) (alpm_pkg_t *); 00045 alpm_time_t (*get_installdate) (alpm_pkg_t *); 00046 const char *(*get_packager) (alpm_pkg_t *); 00047 const char *(*get_arch) (alpm_pkg_t *); 00048 off_t (*get_isize) (alpm_pkg_t *); 00049 alpm_pkgreason_t (*get_reason) (alpm_pkg_t *); 00050 int (*has_scriptlet) (alpm_pkg_t *); 00051 00052 alpm_list_t *(*get_licenses) (alpm_pkg_t *); 00053 alpm_list_t *(*get_groups) (alpm_pkg_t *); 00054 alpm_list_t *(*get_depends) (alpm_pkg_t *); 00055 alpm_list_t *(*get_optdepends) (alpm_pkg_t *); 00056 alpm_list_t *(*get_conflicts) (alpm_pkg_t *); 00057 alpm_list_t *(*get_provides) (alpm_pkg_t *); 00058 alpm_list_t *(*get_replaces) (alpm_pkg_t *); 00059 alpm_filelist_t *(*get_files) (alpm_pkg_t *); 00060 alpm_list_t *(*get_backup) (alpm_pkg_t *); 00061 00062 void *(*changelog_open) (alpm_pkg_t *); 00063 size_t (*changelog_read) (void *, size_t, const alpm_pkg_t *, void *); 00064 int (*changelog_close) (const alpm_pkg_t *, void *); 00065 00066 int (*force_load) (alpm_pkg_t *); 00067 }; 00068 00069 /** The standard package operations struct. get fields directly from the 00070 * struct itself with no abstraction layer or any type of lazy loading. 00071 * The actual definition is in package.c so it can have access to the 00072 * default accessor functions which are defined there. 00073 */ 00074 extern struct pkg_operations default_pkg_ops; 00075 00076 struct __alpm_pkg_t { 00077 unsigned long name_hash; 00078 char *filename; 00079 char *name; 00080 char *version; 00081 char *desc; 00082 char *url; 00083 char *packager; 00084 char *md5sum; 00085 char *sha256sum; 00086 char *base64_sig; 00087 char *arch; 00088 00089 alpm_time_t builddate; 00090 alpm_time_t installdate; 00091 00092 off_t size; 00093 off_t isize; 00094 off_t download_size; 00095 00096 int scriptlet; 00097 00098 alpm_pkgreason_t reason; 00099 alpm_dbinfrq_t infolevel; 00100 alpm_pkgfrom_t origin; 00101 /* origin == PKG_FROM_FILE, use pkg->origin_data.file 00102 * origin == PKG_FROM_*DB, use pkg->origin_data.db */ 00103 union { 00104 alpm_db_t *db; 00105 char *file; 00106 } origin_data; 00107 alpm_handle_t *handle; 00108 00109 alpm_list_t *licenses; 00110 alpm_list_t *replaces; 00111 alpm_list_t *groups; 00112 alpm_list_t *backup; 00113 alpm_list_t *depends; 00114 alpm_list_t *optdepends; 00115 alpm_list_t *conflicts; 00116 alpm_list_t *provides; 00117 alpm_list_t *deltas; 00118 alpm_list_t *delta_path; 00119 alpm_list_t *removes; /* in transaction targets only */ 00120 00121 struct pkg_operations *ops; 00122 00123 alpm_filelist_t files; 00124 }; 00125 00126 alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src); 00127 int _alpm_files_cmp(const void *f1, const void *f2); 00128 00129 alpm_pkg_t* _alpm_pkg_new(void); 00130 int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr); 00131 void _alpm_pkg_free(alpm_pkg_t *pkg); 00132 void _alpm_pkg_free_trans(alpm_pkg_t *pkg); 00133 00134 int _alpm_pkg_validate_internal(alpm_handle_t *handle, 00135 const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level, 00136 alpm_siglist_t **sigdata); 00137 alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, 00138 const char *pkgfile, int full); 00139 00140 int _alpm_pkg_cmp(const void *p1, const void *p2); 00141 int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg); 00142 alpm_pkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle); 00143 int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg); 00144 00145 #endif /* _ALPM_PACKAGE_H */ 00146 00147 /* vim: set ts=2 sw=2 noet: */