librazor/razor.h.in
author J. Ali Harlow <ali@juiblex.co.uk>
Fri Oct 03 15:05:33 2014 +0100 (2014-10-03)
changeset 453 1fd1d221092d
child 457 51a084acef49
permissions -rw-r--r--
Add INTLLIBS back into librazor_la_LIBADD and also into razor.pc

INTLLIBS was originally added into librazor_la_LIBADD (but not razor.pc)
in 611c84a3f4b4538a65d186050608c17adbf17770 and then removed in
236cfc8ecc5c66288e41bf9b72051a3b18326e1c over concerns that it meant
that building static applications (eg., in plover) required a static
version of libintl. Since then, however, the inclusion of gnulib's
getopt has caused the build to fail without INTLLIBS in librazor_la_LIBADD
with messages of the form:

../gl/.libs/libgnu.a(getopt.o): In function `_getopt_internal_r':
/home/ali/wk/razor/vpath/gl/../../working/gl/getopt.c:808: undefined reference to `libintl_gettext'

while building librazor.dll.a

Thus it appears that INTLLIBS really is needed and should go back into
librazor_la_LIBADD (which fixes the build) and should also be in Libs.private
in razor.pc for static builds. This means that a static version of libintl
will be required (eg., as part of mingw64-gettext-static).

