Rate This Document
Findability
Accuracy
Completeness
Readability

Generating a Compression Algorithm RPM Package

This document uses glz-1.0.0 as an example to describe how to generate a compression algorithm RPM package.

  1. Install rpmbuild.
    1
    2
    yum install rpmdevtools -y
    rpmdev-setuptree
    

    If you perform the compilation as the root user, an rpmbuild directory is generated in the /root directory. The compilation will occupy 20 GB to 30 GB. If the /root directory has a smaller space, you can move rpmbuild to another directory, for example, /home.

    1. Modify the .rpmmacros file after running the rpmbuild command.
      1. Open the /root/.rpmmacros file.
        1
        vi /root/.rpmmacros
        
      2. Press i to enter the insert mode and change %_topdir to /home/rpmbuild.
        Figure 1 Changing %_topdir to /home/rpmbuild
      3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
    2. Run the rpmbuild installation command again.
      1
      rpmdev-setuptree
      
  2. Copy the algorithm dynamic library.

    Copy the compression algorithm dynamic library to /home/rpmbuild/BUILD/.

    1
    2
    mkdir -p /home/rpmbuild/BUILD/glz-1.0.0
    cp /usr/lib64/libglz.so /home/rpmbuild/BUILD/glz-1.0.0/
    
  3. Edit the glz.spec file.
    1. Open the /home/rpmbuild/SPECS/glz.spec file.
      1
      vi /home/rpmbuild/SPECS/glz.spec
      
    2. Press i to enter the insert mode and edit the SPEC file as follows:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      # os_type
      %{!?os_type: %define os_type centos}
      
      Name: glz
      Version: 1.0.0
      Release: centos
      Summary: glz compress
      License: Commercial
      
      %description
      
      %install
      mkdir -p %{buildroot}/usr/lib64
      cp %{_builddir}/%{name}-%{version}/*.so %{buildroot}/usr/lib64/
      
      %files
      %{_libdir}/*.so
      
    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  4. Build an RPM package.
    1
    rpmbuild -bb /home/rpmbuild/SPECS/glz.spec
    

    The generated RPM package is stored in /home/rpmbuild/RPMS/aarch64/.