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, "<lua>") == 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, "<lua>") == 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;
}