librazor/importer.c
changeset 370 a3e288343fe7
parent 359 c9c90315ea24
child 372 6e93e5485947
     1.1 --- a/librazor/importer.c	Wed Apr 22 15:09:17 2009 +0100
     1.2 +++ b/librazor/importer.c	Thu Jul 02 11:31:03 2009 +0100
     1.3 @@ -1,6 +1,7 @@
     1.4  /*
     1.5   * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     1.6   * Copyright (C) 2008  Red Hat, Inc
     1.7 + * Copyright (C) 2009  J. Ali Harlow <ali@juiblex.co.uk>
     1.8   *
     1.9   * This program is free software; you can redistribute it and/or modify
    1.10   * it under the terms of the GNU General Public License as published by
    1.11 @@ -82,6 +83,7 @@
    1.12  			     const char *version,
    1.13  			     const char *arch)
    1.14  {
    1.15 +	uint32_t empty;
    1.16  	struct razor_package *p;
    1.17  
    1.18  	p = array_add(&importer->set->packages, sizeof *p);
    1.19 @@ -92,6 +94,12 @@
    1.20  
    1.21  	importer->package = p;
    1.22  	array_init(&importer->properties);
    1.23 +
    1.24 +	empty = hashtable_tokenize(&importer->details_table, "");
    1.25 +	importer->package->preun.program = empty;
    1.26 +	importer->package->preun.body = empty;
    1.27 +	importer->package->postun.program = empty;
    1.28 +	importer->package->postun.body = empty;
    1.29  }
    1.30  
    1.31  /**
    1.32 @@ -135,6 +143,39 @@
    1.33  }
    1.34  
    1.35  /**
    1.36 + * razor_importer_add_script:
    1.37 + * @importer: the %razor_importer
    1.38 + * @script: either %RAZOR_PROPERTY_PREUN or %RAZOR_PROPERTY_POSTUN
    1.39 + * @program: the program to run the script
    1.40 + * @body: the body of the script
    1.41 + *
    1.42 + * Provide a script to use when uninstalling the current package.
    1.43 + **/
    1.44 +RAZOR_EXPORT void
    1.45 +razor_importer_add_script(struct razor_importer *importer,
    1.46 +			  enum razor_property_flags script,
    1.47 +			  const char *program,
    1.48 +			  const char *body)
    1.49 +{
    1.50 +	switch (script) {
    1.51 +	case RAZOR_PROPERTY_PREUN:
    1.52 +		importer->package->preun.program =
    1.53 +			hashtable_tokenize(&importer->table, program);
    1.54 +		importer->package->preun.body =
    1.55 +			hashtable_tokenize(&importer->table, body);
    1.56 +		break;
    1.57 +	case RAZOR_PROPERTY_POSTUN:
    1.58 +		importer->package->postun.program =
    1.59 +			hashtable_tokenize(&importer->table, program);
    1.60 +		importer->package->postun.body =
    1.61 +			hashtable_tokenize(&importer->table, body);
    1.62 +		break;
    1.63 +	default:
    1.64 +		break;
    1.65 +	}
    1.66 +}
    1.67 +
    1.68 +/**
    1.69   * razor_importer_add_property:
    1.70   * @importer: the %razor_importer
    1.71   * @name: name of the property