Occasionally, it may be necessary to rebuild one of the supplied SRPMs. This is not a difficult operation, but it does rely on some features of rpm which may not be familiar to users who have only used this tool for installing binary RPMs.

Note: The procedures specified on this page are applicable to any STLinux distribution, which means that the rpm filename and path are generic. The instructions below use stlinux2x as a generic distribution name and STLinux-X.X as a generic installation root directory. These should be substituted, as applicable, for the correct names of the 2.2 or 2.3 distributions. Similarly, the version numbers of tools are specified in the generic form x.y-z.

All the macros needed for the build are specified in the stm-host-rpmconfig RPM. This is supplied with the distribution, but it is not installed by default so must be installed (as root) by:

host# rpm -ihv stlinux2x-host-rpmconfig-x.y-z.noarch.rpm

The rest of the process does not require root privileges, and does not modify the RPM database. It should be possible to work in the normal RPM build area, by removing the _topdir macro from localmacros. If for any reason, you do not want to do this you must cd to your working directory, and then create the build hierarchy:

host% mkdir -p SOURCES SPECS BUILD SRPMS RPMS/{noarch,i386,sh4}

There are options that must be given to rpm which can only be specified in configuration files. These control the root of the RPM build tree, and the location to search for macro definitions. Note that the localrc file contains just a single long line; the second command is shown here broken into a number of lines for clarity:

host% echo "%_topdir	$(pwd)" > localmacros
host% echo "macrofiles: /usr/lib/rpm/macros:
            /opt/STM/STLinux-X.X/config/rpm/hosts/i686-pc-linux-gnu:
            /opt/STM/STLinux-X.X/config/rpm/targets/sh4-linux:
            /opt/STM/STLinux-X.X/config/rpm/common:
            `pwd`/localmacros" > localrc

Next install the SRPM into this structure, for example:

host% rpm --rcfile localrc -Uhv stlinux2x-target-util-linux-x.y-z.src.rpm 

substituting the name of the required SRPM.

Note : Make sure that the PATH is correctly set. The directories /opt/STM/STLinux-2.X/host/bin and /opt/STM/STLinux-X.X/devkit/sh4/bin must be listed before all other directories.

You can set that with the following command:

host% export PATH=/opt/STM/STLinux-X.X/host/bin:/opt/STM/STLinux-X.X/devkit/sh4/bin:$PATH 

You need to export the TARGET_RPMARCH to sh4-22- [or sh4-23-] for generating packages with correct requires or provides prefix.

host% export TARGET_RPMARCH=sh4-23- 

Finally, build the package:

host% rpmbuild --rcfile /usr/lib/rpm/rpmrc:localrc -ba -v --target=sh4-linux SPECS/stm-target-util-linux.spec

If the package is a host or cross utility, rather than a target package, remove the --&nbrsp;target option.

Note : If, for any reason, you intend to modify the spec file, be aware that commenting out a line that includes is a macro invocation (starting with a % character) may not have the intended outcome. rpm may still interpret these lines as macros despite the fact that they are commented out, causing problems that can be hard to debug. STMicroelectronics strongly suggest making a backup copy of the orginal file and then deleting any lines that are no longer needed. The lines can be restored from the backup if they need to be replaced.