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