From: J. Ali Harlow Date: Fri, 1 May 2009 15:43:37 +0000 (+0100) Subject: Set RPM_INSTALL_PREFIX{n} environment variables for use in scripts X-Git-Tag: 0.1~16 X-Git-Url: http://project.juiblex.co.uk/git/?a=commitdiff_plain;h=6931121cbd6dc1e6df039f640c95a2d0cf2b1126;p=razor2.git%2F.git Set RPM_INSTALL_PREFIX{n} environment variables for use in scripts --- diff --git a/librazor/rpm.c b/librazor/rpm.c index f2fa569..c3bb5c9 100644 --- a/librazor/rpm.c +++ b/librazor/rpm.c @@ -841,18 +841,43 @@ static int run_script(struct installer *installer, unsigned int program_tag, unsigned int script_tag) { - int retval; - const char *script = NULL, *program = NULL; - - program = razor_rpm_get_indirect(installer->rpm, program_tag, NULL); - script = razor_rpm_get_indirect(installer->rpm, script_tag, 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(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; }