# HG changeset patch # User J. Ali Harlow # Date 1241192617 -3600 # Node ID cf88b5df2884385513c4c861aacd4b618a2f7bf6 # Parent 2523d03a840ee74d32321cccad33ad7024c2fac2 Set RPM_INSTALL_PREFIX{n} environment variables for use in scripts diff -r 2523d03a840e -r cf88b5df2884 librazor/rpm.c --- a/librazor/rpm.c Wed Apr 29 17:00:01 2009 +0100 +++ b/librazor/rpm.c Fri May 01 16:43:37 2009 +0100 @@ -841,18 +841,43 @@ run_script(struct installer *installer, unsigned int program_tag, unsigned int script_tag) { - int retval; - const char *script = NULL, *program = NULL; + int i, retval; + struct razor_rpm *rpm = installer->rpm; + const char *script = NULL, *program = NULL, *prefix; + char buf[32], *p; + struct array prefix_pool; - program = razor_rpm_get_indirect(installer->rpm, program_tag, NULL); - script = razor_rpm_get_indirect(installer->rpm, script_tag, NULL); + program = razor_rpm_get_indirect(rpm, program_tag, NULL); + script = razor_rpm_get_indirect(rpm, script_tag, NULL); if (program == NULL && script == NULL) - retval = 0; - else if (strcmp(program, "") == 0) + return 0; + + if (rpm->relocations) { + array_init(&prefix_pool); + for(i = 0; i < rpm->n_prefixes; i++) { + prefix = razor_relocations_apply(rpm->relocations, + rpm->prefixes[i]); + sprintf(buf, "RPM_INSTALL_PREFIX%d", i); + p = array_add(&prefix_pool, + strlen(buf) + strlen(prefix) + 2); + sprintf(p, "%s=%s", buf, prefix); + putenv(p); + } + } + + if (strcmp(program, "") == 0) retval = run_script_lua(installer->root, script_tag, script); else retval = run_script_external(installer->root, program, script); + if (rpm->relocations) { + for(i = 0; i < rpm->n_prefixes; i++) { + sprintf(buf, "RPM_INSTALL_PREFIX%d=", i); + putenv(buf); + } + array_release(&prefix_pool); + } + return retval; }