diff -r 6e93e5485947 -r 5549419824b4 librazor/rpm.c --- a/librazor/rpm.c Fri Jul 03 18:02:33 2009 +0100 +++ b/librazor/rpm.c Wed Jul 08 22:14:16 2009 +0100 @@ -874,7 +874,8 @@ } static int -run_script_lua(const char *root, unsigned int script_tag, const char *script) +run_script_lua(const char *root, unsigned int script_tag, const char *script, + int arg1) { int root_fd, retval; #if HAVE_LUA @@ -898,7 +899,8 @@ break; } root_fd = chroot_push(root); - retval = run_lua_script(root_fd < 0 ? root : NULL, name, script, -1); + retval = run_lua_script(root_fd < 0 ? root : NULL, name, script, -1, + arg1); chroot_pop(root_fd); #else /* HAVE_LUA */ fprintf(stderr, "lua not available to run script\n"); @@ -909,10 +911,12 @@ } static int -run_script_external(const char *root, const char *program, const char *script) +run_script_external(const char *root, const char *program, const char *script, + int arg1) { int root_fd, retval; FILE *fp; + char buf[32], *command; if (program == NULL) { #if MSWIN_API @@ -930,7 +934,14 @@ } root_fd = chroot_push(root); - fp = popen(program, "w"); + if (arg1 >= 0) { + sprintf(buf, "%d", arg1); + command = malloc(strlen(program) + strlen(buf) + 2); + sprintf(command, "%s %s", program, buf); + } else + command = strdup(program); + fp = popen(command, "w"); + free(command); if (!fp) { perror(program); @@ -950,12 +961,12 @@ static int run_script(struct installer *installer, - unsigned int program_tag, unsigned int script_tag) + unsigned int program_tag, unsigned int script_tag, int arg1) { int i, retval; struct razor_rpm *rpm = installer->rpm; const char *script = NULL, *program = NULL, *prefix; - char buf[32], *p; + char buf[32]; struct environment env; program = razor_rpm_get_indirect(rpm, program_tag, NULL); @@ -975,9 +986,11 @@ } if (program && strcmp(program, "") == 0) - retval = run_script_lua(installer->root, script_tag, script); + retval = run_script_lua(installer->root, script_tag, script, + arg1); else - retval = run_script_external(installer->root, program, script); + retval = run_script_external(installer->root, program, script, + arg1); if (rpm->relocations) { environment_unset(&env); @@ -989,7 +1002,7 @@ int razor_run_script(const char *root, enum razor_property_flags script, - const char *program, const char *body) + const char *program, const char *body, int arg1) { int retval; unsigned int script_tag; @@ -1020,10 +1033,10 @@ script_tag = 0; break; } - retval = run_script_lua(root, script_tag, body); + retval = run_script_lua(root, script_tag, body, arg1); } else - retval = run_script_external(root, program, body); + retval = run_script_external(root, program, body, arg1); return retval; } @@ -1101,7 +1114,7 @@ } RAZOR_EXPORT int -razor_rpm_install(struct razor_rpm *rpm, const char *root) +razor_rpm_install(struct razor_rpm *rpm, const char *root, int install_count) { struct installer installer; struct cpio_file_header *header; @@ -1130,7 +1143,7 @@ if (installer_init(&installer)) return -1; - run_script(&installer, RPMTAG_PREINPROG, RPMTAG_PREIN); + run_script(&installer, RPMTAG_PREINPROG, RPMTAG_PREIN, install_count); while (installer.stream.avail_in > 0) { installer.rest = sizeof *header; @@ -1167,7 +1180,7 @@ if (installer_finish(&installer)) return -1; - run_script(&installer, RPMTAG_POSTINPROG, RPMTAG_POSTIN); + run_script(&installer, RPMTAG_POSTINPROG, RPMTAG_POSTIN, install_count); return 0; }