<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML ><HEAD ><TITLE >Of Pre- and Post-installation scripts</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.64 "><LINK REL="HOME" TITLE="Mandrake RPM HOWTO v1.1" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Advanced" HREF="advanced.html"><LINK REL="NEXT" TITLE="Dealing with upgrades" HREF="upgrade.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="mdk-rpm.css"></HEAD ><BODY CLASS="APPENDIX" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Mandrake RPM HOWTO v1.1</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="advanced.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="upgrade.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="APPENDIX" ><H1 CLASS="APPENDIX" ><A NAME="SCRIPTS" >A. Of Pre- and Post-installation scripts</A ></H1 ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN892" >A.1. Basics</A ></H1 ><P >The <SPAN CLASS="ACRONYM" >RPM</SPAN > package is in fact a bit more than a simple archive containing files to be expanded in specific directories of the host client system.</P ><P >The system offers to the programmer a great feature: pre- and post-installation scripts. They allow the packager to write a piece of code which will be executed on the client machine while installing or erasing the package.</P ><P >These scripts are made of any <B CLASS="COMMAND" >sh</B > valid command. There are four of them:</P ><P >There are certain caveats about these scripts which you should take into account. Number one, each must fit inside a 8192 buffer, and number two, they should be non-interactive. Anything which requires manual input from the user is wrong, as this will break non-interactive RPM installation procedures.</P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="LITERAL" >%pre</TT ></DT ><DD ><P >This script is executed just <I CLASS="EMPHASIS" >before</I > the package is <I CLASS="EMPHASIS" >installed</I > on the system.</P ></DD ><DT ><TT CLASS="LITERAL" >%post</TT ></DT ><DD ><P >This script is executed just <I CLASS="EMPHASIS" >after</I > the package is <I CLASS="EMPHASIS" >installed</I > on the system.</P ></DD ><DT ><TT CLASS="LITERAL" >%preun</TT ></DT ><DD ><P >This script is executed just <I CLASS="EMPHASIS" >before</I > the package is <I CLASS="EMPHASIS" >uninstalled</I > from the system.</P ></DD ><DT ><TT CLASS="LITERAL" >%postun</TT ></DT ><DD ><P >This script is executed just <I CLASS="EMPHASIS" >after</I > the package is <I CLASS="EMPHASIS" >uninstalled</I > on the system.</P ></DD ></DL ></DIV ><P >The scope of such scripts may be very large, and they have to be designed with much care not to harm the host system. One have to remember that these scripts will be run as root... They correspond to the tasks a system administrator would have to accomplish when installing a new program on a system. For example:</P ><P ></P ><UL ><LI STYLE="list-style-type: opencircle" ><P >Add a cron job running the program at fixed inervals</P ></LI ><LI STYLE="list-style-type: opencircle" ><P >Run chkconfig to run the daemon at boot time</P ></LI ><LI STYLE="list-style-type: opencircle" ><P >...</P ></LI ></UL ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="advanced.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="upgrade.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Advanced</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Dealing with upgrades</TD ></TR ></TABLE ></DIV ></BODY ></HTML >