diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e25a9eb..a51f93d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: - '**.md' - 'man/**' - 'debian/**' + - 'rpm/**' - 'renovate.json' - 'LICENSE' - '.gitignore' @@ -18,6 +19,7 @@ on: - '**.md' - 'man/**' - 'debian/**' + - 'rpm/**' - 'renovate.json' - 'LICENSE' - '.gitignore' diff --git a/rpm/README.md b/rpm/README.md new file mode 100644 index 0000000..0984e9c --- /dev/null +++ b/rpm/README.md @@ -0,0 +1,236 @@ +# RPM Packaging for libcuid2 + +This directory contains the RPM spec file for building libcuid2 packages on Red Hat-based distributions. + +## Supported Distributions + +- **RHEL 9** and derivatives (Rocky Linux 9, AlmaLinux 9, Oracle Linux 9) +- **RHEL 8** and derivatives (Rocky Linux 8, AlmaLinux 8, Oracle Linux 8) +- **CentOS Stream 8/9** +- **Fedora** (current supported versions) + +## Package Structure + +The spec file produces three packages: + +| Package | Description | +|---------|-------------| +| `libcuid2` | Shared library (`libcuid2.so.0`) | +| `libcuid2-devel` | Development files (headers, CMake config, man pages) | +| `cuid2gen` | Command-line tool for generating identifiers | + +## Prerequisites + +### Fedora + +```bash +sudo dnf install rpm-build rpmdevtools gcc-c++ cmake \ + openssl-devel boost-devel fmt-devel +``` + +### RHEL 9 / Rocky Linux 9 / AlmaLinux 9 + +```bash +sudo dnf install rpm-build rpmdevtools gcc-c++ cmake \ + openssl-devel boost-devel fmt-devel + +# Enable EPEL for additional dependencies if needed +sudo dnf install epel-release +``` + +### RHEL 8 / Rocky Linux 8 / AlmaLinux 8 + +RHEL 8 requires GCC Toolset for C++20 support: + +```bash +# Enable EPEL for OpenSSL 3.x and fmt +sudo dnf install epel-release + +# Install build dependencies +sudo dnf install gcc-toolset-12-gcc-c++ cmake3 \ + rpm-build rpmdevtools openssl3-devel boost-devel fmt-devel + +# Enable GCC Toolset before building +source /opt/rh/gcc-toolset-12/enable +``` + +## Building RPM Packages + +### Method 1: Using rpmbuild (Standard) + +```bash +# Set up RPM build environment +rpmdev-setuptree + +# Copy spec file +cp libcuid2.spec ~/rpmbuild/SPECS/ + +# Download or create source tarball +# Option A: Download from GitHub (when released) +spectool -g -R ~/rpmbuild/SPECS/libcuid2.spec + +# Option B: Create tarball from local source +cd /path/to/libcuid2 +git archive --format=tar.gz --prefix=libcuid2-1.0.1/ \ + -o ~/rpmbuild/SOURCES/libcuid2-1.0.1.tar.gz HEAD + +# Build packages +rpmbuild -ba ~/rpmbuild/SPECS/libcuid2.spec + +# Built packages will be in: +# ~/rpmbuild/RPMS//libcuid2-1.0.1-1...rpm +# ~/rpmbuild/RPMS//libcuid2-devel-1.0.1-1...rpm +# ~/rpmbuild/RPMS//cuid2gen-1.0.1-1...rpm +# ~/rpmbuild/SRPMS/libcuid2-1.0.1-1..src.rpm +``` + +### Method 2: Using mock (Clean Build Environment) + +Mock builds packages in a clean chroot, ensuring reproducibility: + +```bash +# Install mock +sudo dnf install mock + +# Add user to mock group +sudo usermod -a -G mock $USER +newgrp mock + +# Create source RPM first +rpmbuild -bs ~/rpmbuild/SPECS/libcuid2.spec + +# Build for specific target (e.g., Fedora 41) +mock -r fedora-41-x86_64 ~/rpmbuild/SRPMS/libcuid2-1.0.1-1.fc41.src.rpm + +# Build for RHEL 9 +mock -r rocky-9-x86_64 ~/rpmbuild/SRPMS/libcuid2-1.0.1-1.el9.src.rpm + +# Build for RHEL 8 +mock -r rocky-8-x86_64 ~/rpmbuild/SRPMS/libcuid2-1.0.1-1.el8.src.rpm +``` + +### Method 3: Using Copr (Cloud Build Service) + +For automated builds across multiple distributions: + +```bash +# Install copr-cli +sudo dnf install copr-cli + +# Create a Copr project (one-time setup) +copr-cli create libcuid2 --chroot fedora-41-x86_64 \ + --chroot fedora-40-x86_64 --chroot epel-9-x86_64 --chroot epel-8-x86_64 + +# Upload source RPM +copr-cli build libcuid2 ~/rpmbuild/SRPMS/libcuid2-1.0.1-1.*.src.rpm +``` + +## Installing Built Packages + +```bash +# Install runtime library +sudo dnf install ./libcuid2-1.0.1-1.*.rpm + +# Install CLI tool +sudo dnf install ./cuid2gen-1.0.1-1.*.rpm + +# Install development files +sudo dnf install ./libcuid2-devel-1.0.1-1.*.rpm +``` + +## Verification + +After installation, verify the packages: + +```bash +# Test CLI tool +cuid2gen +cuid2gen --length 16 + +# View man pages +man cuid2gen +man 3 libcuid2 +man 7 libcuid2 + +# Check library +ldconfig -p | grep cuid2 + +# Compile a test program +cat > test_cuid2.cpp << 'EOF' +#include +#include + +int main() { + std::cout << cuid2::generate() << std::endl; + return 0; +} +EOF + +g++ -std=c++20 test_cuid2.cpp -lcuid2 -o test_cuid2 +./test_cuid2 +``` + +## Package Dependencies + +### Runtime Dependencies + +| Package | libcuid2 | cuid2gen | +|---------|----------|----------| +| openssl-libs >= 3.0 | Yes | (via libcuid2) | +| libstdc++ | Yes | Yes | + +### Development Dependencies + +| Package | Required For | +|---------|--------------| +| openssl-devel >= 3.0 | Linking | +| boost-devel >= 1.74 | Header-only components | + +## Distribution-Specific Notes + +### RHEL 8 / CentOS Stream 8 + +- **C++20 Support**: Requires GCC Toolset 12 (`gcc-toolset-12-gcc-c++`) +- **CMake**: Use `cmake3` package (cmake in RHEL 8 is version 3.20) +- **OpenSSL 3.x**: Available via EPEL (`openssl3-devel`) +- **fmt**: Available via EPEL (`fmt-devel`) + +### RHEL 9 / CentOS Stream 9 + +- Ships with GCC 11 (full C++20 support) +- CMake 3.26+ available +- OpenSSL 3.0 included in base repositories + +### Fedora + +- Latest GCC and CMake versions +- All dependencies available in base repositories + +## Troubleshooting + +### CMake version too old + +```bash +# RHEL 8: Use cmake3 +sudo dnf install cmake3 +# Spec file handles this automatically +``` + +### GCC doesn't support C++20 + +```bash +# RHEL 8: Enable GCC Toolset +source /opt/rh/gcc-toolset-12/enable +``` + +### Missing fmt-devel + +```bash +# Enable EPEL repository +sudo dnf install epel-release +sudo dnf install fmt-devel +``` + +## License + +MIT License - see LICENSE file in the project root. diff --git a/rpm/libcuid2.spec b/rpm/libcuid2.spec new file mode 100644 index 0000000..7ba974d --- /dev/null +++ b/rpm/libcuid2.spec @@ -0,0 +1,159 @@ +# ============================================================================== +# libcuid2 RPM Spec File +# ============================================================================== + +%global soversion 0 + +Name: libcuid2 +Version: 1.0.1 +Release: 1%{?dist} +Summary: Collision-resistant unique identifier generation library + +License: MIT +URL: https://github.com/visus-io/libcuid2 +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz + +# Common build requirements +BuildRequires: boost-devel >= 1.74 +BuildRequires: fmt-devel >= 8.1 + +# RHEL 8 specific build requirements (requires EPEL) +%if 0%{?rhel} == 8 +BuildRequires: cmake3 >= 3.22 +BuildRequires: gcc-toolset-12-gcc-c++ +BuildRequires: openssl3-devel +%else +# RHEL 9+, Fedora, CentOS Stream 9+ +BuildRequires: cmake >= 3.22 +BuildRequires: gcc-c++ >= 11 +BuildRequires: openssl-devel >= 3.0 +%endif + +%description +libcuid2 is a C++ implementation of Cuid2, providing secure, collision-resistant, +URL-safe, and sortable unique identifiers. + +Features: + * Collision-resistant using cryptographic primitives (SHA3-512) + * Sortable by timestamp for chronological ordering + * URL-safe base-36 encoding + * Thread-safe concurrent generation + * Configurable length (4-32 characters, default 24) + +# ============================================================================== +# Main Package: libcuid2 (shared library) +# ============================================================================== +# Runtime dependency: OpenSSL 3.x (different package name on RHEL 8) +%if 0%{?rhel} == 8 +Requires: openssl3-libs +%else +Requires: openssl-libs >= 3.0 +%endif + +# ============================================================================== +# Subpackage: libcuid2-devel (development files) +# ============================================================================== +%package devel +Summary: Development files for libcuid2 +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: boost-devel >= 1.74 +%if 0%{?rhel} == 8 +Requires: openssl3-devel +%else +Requires: openssl-devel >= 3.0 +%endif + +%description devel +libcuid2 is a C++ implementation of Cuid2, providing secure, collision-resistant, +URL-safe, and sortable unique identifiers. + +This package contains the development files including headers, CMake +configuration files, and manual pages for library functions. + +# ============================================================================== +# Subpackage: cuid2gen (CLI tool) +# ============================================================================== +%package -n cuid2gen +Summary: Command-line tool for generating Cuid2 identifiers +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description -n cuid2gen +cuid2gen is a command-line utility for generating Cuid2 identifiers. + +Cuid2 identifiers are collision-resistant, sortable, URL-safe unique +identifiers suitable for distributed systems, databases, and web applications. + +This package contains the command-line executable and user manual. + +# ============================================================================== +# Build +# ============================================================================== +%prep +%autosetup -n %{name}-%{version} + +%build +%if 0%{?rhel} == 8 +# Enable GCC Toolset 12 for C++20 support on RHEL 8 +source /opt/rh/gcc-toolset-12/enable +# Use cmake3 macro on RHEL 8 +%cmake3 \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TESTS=ON +%cmake3_build +%else +%cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TESTS=ON +%cmake_build +%endif + +%check +%if 0%{?rhel} == 8 +%ctest3 +%else +%ctest +%endif + +%install +%if 0%{?rhel} == 8 +%cmake3_install +%else +%cmake_install +%endif + +# ============================================================================== +# Scriptlets +# ============================================================================== +%ldconfig_scriptlets + +# ============================================================================== +# Files +# ============================================================================== +%files +%license LICENSE +%doc README.md +%{_libdir}/libcuid2.so.%{soversion} +%{_libdir}/libcuid2.so.%{version} + +%files devel +%{_includedir}/cuid2/ +%{_libdir}/libcuid2.so +%{_libdir}/cmake/cuid2/ +%{_mandir}/man3/libcuid2.3* +%{_mandir}/man7/libcuid2.7* + +%files -n cuid2gen +%{_bindir}/cuid2gen +%{_mandir}/man1/cuid2gen.1* + +# ============================================================================== +# Changelog +# ============================================================================== +%changelog +* Wed Jan 15 2026 Visus Development Team - 1.0.1-1 +- New upstream release 1.0.1 +- C++ implementation of Cuid2 identifier generation +- Thread-safe collision-resistant unique identifiers +- SHA3-512 cryptographic hashing (NIST FIPS-202) +- Configurable length (4-32 characters, default 24) +- Cross-platform support (Linux, BSD, macOS, Windows)