Using tsrpm

Both source (SRPM) and binary RPM packages can be manipulated with tsrpm. Reference Linux distributions from TimeSys, along with ready-to-install binary images, include the binary and source RPM packages that were used to build the installed images. Source RPM packages shipped with these distributions have been updated to be cross-build friendly, so they are appropriate for use with tsrpm. However, using tsrpm with source RPM packages from any other package repository, such as Fedora or OpenSuse, might require additional porting efforts.

It should be safe to use tsrpm with binary RPM packages built with RPM utilities that are compatible with Fedora Core/RedHat implementations of RPM utilities. Of course, non-x86 versions of binary RPM packages are not readily available. This is an issue that tsrpm was designed to address.

Since tsrpm is built on top of the RPM framework, some familiarity with RPM is assumed. If you have worked with RPM tools only as a casual user, it is highly recommended that you read the RPM tutorial located at http://www.rpm.org/max-rpm/index.html before attempting to use tsrpm.

Unpacking Source RPM Packages

The binary and source RPM packages need to be downloaded separately from the TimeSys LinuxLink web site, either individually from the Repository, or as a tarball from the Builder. Source RPM packages need to be unpacked before they can be used with tsrpm.

[juser@host SRPMS]tsrpm --extract zlib-1.2.1.1-2.1.src.rpm
Clearing directory /home/juser/SRPMS/rpm-sources/zlib-1.2.1.1-2.1
Extracting zlib-1.2.1.1-2.1.src.rpm to /home/juser/SRPMS/rpm-sources/zlib-1.2.1.1-2.1
Note

There are three modes of operation used in this guide:

  • Those commands you can run as an unprivileged user on the host, indicated by the use of juser@host
  • Those commands you need to run as a privileged user on the host, indicated by the use of root@host
  • Those commands you need to run as a privileged user on the target, indicated by the use of root@target

Building a Package with tsrpm

By default, tsrpm assumes that packages are stored in the rpm-sources subdirectory in the current working directory. If this is the case, you merely need to specify the package name to tsrpm, as shown in the following example:

[juser@host SRPMS] tsrpm --build --target=ppc7xx zlib

If packages are stored in a different location, enter the complete path to the RPM .spec file, as shown in the following example:

[juser@host ~] tsrpm --build --target=ppc7xx  \
  <path_to_zlib_sources>/zlib.spec</path_to_zlib_sources>

A tsrpm build produces several different RPM packages that are deposited in an architecture-specific location, which is relative to the current working directory, as shown in the following example. The source RPM package gets regenerated, and one or more binary RPM packages for the target are produced.

[juser@host SRPMS]$ tsrpm --build --target=ppc7xx zlib
tsrpm: ===== zlib-1.2.1.1-2.1 rpmbuild for ppc7xx hosted on ppc-linux starting \
  at 2005-08-13 09:49:34
 . . .
Wrote: /home/juser/ppc7xx/SRPMS/zlib-1.2.1.1-2.1.src.rpm
Wrote: /home/juser/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
Wrote: /home/juser/ppc7xx/RPMS/zlib-devel-1.2.1.1-2.1.ppc7xx.rpm
 . . .
tsrpm: ===== zlib-1.2.1.1-2.1 rpmbuild for ppc7xx hosted on ppc-linux ending with \
  status 0 at 2005-08-13 09:49:46 elapsed time 0:00:13\

Installing Target RPMS

Linux distributions produced by TimeSys include the RPM tools in the target RFS. The binary or source RPM packages can then be manipulated using standard RPM tools on the target. Thus, the zlib RPM generated in the previous example can be installed with the following command:

[root@target ~]$ rpm -i zlib-1.2.1.1-2.1.ppc7xx.rpm

On the target, all normal RPM commands can be used to detect package dependencies, and to install, upgrade, query, or remove packages.

Installing Target Packages on the Host

If the target is running an NFS-mounted root file system, the package can be installed directly on the host using tsrpm. It would be prudent to ensure that the target is not actually using the RFS during the installation. The following command line is an example.

[juser@host ~]tsrpm --dir /tmp/timesys--target=<arch> --install \
  --root=/opt/timesys/linux/6.1/<arch>-std/rfs  \ 
  <package_dir>/foo.<arch>.rpm

When installing on the host, tsrpm provides the flexibility of choosing the install root to facilitate the creation of a new RFS. However, packages should generally be installed in an install root only in the order of installation dependencies. Install dependencies of a target RPM can be queried on the host using the host RPM tools as shown in the following example:

[juser@host SRPMS]$ rpm -q --requires -p /home/juser/SRPMS/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.3)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Installing a dependent target RPM out of order will result in errors. For example, zlib is dependent on glibc, so installing a package out of order in a new RFS location can result in failed dependencies, as illustrated in the following example:

[juser@host SRPMS]$ tsrpm --install --target=ppc7xx \
  --root=/home/juser/myrfs /home/juser/SRPMS/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
*** finding rpms
  /home/juser/SRPMS/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
error: Failed dependencies:
        libc.so.6 is needed by zlib-1.2.1.1-2.1
        libc.so.6(GLIBC_2.0) is needed by zlib-1.2.1.1-2.1
        libc.so.6(GLIBC_2.1) is needed by zlib-1.2.1.1-2.1
        libc.so.6(GLIBC_2.1.3) is needed by zlib-1.2.1.1-2.1

Installation dependencies for a target package can be queried on the host by using normal RPM commands.

[juser@host SRPMS]$ for i in /home/juser/RPMS/target-glibc/*; 
> do  
>  rpm -q --provides -p $i | grep libc.so.6 > /dev/null && echo "libc.so.6 is provided by" $i; 
> done
libc.so.6 is provided by /home/juser /RPMS/target-glibc/glibc-2.3.3-36.ppc7xx.rpm

If you need to reinstall the same RPM or an older RPM version over an existing installation, you can forcibly install an RPM, as shown in the following example:

[root@host SRPMS]#  tsrpm --dir=/tmp/timesys--install --target=ppc7xx \
  --root=/opt/timesys/linux/6.1/ppc7xx-std/rfs --force \
  /home/juser/SRPMS/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
*** finding rpms
  /home/juser/SRPMS/ppc7xx/RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
+ rpm -Uvh --noorder --dbpath /opt/timesys/linux/6.1/ppc7xx-std/rpmdb 
      --define _dbpath /opt/timesys/linux/6.1/ppc7xx-std/rpmdb 
      --relocate=/=/opt/timesys/linux/6.1/ppc7xx-std/rfs --nosignature 
      --badreloc --ignorearch --ignoreos --force --nodeps /home/juser/SRPMS/ppc7xx/ \
      RPMS/zlib-1.2.1.1-2.1.ppc7xx.rpm
Preparing...                ########################################### [100%]
   1:zlib                   ########################################### [100%]
/opt/timesys/linux/6.1/ppc7xx/tools-host-linux/tsrpm/lib/rpm_install: 
*** Running /opt/timesys/linux/6.1/ppc7xx/tools-host-linux/tsrpm/lib/postinstall
-rwxr-xr-x    1 root     root          104 Aug 13 18:15 /opt/timesys/linux/6.1/ \
 ppc7xx-std/rfs/tsrpm/09alternatives

tsrpm’s --force option directly translates into the RPM option of the same name.