RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Per Øyvind Karlsen Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 17-Jul-2008 20:18:24 Branch: HEAD Handle: 2008071718182300 Modified files: rpm/lib filetriggers.c Log: pass filename as argument to filetrigger script so it can be used with specific files as well (room for improvement!) Summary: Revision Changes Path 2.6 +14 -8 rpm/lib/filetriggers.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/lib/filetriggers.c ============================================================================ $ cvs diff -u -r2.5 -r2.6 filetriggers.c --- rpm/lib/filetriggers.c 17 Jul 2008 15:36:33 -0000 2.5 +++ rpm/lib/filetriggers.c 17 Jul 2008 18:18:23 -0000 2.6 @@ -79,6 +79,7 @@ struct filetrigger { miRE mire; char *name; + char *filename; int command_pipe; int command_pid; }; @@ -184,7 +185,7 @@ return mireRegexec(re, s, (size_t) 0) == 0; } -static int popen_with_root(const char *rootDir, const char *cmd, int *pid) +static int popen_with_root(const char *rootDir, const char *cmd, const char *filename, int *pid) { int pipes[2]; @@ -203,9 +204,10 @@ } chdir("/"); } - const char *argv[2]; + const char *argv[3]; argv[0] = cmd; - argv[1] = NULL; + argv[1] = filename; + argv[2] = NULL; execv(argv[0], (char *const *) argv); _exit(-1); } @@ -220,8 +222,8 @@ if (!trigger->command_pipe) { char *cmd = NULL; if (asprintf(&cmd, "%s/%s.script", filetriggers_dir(), trigger->name) != -1) { - rpmlog(RPMLOG_DEBUG, "[filetriggers] spawning %s\n", cmd); - trigger->command_pipe = popen_with_root(rootDir, cmd, &trigger->command_pid); + rpmlog(RPMLOG_DEBUG, "[filetriggers] spawning %s %s\n", cmd, trigger->filename); + trigger->command_pipe = popen_with_root(rootDir, cmd, trigger->filename, &trigger->command_pid); _free(cmd); } } @@ -253,9 +255,13 @@ rpmlog(RPMLOG_DEBUG, "[filetriggers] matches-any regexp found %s", tmp); int i; for (i = 0; i < nb; i++) - if (is_regexp_matching(list[i].mire, tmp)) { - mayStartFiletrigger(rootDir, &list[i]); - write(list[i].command_pipe, tmp, strlen(tmp)); + if (is_regexp_matching(list[i].mire, tmp)) { + int tmplen = strlen(tmp); + list[i].filename = malloc(tmplen - 1); + int j; + for (j = 1; j < tmplen; j++) list[i].filename[j-1] = tmp[j]; + mayStartFiletrigger(rootDir, &list[i]); + write(list[i].command_pipe, tmp, tmplen); } } fclose(awaiting); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org