Along the way, razor.pc has also been fixed to avoid overlinking
(https://wiki.openmandriva.org/en/Overlinking_issues_in_packaging)
and a missing include directory that caused the razor executable to
fail to build was added.
ali@452
     1
/*
ali@452
     2
 * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
ali@452
     3
 * Copyright (C) 2008  Red Hat, Inc
ali@452
     4
 * Copyright (C) 2009, 2011, 2012, 2014  J. Ali Harlow <ali@juiblex.co.uk>
ali@452
     5
 *
ali@452
     6
 * This program is free software; you can redistribute it and/or modify
ali@452
     7
 * it under the terms of the GNU General Public License as published by
ali@452
     8
 * the Free Software Foundation; either version 2 of the License, or
ali@452
     9
 * (at your option) any later version.
ali@452
    10
 *
ali@452
    11
 * This program is distributed in the hope that it will be useful,
ali@452
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ali@452
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ali@452
    14
 * GNU General Public License for more details.
ali@452
    15
 *
ali@452
    16
 * You should have received a copy of the GNU General Public License along
ali@452
    17
 * with this program; if not, write to the Free Software Foundation, Inc.,
ali@452
    18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ali@452
    19
 */
ali@452
    20
ali@452
    21
#ifndef _RAZOR_H_
ali@452
    22
#define _RAZOR_H_
ali@452
    23
ali@452
    24
#include <stdint.h>
ali@452
    25
#include <sys/types.h>
ali@452
    26
ali@452
    27
/* GCC extensions */
ali@452
    28
#if defined(__GNUC__)
ali@452
    29
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
ali@452
    30
#define RAZOR_MALLOC __attribute__((__malloc__))
ali@452
    31
#else
ali@452
    32
#define RAZOR_MALLOC
ali@452
    33
#endif
ali@452
    34
#if __GNUC__ >= 4
ali@452
    35
#define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
ali@452
    36
#else
ali@452
    37
#define RAZOR_NULL_TERMINATED
ali@452
    38
#endif
ali@452
    39
#endif	/* __GNUC__ */
ali@452
    40
ali@452
    41
enum razor_section_type {
ali@452
    42
	RAZOR_SECTION_MAIN = 0x01,
ali@452
    43
	RAZOR_SECTION_DETAILS = 0x02,
ali@452
    44
	RAZOR_SECTION_FILES = 0x04,
ali@452
    45
	RAZOR_SECTION_ALL = 0x07
ali@452
    46
};
ali@452
    47
ali@452
    48
enum razor_stage_type {
ali@452
    49
	RAZOR_STAGE_SCRIPTS_PRE = 0x1,
ali@452
    50
	RAZOR_STAGE_FILES = 0x2,
ali@452
    51
	RAZOR_STAGE_SCRIPTS_POST = 0x4,
ali@452
    52
	RAZOR_STAGE_SCRIPTS = 0x5,
ali@452
    53
	RAZOR_STAGE_ALL = 0x7
ali@452
    54
};
ali@452
    55
ali@452
    56
enum razor_detail_type {
ali@452
    57
	RAZOR_DETAIL_LAST = 0,	/* the sentinel */
ali@452
    58
	RAZOR_DETAIL_NAME,
ali@452
    59
	RAZOR_DETAIL_VERSION,
ali@452
    60
	RAZOR_DETAIL_ARCH,
ali@452
    61
	RAZOR_DETAIL_SUMMARY,
ali@452
    62
	RAZOR_DETAIL_DESCRIPTION,
ali@452
    63
	RAZOR_DETAIL_URL,
ali@452
    64
	RAZOR_DETAIL_LICENSE,
ali@452
    65
	RAZOR_DETAIL_PREUNPROG,
ali@452
    66
	RAZOR_DETAIL_PREUN,
ali@452
    67
	RAZOR_DETAIL_POSTUNPROG,
ali@452
    68
	RAZOR_DETAIL_POSTUN,
ali@452
    69
	RAZOR_DETAIL_PREFIXES
ali@452
    70
};
ali@452
    71
ali@452
    72
enum razor_property_flags {
ali@452
    73
	RAZOR_PROPERTY_LESS		= 1 << 0,
ali@452
    74
	RAZOR_PROPERTY_GREATER		= 1 << 1,
ali@452
    75
	RAZOR_PROPERTY_EQUAL		= 1 << 2,
ali@452
    76
	RAZOR_PROPERTY_RELATION_MASK	=
ali@452
    77
		RAZOR_PROPERTY_LESS |
ali@452
    78
		RAZOR_PROPERTY_GREATER |
ali@452
    79
		RAZOR_PROPERTY_EQUAL,
ali@452
    80
ali@452
    81
	RAZOR_PROPERTY_REQUIRES		= 0 << 3,
ali@452
    82
	RAZOR_PROPERTY_PROVIDES		= 1 << 3,
ali@452
    83
	RAZOR_PROPERTY_CONFLICTS	= 2 << 3,
ali@452
    84
	RAZOR_PROPERTY_OBSOLETES	= 3 << 3,
ali@452
    85
	RAZOR_PROPERTY_TYPE_MASK	= 3 << 3,
ali@452
    86
		
ali@452
    87
	RAZOR_PROPERTY_PRE		= 1 << 5,
ali@452
    88
	RAZOR_PROPERTY_POST		= 1 << 6,
ali@452
    89
	RAZOR_PROPERTY_PREUN		= 1 << 7,
ali@452
    90
	RAZOR_PROPERTY_POSTUN		= 1 << 8,
ali@452
    91
	RAZOR_PROPERTY_SCRIPT_MASK	=
ali@452
    92
		RAZOR_PROPERTY_PRE |
ali@452
    93
		RAZOR_PROPERTY_POST |
ali@452
    94
		RAZOR_PROPERTY_PREUN |
ali@452
    95
		RAZOR_PROPERTY_POSTUN
ali@452
    96
};
ali@452
    97
ali@452
    98
enum razor_set_flags {
ali@452
    99
	/*
ali@452
   100
	 * Create a private copy of the razor set such that changes made
ali@452
   101
	 * to the underlying file are not visible in the razor set.
ali@452
   102
	 * If this flag is not set then the caller must ensure that the
ali@452
   103
	 * underlying file (if any) is not changed.
ali@452
   104
	 */
ali@452
   105
	RAZOR_SET_PRIVATE		= 1 << 0,
ali@452
   106
};
ali@452
   107
ali@452
   108
/**
ali@452
   109
 * SECTION:error
ali@452
   110
 * @title: Error reporting
ali@452
   111
 * @short_description: A system for reporting errors.
ali@452
   112
 *
ali@452
   113
 * This object represents an error condition.
ali@452
   114
 */
ali@452
   115
struct razor_error;
ali@452
   116
ali@452
   117
struct razor_error *razor_error_new_str(int domain, int code,
ali@452
   118
					const char *object, const char *str);
ali@452
   119
struct razor_error *razor_error_dup(struct razor_error *src,
ali@452
   120
				    const char *summary);
ali@452
   121
ali@452
   122
#define razor_set_error(error, domain, code, object, str) \
ali@452
   123
	if (error) \
ali@452
   124
		*(error) = razor_error_new_str(domain, code, object, str); \
ali@452
   125
	else
ali@452
   126
ali@452
   127
#define razor_propagate_error(dest, src, summary) \
ali@452
   128
	if (dest) \
ali@452
   129
		*(dest) = razor_error_dup(src, summary); \
ali@452
   130
	else
ali@452
   131
ali@452
   132
#define RAZOR_ERROR_DOMAIN(i1,i2,i3,c) \
ali@452
   133
	(((i1)&0xff)<<24|((i2)&0xff)<<16|((i3)&0xff)<<8|(c)&0xff)
ali@452
   134
ali@452
   135
#define RAZOR_GENERAL_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',0)
ali@452
   136
#define RAZOR_POSIX_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',1)
ali@452
   137
#define RAZOR_MSWIN_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',2)
ali@452
   138
#define RAZOR_ZLIB_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',3)
ali@452
   139
ali@452
   140
enum razor_general_error {
ali@452
   141
	RAZOR_GENERAL_ERROR_FAILED,
ali@452
   142
	RAZOR_GENERAL_ERROR_DATABASE_CORRUPTED,
ali@452
   143
	RAZOR_GENERAL_ERROR_DATABASE_INCOMPATIBLE,
ali@452
   144
	RAZOR_GENERAL_ERROR_DATABASE_EXISTS,
ali@452
   145
	RAZOR_GENERAL_ERROR_DATABASE_LOCKED,
ali@452
   146
	RAZOR_GENERAL_ERROR_RPM_UNSUPPORTED,
ali@452
   147
};
ali@452
   148
ali@452
   149
int razor_error_get_domain(struct razor_error *error);
ali@452
   150
int razor_error_get_code(struct razor_error *error);
ali@452
   151
const char *razor_error_get_object(struct razor_error *error);
ali@452
   152
const char *razor_error_get_primary_text(struct razor_error *error);
ali@452
   153
const char *razor_error_get_secondary_text(struct razor_error *error);
ali@452
   154
const char *razor_error_get_msg(struct razor_error *error);
ali@452
   155
void razor_error_free(struct razor_error *error);
ali@452
   156
ali@452
   157
/**
ali@452
   158
 * SECTION:atomic
ali@452
   159
 * @title: Atomic transactions
ali@452
   160
 * @short_description: File-based transactions that shouldn't half-succeed
ali@452
   161
 *
ali@452
   162
 * This is a helper object for issuing a sequence of file-based actions
ali@452
   163
 * that should either all succeed or all fail.
ali@452
   164
 *
ali@452
   165
 * Note that currently only Windows 7 has a native implementation and that
ali@452
   166
 * while the emulated fallback implementation attempts to rollback the
ali@452
   167
 * transaction if it fails, this is not guaranteed to succeed and that
ali@452
   168
 * the transaction is held in core (and thus vulnernable to program crashes,
ali@452
   169
 * power loss, etc.). This could (and should) be improved.
ali@452
   170
 *
ali@452
   171
 * Atomic transactions can be disabled via configure, in which case all
ali@452
   172
 * bets are off.
ali@452
   173
 **/
ali@452
   174
ali@452
   175
@RAZOR_HAVE_ATOMIC_ROLLBACK@
ali@452
   176
ali@452
   177
struct razor_atomic;
ali@452
   178
ali@452
   179
struct razor_atomic *razor_atomic_open(const char *description);
ali@452
   180
int razor_atomic_commit(struct razor_atomic *atomic);
ali@452
   181
struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
ali@452
   182
const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
ali@452
   183
void razor_atomic_destroy(struct razor_atomic *atomic);
ali@452
   184
ali@452
   185
/**
ali@452
   186
 * razor_atomic_make_dirs
ali@452
   187
 * 
ali@452
   188
 * Create all sub-directories leading up to path. We know root exists
ali@452
   189
 * and is a dir, root does not end in a '/', and path either has a
ali@452
   190
 * leading '/' or (on MS-Windows only) root is the empty string
ali@452
   191
 * and path starts with drive (eg., "c:/windows").
ali@452
   192
 * Note: path itself is not created, only the directory in which it
ali@452
   193
 * (would) exist.
ali@452
   194
 *
ali@452
   195
 * Returns: non-zero on error.
ali@452
   196
 **/
ali@452
   197
int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
ali@452
   198
  const char *path);
