Containerized environment template for building Rocky Linux 9 RPM packages from source code. This project provides a reusable template for packaging any source distribution.
Sources are packaged in subdirectories.
rocky_pkg/
├── Containerfile # Base Rocky Linux 9 build environment
├── <package_name>/
│ ├── Containerfile.<package_name> # Package-specific dependencies
│ ├── Makefile # Build automation
│ ├── <package_name>.spec # RPM spec file
│ └── <source_tarball> # Source distribution
Create a directory for your package. You may use the files used to package
pnetcdf as a template:
mkdir <package_name>
cp pnetcdf/Makefile <package_name>/
cp pnetcdf/Containerfile.pnetcdf <package_name>/Containerfile.<package_name>- Build the base image:
podman build -t rocky-pkg-builder .- Build package-specific image:
cd <package_name>
make image PACKAGE_NAME=<package_name>- Download source (if needed):
make source- Run interactive container:
make interactive- Build RPM (inside container):
make build- Copy RPMs to host:
make copy-rpms- Update package dependencies
- Install build tools specific to your package
- Configure environment variables
- Create RPM spec file defining build process
- Set dependencies, file lists, and metadata
- Configure post-install scripts if needed
- Update source download URLs
- Modify build targets as needed
Install built RPMs:
sudo dnf install <package_name>/RPMS/<package_name>-*.rpm- Base image: Rocky Linux 9 with development tools
- Builder user: Non-privileged build environment
- Volume mounting: Host directory mounted as
/home/builder/artifacts - Artifact extraction: RPMs copied to host via
make copy-rpms
The pnetcdf/ directory serves as a complete example implementation
demonstrating:
- MPI library integration (OpenMPI 4.1.1)
- Environment module configuration
- Fortran and C++ bindings
- Complex dependency management
This project builds the following RPM packages:
- pnetcdf/
pnetcdfpnetcdf-devel
- petsc-openmpi/
petscpetsc-develpetsc-docpetsc-openmpipetsc-openmpi-devel
- Podman or Docker
- Rocky Linux 9 host (recommended)