ALT Linux Bugzilla
– Attachment 1009 Details for
Bug 7409
find-requires for %pre/%preun/%post/%postun scriplets
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
patch for build/files.c
rpm-4.0-alt-script-findreq.patch (text/plain), 5.59 KB, created by
at@altlinux.org
on 2005-07-20 18:44:20 MSD
(
hide
)
Description:
patch for build/files.c
Filename:
MIME Type:
Creator:
at@altlinux.org
Created:
2005-07-20 18:44:20 MSD
Size:
5.59 KB
patch
obsolete
>--- rpm-4_0-4.0.4/build/files.c- 2004-01-27 13:53:38 +0300 >+++ rpm-4_0-4.0.4/build/files.c 2005-07-20 18:00:00 +0400 >@@ -2468,6 +2468,89 @@ DepMsg_t depMsgs[] = { > }; > /*@=exportlocal =exportheadervar@*/ > >+typedef struct { >+ char *scriptname; >+ int progTag; >+ int scriptTag; >+} ScriptDep_t; >+ >+ScriptDep_t scriptDeps[] = { >+ { "pre", RPMTAG_PREINPROG, RPMTAG_PREIN }, >+ { "preun", RPMTAG_PREUNPROG, RPMTAG_PREUN }, >+ { "post", RPMTAG_POSTINPROG, RPMTAG_POSTIN }, >+ { "postun", RPMTAG_POSTUNPROG, RPMTAG_POSTUN }, >+ { NULL, 0, 0 } >+}; >+ >+static char *saveInstScript(Spec spec, Package pkg, const char *scriptname) >+{ >+ ScriptDep_t *sd; >+ int progTag = 0, scriptTag = 0; >+ >+ for (sd = scriptDeps; sd->scriptname; sd++) >+ if (strcmp(scriptname, sd->scriptname) == 0) { >+ progTag = sd->progTag; >+ scriptTag = sd->scriptTag; >+ break; >+ } >+ if (!scriptTag) >+ return NULL; >+ >+ /* similar to runInstScript() */ >+ rpmTagType stt; >+ char *script = NULL; >+ HGE_t hge = (HGE_t)headerGetEntryMinMemory; >+ >+ hge(pkg->header, scriptTag, &stt, &script, NULL); >+ if (!script) >+ return NULL; >+ >+ rpmTagType ptt; >+ int argc; >+ const char **argv = NULL; >+ const char *argv1[1]; >+ >+ hge(pkg->header, progTag, &ptt, &argv, &argc); >+ if (argv && ptt == RPM_STRING_TYPE) { >+ argv1[0] = (const char *) argv; >+ argv = argv1; >+ argc = 1; >+ } >+ if (!argv) { >+ argv1[0] = "/bin/sh"; >+ argv = argv1; >+ argc = 1; >+ } >+ >+ char *path = rpmGenPath(spec->buildRootURL, ".script.XXXXXX", NULL); >+ int fd = mkstemp(path); >+ if (fd < 0) { >+ perror("mkstemp"); >+ exit(1); >+ } >+ >+ fchmod(fd, 0755); >+ >+ FILE *f = fdopen(fd, "w"); >+ if (!f) { >+ perror("fdopen"); >+ exit(1); >+ } >+ >+ fprintf(f, "#!%s", argv[0]); >+ while (--argc > 0) >+ fprintf(f, " %s", *++argv); >+ fprintf(f, "\n%s\n", script); >+ fclose(f); >+ >+#if 0 >+ char *cmd; >+ asprintf(&cmd, "set -x; cat %s", path); >+ system(cmd); >+#endif >+ return path; >+} >+ > /** > */ > static int generateDepends(Spec spec, Package pkg, TFI_t cpioList, int multiLib) >@@ -2477,8 +2560,6 @@ static int generateDepends(Spec spec, Pa > fileSystem, internalState @*/ > { > TFI_t fi = cpioList; >- StringBuf writeBuf; >- int writeBytes; > StringBuf readBuf; > DepMsg_t *dm; > int failnonzero = 1; >@@ -2497,9 +2578,6 @@ static int generateDepends(Spec spec, Pa > const char *mPost = "%{__spec_autodep_post}"; > urlinfo u = NULL; > >- if (!(fi && fi->fc > 0)) >- return 0; >- > if ( !*pkg->autoReq && !*pkg->autoProv ) > return 0; > >@@ -2536,19 +2614,24 @@ static int generateDepends(Spec spec, Pa > runTemplate = rpmExpand(mTemplate, NULL); > runPost = rpmExpand(mPost, NULL); > >- writeBuf = newStringBuf(); >- for (i = 0, writeBytes = 0; i < fi->fc; i++) { >+ StringBuf fileListBuf = NULL; >+ int fileListBytes = 0; > >- if (fi->fmapflags && multiLib == 2) { >- if (!(fi->fmapflags[i] & CPIO_MULTILIB)) >- continue; >- fi->fmapflags[i] &= ~CPIO_MULTILIB; >- } >- >- appendStringBuf(writeBuf, fi->dnl[fi->dil[i]]); >- writeBytes += strlen(fi->dnl[fi->dil[i]]); >- appendLineStringBuf(writeBuf, fi->bnl[i]); >- writeBytes += strlen(fi->bnl[i]) + 1; >+ if (fi && fi->fc > 0) { >+ fileListBuf = newStringBuf(); >+ for (i = 0, fileListBytes = 0; i < fi->fc; i++) { >+ >+ if (fi->fmapflags && multiLib == 2) { >+ if (!(fi->fmapflags[i] & CPIO_MULTILIB)) >+ continue; >+ fi->fmapflags[i] &= ~CPIO_MULTILIB; >+ } >+ >+ appendStringBuf(fileListBuf, fi->dnl[fi->dil[i]]); >+ fileListBytes += strlen(fi->dnl[fi->dil[i]]); >+ appendLineStringBuf(fileListBuf, fi->bnl[i]); >+ fileListBytes += strlen(fi->bnl[i]) + 1; >+ } > } > > for (dm = depMsgs; dm->msg != NULL; dm++) { >@@ -2560,26 +2643,52 @@ static int generateDepends(Spec spec, Pa > FILE *fp = 0; > char *runBody = 0; > >- if ( !dm->argv || !dm->argv[0] ) >+ char *instScript = NULL; >+ >+ if (!dm->argv[0] && dm->argv[1]) >+ instScript = saveInstScript(spec, pkg, dm->argv[1]); >+ >+ if (!dm->argv[0] && !instScript) >+ continue; >+ >+ char *writeBuf; >+ int writeBytes; >+ >+ if (instScript) { >+ writeBuf = newStringBuf(); >+ appendLineStringBuf(writeBuf, instScript); >+ writeBytes = strlen(instScript) + 1; >+ } else { >+ writeBuf = fileListBuf; >+ writeBytes = fileListBytes; >+ } >+ >+ if (!writeBuf) > continue; > >+ if (instScript) /* similar to parseScript() */ >+ tagflags = dm->mask | RPMSENSE_PREREQ; >+ > switch(tag) { > case RPMTAG_PROVIDEFLAGS: > if (!*pkg->autoProv) > continue; >- tagflags = RPMSENSE_FIND_PROVIDES; >+ tagflags |= RPMSENSE_FIND_PROVIDES; > /*@switchbreak@*/ break; > case RPMTAG_REQUIREFLAGS: > if (!*pkg->autoReq) > continue; >- tagflags = RPMSENSE_FIND_REQUIRES; >+ tagflags |= RPMSENSE_FIND_REQUIRES; > /*@switchbreak@*/ break; > default: > continue; > /*@notreached@*/ /*@switchbreak@*/ break; > } > >- runBody = rpmExpand( dm->argv[0], NULL ); >+ if (instScript) >+ runBody = rpmExpand( "%{__find_requires}", NULL); >+ else >+ runBody = rpmExpand( dm->argv[0], NULL ); > > if ( !runBody || '%' == runBody[0] ) > { >@@ -2587,7 +2696,7 @@ static int generateDepends(Spec spec, Pa > continue; > } > >- { >+ if (!instScript) { > const char **av; > for ( av = dm->argv + 1; av[0]; ++av ) > { >@@ -2690,6 +2799,13 @@ static int generateDepends(Spec spec, Pa > > Unlink(scriptName); > scriptName = _free(scriptName); >+ >+ if (instScript) { >+ unlink(instScript); >+ _free(instScript); >+ _free(writeBuf); >+ } >+ > } > > if (u) { >@@ -2708,7 +2824,8 @@ static int generateDepends(Spec spec, Pa > runPost = _free(runPost); > runTemplate = _free(runTemplate); > runDirURL = _free(runDirURL); >- writeBuf = freeStringBuf(writeBuf); >+ if (fileListBuf) >+ fileListBuf = freeStringBuf(fileListBuf); > return rc; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 7409
: 1009