ali@452
   199
int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
ali@452
   200
int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
ali@452
   201
			     const char *newpath);
ali@452
   202
ali@452
   203
/**
ali@452
   204
 * razor_atomic_create_dir
ali@452
   205
 * 
ali@452
   206
 * Create a directory, replacing any existing object at this path except
ali@452
   207
 * an existing directory (which is not counted as a error).
ali@452
   208
 *
ali@452
   209
 * Returns: non-zero on error.
ali@452
   210
 */
ali@452
   211
int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
ali@452
   212
  mode_t mode);
ali@452
   213
ali@452
   214
/**
ali@452
   215
 * razor_atomic_create_symlink
ali@452
   216
 * 
ali@452
   217
 * Create a symbolic link, replacing any existing object at this path except
ali@452
   218
 * a non-empty directory.
ali@452
   219
 *
ali@452
   220
 * Note: This function will always fail on platforms that don't support
ali@452
   221
 * symbolic links.
ali@452
   222
 *
ali@452
   223
 * Returns: non-zero on error.
ali@452
   224
 */
ali@452
   225
int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
ali@452
   226
  const char *path);
ali@452
   227
/**
ali@452
   228
 * razor_atomic_create_file
ali@452
   229
 * 
ali@452
   230
 * Create a file, replacing any existing object at this path except
ali@452
   231
 * a non-empty directory.
ali@452
   232
 *
ali@452
   233
 * Returns: A handle to be passed to razor_atomic_write() and
ali@452
   234
 * razor_atomic_close() or a negative value on error.
ali@452
   235
 */
