Remove INTLLIBS from librazor_la_LIBADD.
This partially reverts 611c84a3f4b4538a65d186050608c17adbf17770.
It's not clear what motivated the initial inclusion of INTLLIBS
here since the net effect is only seen in librazor.la and not
in razor.pc and librazor.la is not normally packaged. Certainly
neither the static nor the dynamic versions of librazor currently
use libintl. At best this would cause the linker to search a
static libintl for undefined symbols without finding any; at worse
it causes a static build of plover using librazor.la to fail if
no static version of libintl is installed.
2 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
3 * Copyright (C) 2008 Red Hat, Inc
4 * Copyright (C) 2009, 2011, 2012 J. Ali Harlow <ali@juiblex.co.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <sys/types.h>
29 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
30 #define RAZOR_MALLOC __attribute__((__malloc__))
35 #define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
37 #define RAZOR_NULL_TERMINATED
41 enum razor_section_type {
42 RAZOR_SECTION_MAIN = 0x01,
43 RAZOR_SECTION_DETAILS = 0x02,
44 RAZOR_SECTION_FILES = 0x04,
45 RAZOR_SECTION_ALL = 0x07
48 enum razor_stage_type {
49 RAZOR_STAGE_SCRIPTS_PRE = 0x1,
50 RAZOR_STAGE_FILES = 0x2,
51 RAZOR_STAGE_SCRIPTS_POST = 0x4,
52 RAZOR_STAGE_SCRIPTS = 0x5,
56 enum razor_detail_type {
57 RAZOR_DETAIL_LAST = 0, /* the sentinel */
62 RAZOR_DETAIL_DESCRIPTION,
65 RAZOR_DETAIL_PREUNPROG,
67 RAZOR_DETAIL_POSTUNPROG,
72 enum razor_property_flags {
73 RAZOR_PROPERTY_LESS = 1 << 0,
74 RAZOR_PROPERTY_GREATER = 1 << 1,
75 RAZOR_PROPERTY_EQUAL = 1 << 2,
76 RAZOR_PROPERTY_RELATION_MASK =
78 RAZOR_PROPERTY_GREATER |
81 RAZOR_PROPERTY_REQUIRES = 0 << 3,
82 RAZOR_PROPERTY_PROVIDES = 1 << 3,
83 RAZOR_PROPERTY_CONFLICTS = 2 << 3,
84 RAZOR_PROPERTY_OBSOLETES = 3 << 3,
85 RAZOR_PROPERTY_TYPE_MASK = 3 << 3,
87 RAZOR_PROPERTY_PRE = 1 << 5,
88 RAZOR_PROPERTY_POST = 1 << 6,
89 RAZOR_PROPERTY_PREUN = 1 << 7,
90 RAZOR_PROPERTY_POSTUN = 1 << 8,
91 RAZOR_PROPERTY_SCRIPT_MASK =
94 RAZOR_PROPERTY_PREUN |
98 enum razor_set_flags {
100 * Create a private copy of the razor set such that changes made
101 * to the underlying file are not visible in the razor set.
102 * If this flag is not set then the caller must ensure that the
103 * underlying file (if any) is not changed.
105 RAZOR_SET_PRIVATE = 1 << 0,
110 * @title: Error reporting
111 * @short_description: A system for reporting errors.
113 * This object represents an error condition.
117 struct razor_error *razor_error_new_str(const char *path, const char *str);
118 struct razor_error *razor_error_dup(struct razor_error *src,
119 const char *summary);
121 #define razor_set_error(error, path, str) \
123 *(error) = razor_error_new_str(path, str); \
126 #define razor_propagate_error(dest, src, summary) \
128 *(dest) = razor_error_dup(src, summary); \
131 const char *razor_error_get_primary_text(struct razor_error *error);
132 const char *razor_error_get_secondary_text(struct razor_error *error);
133 const char *razor_error_get_msg(struct razor_error *error);
134 void razor_error_free(struct razor_error *error);
138 * @title: Atomic transactions
139 * @short_description: File-based transactions that shouldn't half-succeed
141 * This is a helper object for issuing a sequence of file-based actions
142 * that should either all succeed or all fail.
144 * Note that currently only Windows 7 has a native implementation and that
145 * while the emulated fallback implementation attempts to rollback the
146 * transaction if it fails, this is not guaranteed to succeed and that
147 * the transaction is held in core (and thus vulnernable to program crashes,
148 * power loss, etc.). This could (and should) be improved.
150 * Atomic transactions can be disabled via configure, in which case all
155 struct razor_atomic *razor_atomic_open(const char *description);
156 int razor_atomic_commit(struct razor_atomic *atomic);
157 struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
158 const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
159 void razor_atomic_destroy(struct razor_atomic *atomic);
162 * razor_atomic_make_dirs
164 * Create all sub-directories leading up to path. We know root exists
165 * and is a dir, root does not end in a '/', and path either has a
166 * leading '/' or (on MS-Windows only) root is the empty string
167 * and path starts with drive (eg., "c:/windows").
168 * Note: path itself is not created, only the directory in which it
171 * Returns: non-zero on error.
173 int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
175 int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
176 int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
177 const char *newpath);
180 * razor_atomic_create_dir
182 * Create a directory, replacing any existing object at this path except
183 * an existing directory (which is not counted as a error).
185 * Returns: non-zero on error.
187 int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
191 * razor_atomic_create_symlink
193 * Create a symbolic link, replacing any existing object at this path except
194 * a non-empty directory.
196 * Note: This function will always fail on platforms that don't support
199 * Returns: non-zero on error.
201 int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
204 * razor_atomic_create_file
206 * Create a file, replacing any existing object at this path except
207 * a non-empty directory.
209 * Returns: A handle to be passed to razor_atomic_write() and
210 * razor_atomic_close() or a negative value on error.
212 int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
214 int razor_atomic_write(struct razor_atomic *atomic, int handle,
215 const void *data, size_t size);
216 int razor_atomic_close(struct razor_atomic *atomic, int handle);
217 int razor_atomic_sync(struct razor_atomic *atomic, int handle);
218 void razor_atomic_abort(struct razor_atomic *atomic, const char *error_msg);
219 int razor_atomic_in_error_state(struct razor_atomic *atomic);
223 * @title: Package Set
224 * @short_description: Represents a set of packages and their metadata.
226 * This object represents a set of packages, their dependency
227 * information, the file lists and a number of other details.
231 struct razor_package;
232 struct razor_property;
234 #define RAZOR_HEADER_VERSION 2 /* Current version */
235 #define RAZOR_HEADER_VERSION_MIN 1 /* Minimum version we support */
240 * Create a new #razor_set object.
242 * Returns: the new #razor_set object.
244 struct razor_set *razor_set_create_without_root(void);
245 struct razor_set *razor_set_create(void);
247 razor_set_open(const char *filename, enum razor_set_flags flags,
248 struct razor_error **error);
249 uint32_t razor_set_get_header_version(struct razor_set *set);
250 int razor_set_set_header_version(struct razor_set *set,
251 uint32_t header_version);
252 void razor_set_unref(struct razor_set *set);
253 struct razor_set *razor_set_ref(struct razor_set *set);
254 void razor_set_write_to_handle(struct razor_set *set,
255 struct razor_atomic *atomic, int handle,
256 uint32_t section_mask);
257 int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
258 const char *filename, uint32_t setions);
260 razor_set_bind_sections(struct razor_set *set, const char *filename,
261 enum razor_set_flags flags, struct razor_error **error);
263 struct razor_package *
264 razor_set_get_package(struct razor_set *set, const char *package);
267 razor_package_get_details(struct razor_set *set,
268 struct razor_package *package, ...);
270 razor_package_remove(struct razor_set *prev, struct razor_set *next,
271 struct razor_atomic *atomic, struct razor_package *package,
272 const char *root, int install_count,
273 enum razor_stage_type stage);
278 * @short_description: Objects for traversing packages or properties.
280 * The razor iterator objects provides a way to iterate through a set
281 * of packages or properties.
284 struct razor_package_iterator;
287 * razor_package_iterator_create:
289 * Create a new #razor_package_iterator object.
291 * Returns: the new #razor_package_iterator object.
294 struct razor_package_iterator *
295 razor_package_iterator_create(struct razor_set *set);
298 * razor_package_iterator_create_for_property:
300 * Create a new #razor_package_iterator object for the packages that
301 * own the given property.
303 * Returns: the new #razor_package_iterator object.
305 struct razor_package_iterator *
306 razor_package_iterator_create_for_property(struct razor_set *set,
307 struct razor_property *property);
310 * razor_package_iterator_create_for_file:
312 * Create a new #razor_package_iterator object for the packages that
313 * contain the given file name.
315 * Returns: the new #razor_package_iterator object.
317 struct razor_package_iterator *
318 razor_package_iterator_create_for_file(struct razor_set *set,
319 const char *filename);
321 int razor_package_iterator_next(struct razor_package_iterator *pi,
322 struct razor_package **package, ...);
323 void razor_package_iterator_destroy(struct razor_package_iterator *pi);
325 struct razor_package_query *
326 razor_package_query_create(struct razor_set *set);
328 razor_package_query_add_package(struct razor_package_query *pq,
329 struct razor_package *p);
331 razor_package_query_add_iterator(struct razor_package_query *pq,
332 struct razor_package_iterator *pi);
333 struct razor_package_iterator *
334 razor_package_query_finish(struct razor_package_query *pq);
336 struct razor_property_iterator;
337 struct razor_property_iterator *
338 razor_property_iterator_create(struct razor_set *set,
339 struct razor_package *package);
340 int razor_property_iterator_next(struct razor_property_iterator *pi,
341 struct razor_property **property,
344 const char **version);
346 razor_property_iterator_destroy(struct razor_property_iterator *pi);
348 struct razor_file_iterator;
349 struct razor_file_iterator *
350 razor_file_iterator_create(struct razor_set *set,
351 struct razor_package *package, int post_order);
352 int razor_file_iterator_next(struct razor_file_iterator *fi,
354 void razor_file_iterator_destroy(struct razor_file_iterator *fi);
356 void razor_set_list_files(struct razor_set *set, const char *prefix);
357 void razor_set_list_package_files(struct razor_set *set,
358 struct razor_package *package);
360 enum razor_diff_action {
361 RAZOR_DIFF_ACTION_ADD,
362 RAZOR_DIFF_ACTION_REMOVE,
365 typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
366 struct razor_package *package,
373 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
374 razor_diff_callback_t callback, void *data);
376 struct razor_install_iterator;
378 enum razor_install_action {
379 RAZOR_INSTALL_ACTION_ADD,
380 RAZOR_INSTALL_ACTION_REMOVE,
381 RAZOR_INSTALL_ACTION_COMMIT
384 struct razor_install_iterator *
385 razor_set_create_install_iterator(struct razor_set *set,
386 struct razor_set *next);
388 int razor_install_iterator_next(struct razor_install_iterator *ii,
389 struct razor_package **package,
390 enum razor_install_action *action,
394 * razor_install_iterator_commit_set
396 * Immediately after razor_install_iterator_next() returns
397 * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
398 * which should be committed.
400 * Returns: a new #razor_set object.
403 razor_install_iterator_commit_set(struct razor_install_iterator *ii);
405 void razor_install_iterator_rewind(struct razor_install_iterator *ii);
406 size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
407 size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
409 void razor_install_iterator_destroy(struct razor_install_iterator *ii);
412 * SECTION:transaction
413 * @title: Transaction
414 * @short_description: Create a new package set by merging two or more sets.
416 * The razor transaction object provides a way to create a new package set
417 * from packages from one or more other package sets.
422 struct razor_transaction *
423 razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
424 void razor_transaction_install_package(struct razor_transaction *transaction,
425 struct razor_package *package);
426 void razor_transaction_remove_package(struct razor_transaction *transaction,
427 struct razor_package *package);
428 void razor_transaction_update_package(struct razor_transaction *trans,
429 struct razor_package *package);
430 void razor_transaction_fixup_package(struct razor_transaction *trans,
431 struct razor_package *package,
432 struct razor_rpm *rpm);
433 void razor_transaction_update_all(struct razor_transaction *transaction);
434 int razor_transaction_resolve(struct razor_transaction *trans);
435 int razor_transaction_describe(struct razor_transaction *trans);
436 struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
437 void razor_transaction_destroy(struct razor_transaction *trans);
439 /* Temporary helper for test suite. */
440 int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
443 const char *version);
448 * @short_description: Operating on RPM files.
450 * Functions for open RPM files and extracting information and
451 * installing or removing RPM files.
454 struct razor_relocations;
456 struct razor_relocations *razor_relocations_create(void);
457 void razor_relocations_add(struct razor_relocations *relocations,
458 const char *oldpath, const char *newpath);
459 void razor_relocations_set_rpm(struct razor_relocations *relocations,
460 struct razor_rpm *rpm);
461 const char *razor_relocations_apply(struct razor_relocations *relocations,
463 void razor_relocations_destroy(struct razor_relocations *relocations);
465 struct razor_rpm *razor_rpm_open(const char *filename,
466 struct razor_error **error);
467 void razor_rpm_get_details(struct razor_rpm *rpm, ...);
468 void razor_rpm_set_relocations(struct razor_rpm *rpm,
469 struct razor_relocations *relocations);
470 int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
471 const char *root, int install_count,
472 enum razor_stage_type stage);
473 int razor_rpm_close(struct razor_rpm *rpm);
478 * @short_description: A mechanism for building #razor_set objects
480 * The %razor_importer is a helper object for building a razor set
481 * from external sources, like yum metadata, the RPM database or RPM
484 * The importer is a stateful object; it has the notion of a current
485 * package, and the caller can provide meta data such as properties,
486 * files and similiar for the package as it becomes available. Once a
487 * package is fully described, the next pacakge can begin. When all
488 * packages have been described to the importer, the importer will
489 * create a new %razor_set with the specified packages.
492 * of the importer will follow this template:
494 * importer = razor_importer_create();
496 * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
497 * /<!-- -->* get name, version and arch of next package *<!-- -->/
498 * razor_importer_begin_package(importer, name, version, arch);
499 * razor_importer_add_details(importer, summary, description, url, license);
501 * while ( /<!-- -->* more properties to add *<!-- -->/ )
502 * razor_importer_add_property(importer, name, flags, version);
504 * while ( /<!-- -->* [more files to add *<!-- -->/ )
505 * razor_importer_add_file(importer, name);
507 * razor_importer_finish_package(importer);
510 * return razor_importer_finish(importer);
513 struct razor_importer;
515 struct razor_importer *razor_importer_create(void);
516 void razor_importer_destroy(struct razor_importer *importer);
517 void razor_importer_begin_package(struct razor_importer *importer,
521 void razor_importer_add_details(struct razor_importer *importer,
523 const char *description,
525 const char *license);
526 void razor_importer_add_script(struct razor_importer *importer,
527 enum razor_property_flags script,
530 void razor_importer_add_install_prefix(struct razor_importer *importer,
531 const char *install_prefix);
532 void razor_importer_add_property(struct razor_importer *importer,
535 const char *version);
536 void razor_importer_add_file(struct razor_importer *importer,
538 void razor_importer_finish_package(struct razor_importer *importer);
540 int razor_importer_add_rpm(struct razor_importer *importer,
541 struct razor_rpm *rpm);
543 struct razor_set *razor_importer_finish(struct razor_importer *importer);
545 struct razor_set *razor_set_create_from_yum(void);
546 struct razor_set *razor_set_create_from_rpmdb(void);
551 * @short_description: Functions for accessing an install root.
553 * The #razor_root object encapsulate access to and locking of a razor
558 int razor_root_create(const char *root, struct razor_error **error);
560 razor_root_open(const char *root, struct razor_error **error);
562 razor_root_open_read_only(const char *root, struct razor_error **error);
563 struct razor_set *razor_root_get_system_set(struct razor_root *root);
564 int razor_root_close(struct razor_root *root);
566 razor_root_update(struct razor_root *root, struct razor_set *next,
567 struct razor_atomic *atomic);
571 * @title: Miscellaneous Functions
572 * @short_description: Various helper functions
574 * Functions that doesn't fit anywhere else.
578 razor_property_relation_to_string(struct razor_property *p);
580 razor_property_type_to_string(struct razor_property *p);
582 void razor_build_evr(char *evr_buf, int size, const char *epoch,
583 const char *version, const char *release);
584 int razor_versioncmp(const char *s1, const char *s2);
586 void razor_disable_root_name_checks(int disable);
588 void razor_set_lua_loader(const char *modname, void (*loader)());
589 void (*razor_get_lua_loader(const char *modname))();
591 char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
593 const char *razor_system_arch(void);
595 #endif /* _RAZOR_H_ */