https://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&feed=atom&action=historyUser:Toshio/Writing scriptlets - Revision history2024-03-28T10:24:05ZRevision history for this page on the wikiMediaWiki 1.39.4https://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&diff=265507&oldid=prevToshio: close tag2012-01-04T17:32:40Z<p>close tag</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:32, 4 January 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l26">Line 26:</td>
<td colspan="2" class="diff-lineno">Line 26:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When writing the macros, the FPC will still want to review the macros (and perhaps include the implementation of the macros in the guideline to show packagers what's happening behind the scenes).</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When writing the macros, the FPC will still want to review the macros (and perhaps include the implementation of the macros in the guideline to show packagers what's happening behind the scenes).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>One principle that the FPC follows is that macros must not contain the start of scriptlet tags (for instance, <code>%pre</<del style="font-weight: bold; text-decoration: none;">pre</del>>). This also means that a single macro must not be defined to do things in both <code>%pre</code> and <code>%post</code>. Instead, write one macro that performs the actions in <code>%pre</code> and a separate macro that performs the actions in <code>%post</code>. This principle makes it so that all spec files can use your macros in the same manner even if they already have a <code>%pre</code> or <code>%post</code> defined.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>One principle that the FPC follows is that macros must not contain the start of scriptlet tags (for instance, <code>%pre</<ins style="font-weight: bold; text-decoration: none;">code</ins>>). This also means that a single macro must not be defined to do things in both <code>%pre</code> and <code>%post</code>. Instead, write one macro that performs the actions in <code>%pre</code> and a separate macro that performs the actions in <code>%post</code>. This principle makes it so that all spec files can use your macros in the same manner even if they already have a <code>%pre</code> or <code>%post</code> defined.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Packaging guidelines drafts]]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Packaging guidelines drafts]]</div></td></tr>
</table>Toshiohttps://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&diff=265506&oldid=prevToshio: Update macros section2012-01-04T17:31:47Z<p>Update macros section</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:31, 4 January 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l26">Line 26:</td>
<td colspan="2" class="diff-lineno">Line 26:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When writing the macros, the FPC will still want to review the macros (and perhaps include the implementation of the macros in the guideline to show packagers what's happening behind the scenes).</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When writing the macros, the FPC will still want to review the macros (and perhaps include the implementation of the macros in the guideline to show packagers what's happening behind the scenes).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>One principle that the FPC follows is that macros must not <del style="font-weight: bold; text-decoration: none;">cross </del>scriptlet <del style="font-weight: bold; text-decoration: none;">boundaries</del>. <del style="font-weight: bold; text-decoration: none;">For instance, </del>a single macro <del style="font-weight: bold; text-decoration: none;">should </del>not be defined to do things in both <code>%pre</code> and <code>%post</code>. Instead, write one macro that performs the actions in <code>%pre</code> and a separate macro that performs the actions in <code>%post</code>. This principle makes it so that all spec files can use your macros in the same manner even if they already have a <code>%pre</code> or <code>%post</code> defined.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>One principle that the FPC follows is that macros must not <ins style="font-weight: bold; text-decoration: none;">contain the start of </ins>scriptlet <ins style="font-weight: bold; text-decoration: none;">tags (for instance, <code>%pre</pre>)</ins>. <ins style="font-weight: bold; text-decoration: none;">This also means that </ins>a single macro <ins style="font-weight: bold; text-decoration: none;">must </ins>not be defined to do things in both <code>%pre</code> and <code>%post</code>. Instead, write one macro that performs the actions in <code>%pre</code> and a separate macro that performs the actions in <code>%post</code>. This principle makes it so that all spec files can use your macros in the same manner even if they already have a <code>%pre</code> or <code>%post</code> defined.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Packaging guidelines drafts]]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Packaging guidelines drafts]]</div></td></tr>
</table>Toshiohttps://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&diff=265505&oldid=prevToshio: s/rpm/rpm-state/2012-01-04T17:28:54Z<p>s/rpm/rpm-state/</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:28, 4 January 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l14">Line 14:</td>
<td colspan="2" class="diff-lineno">Line 14:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* If we only want the program in <code>%posttrans</code> to do its work once per-transaction, we may need to write out a flag file so that the <code>%posttrans</code> knows whether to perform an action.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* If we only want the program in <code>%posttrans</code> to do its work once per-transaction, we may need to write out a flag file so that the <code>%posttrans</code> knows whether to perform an action.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>To address these issues scriptlets that run earlier need to write out information that is used in <code>%posttrans</code>. We recommend using a subdirectory of <code>%{_localstatedir}/lib/rpm</code> for that. For instance, the eclipse plugin scripts touch a file in <code>%{_localstatedir}/lib/rpm/eclipse/</code> when they're installed. The <code>%posttrans</code> runs a script that checks if that file exists. If it does, it performs its action and then deletes the file. That way the script only performs its action once per transaction.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>To address these issues scriptlets that run earlier need to write out information that is used in <code>%posttrans</code>. We recommend using a subdirectory of <code>%{_localstatedir}/lib/rpm<ins style="font-weight: bold; text-decoration: none;">-state/</ins></code> for that. For instance, the eclipse plugin scripts touch a file in <code>%{_localstatedir}/lib/rpm<ins style="font-weight: bold; text-decoration: none;">-state</ins>/eclipse/</code> when they're installed. The <code>%posttrans</code> runs a script that checks if that file exists. If it does, it performs its action and then deletes the file. That way the script only performs its action once per transaction.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>{{admon/note||We're asking that the <code>%{_localstatedir}/lib/rpm</code> directory be owned by either the rpm or filesystem packages in Fedora. Until that happens, a package that is providing this functionality needs to own <code>%{_localstatedir}/lib/rpm</code> as well as their subdirectory of it.}}</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{admon/note||We're asking that the <code>%{_localstatedir}/lib/rpm<ins style="font-weight: bold; text-decoration: none;">-state/</ins></code> directory be owned by either the rpm or filesystem packages in Fedora. Until that happens, a package that is providing this functionality needs to own <code>%{_localstatedir}/lib/rpm<ins style="font-weight: bold; text-decoration: none;">-state/</ins></code> as well as their subdirectory of it.}}</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Macros ===</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Macros ===</div></td></tr>
</table>Toshiohttps://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&diff=264112&oldid=prevToshio: moved User:Toshio/Scriptlet postrans to User:Toshio/Writing scriptlets: section became more generic2011-12-21T18:22:23Z<p>moved <a href="/wiki/User:Toshio/Scriptlet_postrans" class="mw-redirect" title="User:Toshio/Scriptlet postrans">User:Toshio/Scriptlet postrans</a> to <a href="/wiki/User:Toshio/Writing_scriptlets" title="User:Toshio/Writing scriptlets">User:Toshio/Writing scriptlets</a>: section became more generic</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:22, 21 December 2011</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Toshiohttps://fedoraproject.org/w/index.php?title=User:Toshio/Writing_scriptlets&diff=264111&oldid=prevToshio: Tips for writing scriptlets2011-12-21T18:21:08Z<p>Tips for writing scriptlets</p>
<p><b>New page</b></p><div>{{draft| To be added to [[Packaging:ScriptletSnippets]]}}<br />
<br />
To be added to [[Packaging:ScriptletSnippets]] after the Syntax Ordering section.<br />
<br />
== Writing scriptlets ==<br />
<br />
Some tips for writing good scriptlets<br />
<br />
=== Saving state between scriptlets ===<br />
<br />
Sometimes a scriptlet needs to save some state from an earlier running scriptlet in order to use it at a later running scriptlet. This is especially common when trying to optimize the scriptlets. Examples:<br />
<br />
* If a <code>%posttrans</code> needs to de-register some piece of information when upgrading but the file that has that information is removed when the old package is removed the scriptlets need to save that file during <code>%pre</code> or <code>%post</code> so that the script in <code>%posttrans</code> can access it.<br />
* If we only want the program in <code>%posttrans</code> to do its work once per-transaction, we may need to write out a flag file so that the <code>%posttrans</code> knows whether to perform an action.<br />
<br />
To address these issues scriptlets that run earlier need to write out information that is used in <code>%posttrans</code>. We recommend using a subdirectory of <code>%{_localstatedir}/lib/rpm</code> for that. For instance, the eclipse plugin scripts touch a file in <code>%{_localstatedir}/lib/rpm/eclipse/</code> when they're installed. The <code>%posttrans</code> runs a script that checks if that file exists. If it does, it performs its action and then deletes the file. That way the script only performs its action once per transaction.<br />
<br />
{{admon/note||We're asking that the <code>%{_localstatedir}/lib/rpm</code> directory be owned by either the rpm or filesystem packages in Fedora. Until that happens, a package that is providing this functionality needs to own <code>%{_localstatedir}/lib/rpm</code> as well as their subdirectory of it.}}<br />
<br />
=== Macros ===<br />
Complex scriptlets may be placed in rpm macros. This has two benefits:<br />
<br />
# The standard package authors only have to remember the macros, not the complex stuff that it does<br />
# The macros' implementations may change without having to update the package<br />
<br />
When writing the macros, the FPC will still want to review the macros (and perhaps include the implementation of the macros in the guideline to show packagers what's happening behind the scenes).<br />
<br />
One principle that the FPC follows is that macros must not cross scriptlet boundaries. For instance, a single macro should not be defined to do things in both <code>%pre</code> and <code>%post</code>. Instead, write one macro that performs the actions in <code>%pre</code> and a separate macro that performs the actions in <code>%post</code>. This principle makes it so that all spec files can use your macros in the same manner even if they already have a <code>%pre</code> or <code>%post</code> defined.<br />
<br />
<br />
[[Category:Packaging guidelines drafts]]</div>Toshio