ali@452
   236
int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
ali@452
   237
  mode_t mode);
ali@452
   238
int razor_atomic_write(struct razor_atomic *atomic, int handle,
ali@452
   239
  const void *data, size_t size);
ali@452
   240
int razor_atomic_close(struct razor_atomic *atomic, int handle);
ali@452
   241
int razor_atomic_sync(struct razor_atomic *atomic, int handle);
ali@452
   242
void razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
ali@452
   243
  const char *error_msg);
ali@452
   244
void razor_atomic_propagate_error(struct razor_atomic *atomic,
ali@452
   245
  struct razor_error *error, const char *summary);
ali@452
   246
int razor_atomic_in_error_state(struct razor_atomic *atomic);
ali@452
   247
ali@452
   248
/**
ali@452
   249
 * SECTION:set
ali@452
   250
 * @title: Package Set
ali@452
   251
 * @short_description: Represents a set of packages and their metadata.
ali@452
   252
 *
ali@452
   253
 * This object represents a set of packages, their dependency
ali@452
   254
 * information, the file lists and a number of other details.
ali@452
   255
 **/
ali@452
   256
ali@452
   257
struct razor_set;
ali@452
   258
struct razor_package;
ali@452
   259
struct razor_property;
ali@452
   260
ali@452
   261
#define RAZOR_HEADER_VERSION		2	/* Current version */
ali@452
   262
#define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
ali@452
   263
ali@452
   264
/**
ali@452
   265
 * razor_set_create:
ali@452
   266
 * 
ali@452
   267
 * Create a new #razor_set object.
ali@452
   268
 * 
ali@452
   269
 * Returns: the new #razor_set object.
ali@452
   270
 **/
ali@452
   271
struct razor_set *razor_set_create_without_root(void);
ali@452
   272
struct razor_set *razor_set_create(void);
ali@452
   273
struct razor_set *
ali@452
   274
razor_set_open(const char *filename, enum razor_set_flags flags,
ali@452
   275
	       struct razor_error **error);
ali@452
   276
uint32_t razor_set_get_header_version(struct razor_set *set);
ali@452
   277
int razor_set_set_header_version(struct razor_set *set,
ali@452
   278
				 uint32_t header_version);
ali@452
   279
void razor_set_unref(struct razor_set *set);
ali@452
   280
struct razor_set *razor_set_ref(struct razor_set *set);
ali@452
   281
void razor_set_write_to_handle(struct razor_set *set,
ali@452
   282
			       struct razor_atomic *atomic, int handle,
ali@452
   283
			       uint32_t section_mask);
ali@452
   284
int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
ali@452
   285
		    const char *filename, uint32_t setions);
ali@452
   286
int
ali@452
   287
razor_set_bind_sections(struct razor_set *set, const char *filename,
ali@452
   288
			enum razor_set_flags flags, struct razor_error **error);
ali@452
   289
ali@452
   290
void
ali@452
   291
razor_package_get_details(struct razor_set *set,
ali@452
   292
			  struct razor_package *package, ...);
ali@452
   293
