This likely needs some explanation ...
If scriptlet bodies are expanded, then one can change the
behavior of install scriptlets through configuration.
Any/all macros can already be prefix'ed with '%%'
to escape the build time expansion.
The only risk is with accidental collision with a scriptlet
that uses '%' with its shell meaning.
Quck: How many of you know what shell does with '%' without looking
at the man page?
Hmmm, time to wire up the pre/post macros in the rpmExpand
so that install scriptlets behave exactly the same as build scritptlet
templates. Adding 2 args to the rpmExpand, todo++.
But if there are concerns, the change is trivially backed out.
Are there concerns?
73 de Jeff
On Dec 6, 2007, at 4:21 PM, Jeff Johnson wrote:
> RPM Package Manager, CVS Repository
> http://rpm5.org/cvs/
>
> ______________________________________________________________________
> ______
>
> Server: rpm5.org Name: Jeff Johnson
> Root: /v/rpm/cvs Email: jbj@rpm5.org
> Module: rpm Date: 06-Dec-2007
> 22:21:06
> Branch: HEAD Handle: 2007120621210501
>
> Modified files:
> rpm CHANGES TODO
> rpm/lib psm.c rpmlib.h
>
> Log:
> - jbj: macro expand all scriptlet bodies before execution. W00t!
>
> Summary:
> Revision Changes Path
> 1.1952 +1 -0 rpm/CHANGES
> 1.41 +2 -0 rpm/TODO
> 2.275 +8 -3 rpm/lib/psm.c
> 2.456 +6 -1 rpm/lib/rpmlib.h
>
> ______________________________________________________________________
> ______
>
> patch -p0 <<'@@ .'
> Index: rpm/CHANGES
>
> ======================================================================
> ======
> $ cvs diff -u -r1.1951 -r1.1952 CHANGES
> --- rpm/CHANGES 6 Dec 2007 20:49:16 -0000 1.1951
> +++ rpm/CHANGES 6 Dec 2007 21:21:05 -0000 1.1952
> @@ -1,4 +1,5 @@
> 5.0a4 -> 5.0b1:
> + - jbj: macro expand all scriptlet bodies before execution.
> W00t!
> - jbj: populate RPMTAG_BUILDMACROS. implementation took 6+
> years ...
> - jbj: add %sanitycheck scriptlet to packages. more wiring
> needed todo++.
> - jbj: add %track section/scriptlet. Hmmm, not in *.rpm
> content yet, todo++.
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/TODO
>
> ======================================================================
> ======
> $ cvs diff -u -r1.40 -r1.41 TODO
> --- rpm/TODO 6 Dec 2007 20:22:15 -0000 1.40
> +++ rpm/TODO 6 Dec 2007 21:21:05 -0000 1.41
> @@ -103,6 +103,7 @@
> - rse: NEWS polishing
> - jbj: fix openssl RSA signature verification.
> - jbj: drill Requires: sanitycheck(N) = E:V-R runtime probe.
> + - jbj: write up added featlets/bugtures in %docdir notes.
>
> RPM 5.1 ROADMAP ISSUES
> ----------------------
> @@ -118,3 +119,4 @@
> - jbj: add per-implementation symmetric ciphers.
> - jbj: permit per-file encryption with password caching
> through keyutils.
> - jbj: generalize the Leopard XAR format to ar (as in
> *.deb), tar, and cpio.
> + - jbj: eliminate the oddball *.src.rpm paths, nuke
> rpmInstallSourcePackage.
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/lib/psm.c
>
> ======================================================================
> ======
> $ cvs diff -u -r2.274 -r2.275 psm.c
> --- rpm/lib/psm.c 6 Dec 2007 14:47:49 -0000 2.274
> +++ rpm/lib/psm.c 6 Dec 2007 21:21:06 -0000 2.275
> @@ -667,6 +667,7 @@
> FD_t out;
> rpmRC rc = RPMRC_FAIL; /* assume failure */
> const char * NVRA;
> + const char * body = NULL;
> int * ssp = NULL;
> int xx;
> int i;
> @@ -679,6 +680,9 @@
> if (progArgv == NULL && script == NULL)
> return RPMRC_OK;
>
> + /* Macro expand all scriptlets. */
> + body = rpmExpand(script, NULL);
> +
> he->tag = RPMTAG_NVRA;
> xx = headerGet(h, he, 0);
> assert(he->p.str != NULL);
> @@ -690,7 +694,7 @@
> D_("%s: %s(%s) running <lua> scriptlet.\n"),
> psm->stepName, tag2sln(psm->scriptTag), NVRA);
> rc = runLuaScript(psm, h, sln, progArgc, progArgv,
> - script, arg1, arg2);
> + body, arg1, arg2);
> #endif
> goto exit;
> }
> @@ -773,10 +777,10 @@
> xx = Fwrite(set_x, sizeof(set_x[0]), sizeof(set_x)-1, fd);
> }
>
> - if (ldconfig_path && strstr(script, ldconfig_path) != NULL)
> + if (ldconfig_path && strstr(body, ldconfig_path) != NULL)
> ldconfig_done = 1;
>
> - xx = Fwrite(script, sizeof(script[0]), strlen(script), fd);
> + xx = Fwrite(body, sizeof(body[0]), strlen(body), fd);
> xx = Fclose(fd);
>
> { const char * sn = fn;
> @@ -965,6 +969,7 @@
> fn = _free(fn);
> }
>
> + body = _free(body);
> NVRA = _free(NVRA);
>
> return rc;
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/lib/rpmlib.h
>
> ======================================================================
> ======
> $ cvs diff -u -r2.455 -r2.456 rpmlib.h
> --- rpm/lib/rpmlib.h 4 Dec 2007 07:55:03 -0000 2.455
> +++ rpm/lib/rpmlib.h 6 Dec 2007 21:21:06 -0000 2.456
> @@ -160,6 +160,7 @@
> /** \ingroup rpmrc
> * Build and install arch/os table identifiers.
> * @deprecated Eliminate from API.
> + * @todo Eliminate in rpm-5.1.
> */
> enum rpm_machtable_e {
> RPM_MACHTABLE_INSTARCH = 0, /*!< Install platform
> architecture. */
> @@ -212,7 +213,7 @@
>
> /** \ingroup rpmrc
> * @deprecated Use addMacro to set _target_* macros.
> - * @todo Eliminate from API.
> + * @todo Eliminate in rpm-5.1.
> # @note Only used by build code.
> * @param archTable
> * @param osTable
> @@ -222,6 +223,7 @@
> /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
>
> /** \ingroup rpmrc
> + * @todo Eliminate in rpm-5.1.
> * Destroy rpmrc arch/os compatibility tables.
> * @todo Eliminate from API.
> */
> @@ -250,6 +252,7 @@
> /**
> * Compare headers to determine which header is "newer".
> * @deprecated Use rpmdsCompare instead.
> + * @todo Eliminate in rpm-5.1.
> * @param first 1st header
> * @param second 2nd header
> * @return result of comparison
> @@ -288,6 +291,8 @@
>
> /**
> * Install source package.
> + * @deprecated This routine needs to DIE! DIE! DIE!.
> + * @todo Eliminate in rpm-5.1, insturment rpmtsRun() state
> machine instead.
> * @param ts transaction set
> * @param _fd file handle
> * @retval specFilePtr address of spec file name (or NULL)
> @@ .
> ______________________________________________________________________
> RPM Package Manager http://rpm5.org
> CVS Sources Repository rpm-cvs@rpm5.org
Received on Thu Dec 6 22:28:50 2007