| 126 | === CONFIG.SYS changes === |
| 127 | It is sometimes necessary to modify the CONFIG.SYS file during installation, even when using RPM. One of the examples is when your package installs a device driver that needs to be loaded at boot time or when a global environment variable needs to be set. This can be done from the {{{%post}}} section using the special macro {{{%cube}}} which is based on the CUBE tool. |
| 128 | |
| 129 | For example, this snippet will add a DEVICE= line to CONFIG.SYS after the first DEVICE= line (or to the bottom if there are no DEVICE= statements), add an environment variable (using the same logic) and back up the old CONFIG.SYS file as CONFIG.SYS.YUM. Note that the backup file name is only specified in the __first__ {{{%cube}}} statement since you only need to create the backup file __once__ -- before you start any modifications. |
| 130 | {{{ |
| 131 | %post |
| 132 | %cube {ADDLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys" (AFTER "DEVICE="} %{os2_config_sys} %{os2_config_sys}.yum >nul |
| 133 | %cube {ADDLINE "SET MYENVVAR=myvalue" (AFTER "SET "} %{os2_config_sys} >nul |
| 134 | echo; echo "NOTE:" |
| 135 | echo; echo "The file '%{os2_config_sys}' has been changed. You need to reboot your" |
| 136 | echo "computer in order to activate these changes." |
| 137 | echo |
| 138 | }}} |
| 139 | |
| 140 | Here is the corresponding uninstallation snippet that will undo changes made by the above code. You should always perform symmetric uninstallation steps to make sure that all changes your package does to CONFIG.SYS are rolled back when the package is uninstalled from the system. |
| 141 | {{{ |
| 142 | %postun |
| 143 | %cube {DELLINE "SET MYENVVAR="} %{os2_config_sys} >nul |
| 144 | %cube {DELLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys"} %{os2_config_sys} >nul |
| 145 | echo; echo "NOTE:" |
| 146 | echo; echo "The file '%{os2_config_sys}' has been changed. You need to reboot your" |
| 147 | echo "computer in order to activate these changes." |
| 148 | echo |
| 149 | }}} |
| 150 | |
| 151 | The complete CUBE documentation is available here: http://www3.sympatico.ca/gjarviseng/cube/cube.html |