int
ali@452
   294
razor_package_remove(struct razor_set *prev, struct razor_set *next,
ali@452
   295
		     struct razor_atomic *atomic, struct razor_package *package,
ali@452
   296
		     const char *root, int install_count,
ali@452
   297
		     enum razor_stage_type stage);
ali@452
   298
ali@452
   299
/**
ali@452
   300
 * SECTION:iterator
ali@452
   301
 * @title: Iterators
ali@452
   302
 * @short_description: Objects for traversing packages or properties.
ali@452
   303
 *
ali@452
   304
 * The razor iterator objects provides a way to iterate through a set
ali@452
   305
 * of packages or properties.
ali@452
   306
 **/
ali@452
   307
ali@452
   308
struct razor_package_iterator;
ali@452
   309
ali@452
   310
/**
ali@452
   311
 * razor_package_iterator_create:
ali@452
   312
 * 
ali@452
   313
 * Create a new #razor_package_iterator object.
ali@452
   314
 * 
ali@452
   315
 * Returns: the new #razor_package_iterator object.
ali@452
   316
 **/
ali@452
   317
ali@452
   318
struct razor_package_iterator *
ali@452
   319
razor_package_iterator_create(struct razor_set *set);
ali@452
   320
ali@452
   321
/**
ali@452
   322
 * razor_package_iterator_create_for_property:
ali@452
   323
 * 
ali@452
   324
 * Create a new #razor_package_iterator object for the packages that
ali@452
   325
 * own the given property.
ali@452
   326
 * 
ali@452
   327
 * Returns: the new #razor_package_iterator object.
ali@452
   328
 **/
ali@452
   329
struct razor_package_iterator *
ali@452
   330
razor_package_iterator_create_for_property(struct razor_set *set,
ali@452
   331
					   struct razor_property *property);
ali@452
   332
ali@452
   333
/**
ali@452
   334
 * razor_package_iterator_create_for_file:
ali@452
   335
 *
ali@452
   336
 * Create a new #razor_package_iterator object for the packages that
ali@452
   337
 * contain the given file name.
ali@452
   338
 *
ali@452
   339
 * Returns: the new #razor_package_iterator object.
ali@452
   340
 **/
ali@452
   341
struct razor_package_iterator *
ali@452
   342
razor_package_iterator_create_for_file(struct razor_set *set,
ali@452
   343
				       const char *filename);
ali@452
   344
ali@452
   345
int razor_package_iterator_next(struct razor_package_iterator *pi,
ali@452
   346
				struct razor_package **package, ...);
ali@452
   347
void razor_package_iterator_destroy(struct razor_package_iterator *pi);
ali@452
   348
ali@452
   349
struct razor_package_query *
ali@452
   350
razor_package_query_create(struct razor_set *set);
ali@452
   351
void
ali@452
   352
razor_package_query_add_package(struct razor_package_query *pq,
ali@452
   353
				struct razor_package *p);
ali@452
   354
void
ali@452
   355
razor_package_query_add_iterator(struct razor_package_query *pq,
ali@452
   356
				 struct razor_package_iterator *pi);
ali@452
   357
struct razor_package_iterator *
ali@452
   358
razor_package_query_finish(struct razor_package_query *pq);
ali@452
   359
ali@452
   360
struct razor_property_iterator;
ali@452
   361
struct razor_property_iterator *
ali@452
   362
razor_property_iterator_create(struct razor_set *set,
ali@452
   363
			       struct razor_package *package);
ali@452
   364
int razor_property_iterator_next(struct razor_property_iterator *pi,
ali@452
   365
				 struct razor_property **property,
ali@452
   366
				 const char **name,
ali@452
   367
				 uint32_t *flags,
ali@452
   368
				 const char **version);
ali@452
   369
void
ali@452
   370
razor_property_iterator_destroy(struct razor_property_iterator *pi);
ali@452
   371
ali@452
   372
struct razor_file_iterator;
ali@452
   373
struct razor_file_iterator *
ali@452
   374
razor_file_iterator_create(struct razor_set *set,
ali@452
   375
			   struct razor_package *package, int post_order);
ali@452
   376
int razor_file_iterator_next(struct razor_file_iterator *fi,
ali@452
   377
			     const char **name);
ali@452
   378
void razor_file_iterator_destroy(struct razor_file_iterator *fi);
ali@452
   379
ali@452
   380
