Changes between Version 64 and Version 65 of RpmHowToPackagers
- Timestamp:
- Nov 18, 2019, 4:14:50 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RpmHowToPackagers
v64 v65 502 502 Adding vendor and packagename is optional. In case they are not provided, they will be replaced with fixed values of wpi4rpm. 503 503 504 === Using macros at install time === 505 506 There is a group of OS/2-specific RPM macros that provide access to various aspects of the configuration of the OS/2 machine RPM is being run on. All these macros have names starting with `os2_`. 507 508 They are normal RPM macros and may be used wherever any other RPM macro does. There is, however, one important detail that should be taken into account when using OS/2-specific macros in `.spec` files — some of these macros depend on user-specific aspects of configuration. 509 510 A common case of such a dependency is the OS/2 boot drive letter. It may differ on a machine where the RPM package is being created and on a machine where it is later installed. The latter is up to the user and out of control of the RPM package creator. Normally all RPM macros are expanded at RPM creation time. For `.spec` sections that are run on the RPM creator's machine (such as `%prep`, `%build`, `%install`) it's not a problem as macro expansion happens at the same time the macro is used in the relevant section. However, for sections run on the user's machine at install time (`%post`, `%postun` etc) it is possible that the value of a macro expanded at package creation time will not match the value of the same macro when the package is later installed. Note that it may happen even if it's the same machine (e.g. the RPM creator changes its boot drive later). 511 512 A solution RPM provides to overcome this issue is secondary macro expansion. For this solution to work two prerequisites are necessary: a) the relevant `%post`, `%postun` or similar section must contain the `-e` option (to enable an extra expansion at install/uninstall time); b) the macro which is subject to secondary expansion should be prefixed with double `%` sign (to prevent it from being expanded at package creation time). 513 514 Here is the list of all OS/2-specific macros that depend on user-specific install-time configuration properties: 515 516 ||= **Macro** =||= **Dependency** =|| 517 ||os2_boot_drive||Refers to boot drive|| 518 ||os2_config_sys||Refers to `%{os2_boot_drive}`|| 519 ||os2_expand_unixroot||Refers to `%UNIXROOT%` env.var|| 520 ||os2_expand_dos_vars||Refers to `%UNIXROOT%` env.var|| 521 ||os2_unixroot_path||Refers to `%{os2_expand_unixroot}` 522 523 Also, all other macros which refer to one of the above macros in their definitions must be subject to double expansion. 524 525 A good example of how to use such macros is provided in the next section. 526 504 527 === CONFIG.SYS changes === 505 528 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. 506 529 507 530 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 similar logic). 508 {{{ 509 %post 510 %cube {ADDLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys" (AFTER "DEVICE="} %{os2_config_sys} >nul 511 %cube {ADDLINE "SET MYENVVAR=myvalue" (AFTER "SET "} %{os2_config_sys} >nul 531 532 **NOTE**: Using `%{os2_config_sys}` below requires secondary macro expansion. See the previous section for more info. 533 {{{ 534 %post -e 535 %cube {ADDLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys" (AFTER "DEVICE="} %%{os2_config_sys} >nul 536 %cube {ADDLINE "SET MYENVVAR=myvalue" (AFTER "SET "} %%{os2_config_sys} >nul 512 537 echo; echo "NOTE:" 513 echo; echo "The file '% {os2_config_sys}' has been changed. You need to reboot your"538 echo; echo "The file '%%{os2_config_sys}' has been changed. You need to reboot your" 514 539 echo "computer in order to activate these changes." 515 540 echo … … 518 543 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. 519 544 {{{ 520 %postun 521 %cube {DELLINE "SET MYENVVAR="} % {os2_config_sys} >nul522 %cube {DELLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys"} % {os2_config_sys} >nul545 %postun -e 546 %cube {DELLINE "SET MYENVVAR="} %%{os2_config_sys} >nul 547 %cube {DELLINE "DEVICE=%UNIXROOT%\usr\%{_lib}\mydrv.sys"} %%{os2_config_sys} >nul 523 548 echo; echo "NOTE:" 524 echo; echo "The file '% {os2_config_sys}' has been changed. You need to reboot your"549 echo; echo "The file '%%{os2_config_sys}' has been changed. You need to reboot your" 525 550 echo "computer in order to activate these changes." 526 551 echo