void razor_set_list_files(struct razor_set *set, const char *prefix);
ali@452
   381
void razor_set_list_package_files(struct razor_set *set,
ali@452
   382
				  struct razor_package *package);
ali@452
   383
ali@452
   384
enum razor_diff_action {
ali@452
   385
	RAZOR_DIFF_ACTION_ADD,
ali@452
   386
	RAZOR_DIFF_ACTION_REMOVE,
ali@452
   387
};
ali@452
   388
ali@452
   389
typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
ali@452
   390
				      struct razor_package *package,
ali@452
   391
				      const char *name,
ali@452
   392
				      const char *version,
ali@452
   393
				      const char *arch,
ali@452
   394
				      void *data);
ali@452
   395
ali@452
   396
void
ali@452
   397
razor_set_diff(struct razor_set *set, struct razor_set *upstream,
ali@452
   398
	       razor_diff_callback_t callback, void *data);
ali@452
   399
ali@452
   400
struct razor_install_iterator;
ali@452
   401
ali@452
   402
enum razor_install_action {
ali@452
   403
	RAZOR_INSTALL_ACTION_ADD,
ali@452
   404
	RAZOR_INSTALL_ACTION_REMOVE,
ali@452
   405
	RAZOR_INSTALL_ACTION_COMMIT
ali@452
   406
};
ali@452
   407
ali@452
   408
struct razor_install_iterator *
ali@452
   409
razor_set_create_install_iterator(struct razor_set *set,
ali@452
   410
				  struct razor_set *next);
ali@452
   411
ali@452
   412
int razor_install_iterator_next(struct razor_install_iterator *ii,
ali@452
   413
				struct razor_package **package,
ali@452
   414
				enum razor_install_action *action,
ali@452
   415
				int *count);
ali@452
   416
ali@452
   417
/**
ali@452
   418
 * razor_install_iterator_commit_set
ali@452
   419
 *
ali@452
   420
 * Immediately after razor_install_iterator_next() returns
ali@452
   421
 * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
ali@452
   422
 * which should be committed.
ali@452
   423
 *
ali@452
   424
 * Returns: a new #razor_set object.
ali@452
   425
 **/
ali@452
   426
struct razor_set *
ali@452
   427
razor_install_iterator_commit_set(struct razor_install_iterator *ii);
ali@452
   428
ali@452
   429
void razor_install_iterator_rewind(struct razor_install_iterator *ii);
ali@452
   430
size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
ali@452
   431
size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
ali@452
   432
				   size_t pos);
ali@452
   433
void razor_install_iterator_destroy(struct razor_install_iterator *ii);
ali@452
   434
ali@452
   435
/**
ali@452
   436
 * SECTION:transaction
ali@452
   437
 * @title: Transaction
ali@452
   438
 * @short_description: Create a new package set by merging two or more sets.
ali@452
   439
 *
ali@452
   440
 * The razor transaction object provides a way to create a new package set
ali@452
   441
 * from packages from one or more other package sets.
ali@452
   442
 **/
ali@452
   443
ali@452
   444
struct razor_rpm;
ali@452
   445
ali@452
   446
struct razor_transaction *
ali@452
   447
razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
ali@452
   448
void razor_transaction_install_package(struct razor_transaction *transaction,
ali@452
   449
				       struct razor_package *package);
ali@452
   450
void razor_transaction_remove_package(struct razor_transaction *transaction,
ali@452
   451
				      struct razor_package *package);
ali@452
   452
void razor_transaction_update_package(struct razor_transaction *trans,
ali@452
   453
				      struct razor_package *package);
ali@452
   454
void razor_transaction_fixup_package(struct razor_transaction *trans,
ali@452
   455
				     struct razor_package *package,
ali@452
   456
				     struct razor_rpm *rpm);
ali@452
   457
void razor_transaction_update_all(struct razor_transaction *transaction);
ali@452
   458
int razor_transaction_resolve(struct razor_transaction *trans);
ali@452
   459
ali@452
   460
typedef void (*razor_unsatisfied_callback_t)(const char *requirement,
ali@452
   461
					     struct razor_package *package,
ali@452
   462
					     const char *name,
ali@452
   463
					     const char *version,
ali@452
   464
					     const char *arch,
ali@452
   465
					     void *data);
ali@452
   466
ali@452
   467
int razor_transaction_unsatisfied(struct razor_transaction *trans,
ali@452
   468
				  razor_unsatisfied_callback_t callback,
ali@452
   469
				  void *data);
ali@452
   470
int razor_transaction_describe(struct razor_transaction *trans);
ali@452
   471
struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
ali@452
   472
void razor_transaction_destroy(struct razor_transaction *trans);
ali@452
   473
ali@452
   474
/* Temporary helper for test suite. */
ali@452
   475
int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
ali@452
   476
					   const char *name,
ali@452
   477
					   uint32_t flags,
ali@452
   478
					   const char *version);
ali@452
   479
ali@452
   480
/**
ali@452
   481
 * SECTION:rpm
ali@452
   482
 * @title: Razor RPM
ali@452
   483
 * @short_description: Operating on RPM files.
ali@452
   484
 *
ali@452
   485
 * Functions for open RPM files and extracting information and
ali@452
   486
 * installing or removing RPM files.
ali@452
   487
 **/
ali@452
   488
ali@452
   489
struct razor_relocations;
ali@452
   490
ali@452
   491
struct razor_relocations *razor_relocations_create(void);
ali@452
   492
void razor_relocations_add(struct razor_relocations *relocations,
ali@452
   493
			   const char *oldpath, const char *newpath);
ali@452
   494
void razor_relocations_set_rpm(struct razor_relocations *relocations,
ali@452
   495
			       struct razor_rpm *rpm);
ali@452
   496
const char *razor_relocations_apply(struct razor_relocations *relocations,
ali@452
   497
				    const char *path);
ali@452
   498
void razor_relocations_destroy(struct razor_relocations *relocations);
ali@452
   499
ali@452
   500
struct razor_rpm *razor_rpm_open(const char *filename,
ali@452
   501
				 struct razor_error **error);
ali@452
   502
void razor_rpm_get_details(struct razor_rpm *rpm, ...);
ali@452
   503
void razor_rpm_set_relocations(struct razor_rpm *rpm,
ali@452
   504
			       struct razor_relocations *relocations);
ali@452
   505
int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
ali@452
   506
		      const char *root, int install_count,
ali@452
   507
		      enum razor_stage_type stage);
ali@452
   508
int razor_rpm_close(struct razor_rpm *rpm);
ali@452
   509
ali@452
   510
/**
ali@452
   511
 * SECTION:importer
ali@452
   512
 * @title: Importer
ali@452
   513
 * @short_description: A mechanism for building #razor_set objects
ali@452
   514
 *
ali@452
   515
 * The %razor_importer is a helper object for building a razor set
ali@452
   516
 * from external sources, like yum metadata, the RPM database or RPM
ali@452
   517
 * files.
ali@452
   518
 *
ali@452
   519
 * The importer is a stateful object; it has the notion of a current
ali@452
   520
 * package, and the caller can provide meta data such as properties,
ali@452
   521
 * files and similiar for the package as it becomes available.  Once a
ali@452
   522
 * package is fully described, the next pacakge can begin.  When all
ali@452
   523
 * packages have been described to the importer, the importer will
ali@452
   524
 * create a new %razor_set with the specified packages.
ali@452
   525
 *
ali@452
   526
 * A typical use
ali@452
   527
 * of the importer will follow this template:
ali@452
   528
 * |[
ali@452
   529
 * importer = razor_importer_create();
ali@452
   530
 *
ali@452
   531
 * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
ali@452
   532
 *   /<!-- -->* get name, version and arch of next package *<!-- -->/
ali@452
   533
 *   razor_importer_begin_package(importer, name, version, arch);
ali@452
   534
 *   razor_importer_add_details(importer, summary, description, url, license);
ali@452
   535
 *
ali@452
   536
 *   while ( /<!-- -->* more properties to add *<!-- -->/ )
ali@452
   537
 *     razor_importer_add_property(importer, name, flags, version);
ali@452
   538
 *
ali@452
   539
 *   while ( /<!-- -->* [more files to add *<!-- -->/ )
ali@452
   540
 *     razor_importer_add_file(importer, name);
ali@452
   541
 *
ali@452
   542
 *   razor_importer_finish_package(importer);
ali@452
   543
 * }
ali@452
   544
 *
ali@452
   545
 * return razor_importer_finish(importer);
ali@452
   546
 * ]|
ali@452
   547
 **/
ali@452
   548
struct razor_importer;
ali@452
   549
ali@452
   550
struct razor_importer *razor_importer_create(void);
ali@452
   551
void razor_importer_destroy(struct razor_importer *importer);
ali@452
   552
void razor_importer_begin_package(struct razor_importer *importer,
ali@452
   553
				  const char *name,
ali@452
   554
				  const char *version,
ali@452
   555
				  const char *arch);
ali@452
   556
void razor_importer_add_details(struct razor_importer *importer,
ali@452
   557
				const char *summary,
ali@452
   558
				const char *description,
ali@452
   559
				const char *url,
ali@452
   560
				const char *license);
ali@452
   561
void razor_importer_add_script(struct razor_importer *importer,
ali@452
   562
			       enum razor_property_flags script,
ali@452
   563
			       const char *program,
ali@452
   564
			       const char *body);
ali@452
   565
void razor_importer_add_install_prefix(struct razor_importer *importer,
ali@452
   566
				       const char *install_prefix);
ali@452
   567
void razor_importer_add_property(struct razor_importer *importer,
ali@452
   568
				 const char *name,
ali@452
   569
				 uint32_t flags,
ali@452
   570
				 const char *version);
ali@452
   571
void razor_importer_add_file(struct razor_importer *importer,
ali@452
   572
			     const char *name);
ali@452
   573
void razor_importer_finish_package(struct razor_importer *importer);
ali@452
   574
ali@452
   575
int razor_importer_add_rpm(struct razor_importer *importer,
ali@452
   576
			   struct razor_rpm *rpm);
ali@452
   577
ali@452
   578
struct razor_set *razor_importer_finish(struct razor_importer *importer);
ali@452
   579
ali@452
   580
struct razor_set *razor_set_create_from_yum(void);
ali@452
   581
struct razor_set *razor_set_create_from_rpmdb(void);
ali@452
   582
ali@452
   583
/**
ali@452
   584
 * SECTION:root
ali@452
   585
 * @title: Root
ali@452
   586
 * @short_description: Functions for accessing an install root.
ali@452
   587
 *
ali@452
   588
 * The #razor_root object encapsulate access to and locking of a razor
ali@452
   589
 * install root.
ali@452
   590
 **/
ali@452
   591
struct razor_root;
ali@452
   592
ali@452
   593
const char *razor_get_database_path();
ali@452
   594
void razor_set_database_path(const char *database_path);
ali@452
   595
int razor_root_create(const char *root, struct razor_error **error);
ali@452
   596
struct razor_root *
ali@452
   597
razor_root_open(const char *root, struct razor_error **error);
ali@452
   598
struct razor_set *
ali@452
   599
razor_root_open_read_only(const char *root, struct razor_error **error);
ali@452
   600
struct razor_set *razor_root_get_system_set(struct razor_root *root);
ali@452
   601
int razor_root_close(struct razor_root *root);
ali@452
   602
int
ali@452
   603
razor_root_update(struct razor_root *root, struct razor_set *next,
ali@452
   604
		  struct razor_atomic *atomic);
ali@452
   605
ali@452
   606
/**
ali@452
   607
 * SECTION:misc
ali@452
   608
 * @title: Miscellaneous Functions
ali@452
   609
 * @short_description: Various helper functions
ali@452
   610
 *
ali@452
   611
 * Functions that doesn't fit anywhere else.
ali@452
   612
 **/
ali@452
   613
ali@452
   614
const char *
ali@452
   615
razor_property_relation_to_string(struct razor_property *p);
ali@452
   616
const char *
ali@452
   617
razor_property_type_to_string(struct razor_property *p);
ali@452
   618
ali@452
   619
void razor_build_evr(char *evr_buf, int size, const char *epoch,
ali@452
   620
		     const char *version, const char *release);
ali@452
   621
int razor_versioncmp(const char *s1, const char *s2);
ali@452
   622
ali@452
   623
void razor_disable_root_name_checks(int disable);
ali@452
   624
ali@452
   625
void razor_set_lua_loader(const char *modname, void (*loader)());
ali@452
   626
void (*razor_get_lua_loader(const char *modname))();
ali@452
   627
ali@452
   628
char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
ali@452
   629
ali@452
   630
char *razor_path_add_root(const char *path, const char *root) RAZOR_MALLOC;
ali@452
   631
ali@452
   632
const char *razor_system_arch(void);
ali@452
   633
ali@452
   634
#endif /* _RAZOR_H_ */