Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit ae1436e

Browse files
authored
RPM Build script && Use host glibmm (#96)
* Add script to build rpms * Fix debug build * Link against host Glibmm using pkg-config * Extract glibmm from diskImage, move it to files.cpp --------- Co-authored-by: Daniel Hilst <daniel@versatushpc.com.br>
1 parent 9e9a860 commit ae1436e

14 files changed

Lines changed: 170 additions & 65 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 3.26.5)
66
# so that it works well with tools like CPM or other
77
# manual dependency management
88

9+
# Load PkgConfig so we can use pkg_check_modules later
10+
# to find local packages.
11+
find_package(PkgConfig REQUIRED)
12+
913
# Only set the cxx_standard if it is not set by someone else
1014
if (NOT DEFINED CMAKE_CXX_STANDARD)
1115
set(CMAKE_CXX_STANDARD 23)

Dependencies.cmake

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ function(cloysterhpc_setup_dependencies)
8686
endif()
8787
endif()
8888

89-
if(NOT TARGET glibmm::glibmm)
90-
if (cloysterhpc_ENABLE_CONAN)
91-
CPMFindPackage(NAME glibmm)
92-
else()
93-
CPMAddPackage("gh:GNOME/glibmm@2.78.1")
94-
endif()
95-
endif()
96-
9789
if(NOT TARGET SDBusCpp::sdbus-c++)
9890
if (cloysterhpc_ENABLE_CONAN)
9991
CPMFindPackage(NAME sdbus-c++)
@@ -123,13 +115,29 @@ function(cloysterhpc_setup_dependencies)
123115
endif()
124116

125117
# Standalone packages
118+
include(FindPackageHandleStandardArgs)
119+
126120
# Include module path for packages that we need to find or build
127121
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
128122
include(cmake/Findnewt.cmake)
129123
if(NOT TARGET newt)
130124
CPMFindPackage(NAME newt)
131125
endif()
132126

127+
if(NOT TARGET glibmm)
128+
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4)
129+
130+
message(STATUS "GLIBMM_LIBRARIES=${GLIBMM_LIBRARIES}")
131+
message(STATUS "GLIBMM_INCLUDE_DIRS=${GLIBMM_INCLUDE_DIRS}")
132+
find_package_handle_standard_args(glibmm
133+
DEFAULT_MSG
134+
GLIBMM_LIBRARIES
135+
GLIBMM_INCLUDE_DIRS)
136+
137+
mark_as_advanced(GLIBMM_INCLUDE_DIRS GLIBMM_LIBRARIES)
138+
# include_directories(${GLIBMM_INCLUDE_DIRS})
139+
endif()
140+
133141
# Set the variable ${STDC++FS} to the correct library
134142
include(cmake/Addstdcppfs.cmake)
135143

buildrpm.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash -eu
2+
3+
function check_build_distro() {
4+
local SUPPORTED_BUILD_DISTS=(rocky)
5+
local ID=$(awk -F= '/^ID=/ { gsub("\"" , "", $2); print $2}' /etc/os-release)
6+
case "${SUPPORTED_BUILD_DISTS[*]}" in
7+
"${ID}")
8+
;;
9+
*)
10+
echo "Build RPM Environment not supported, you need to run this" \
11+
"in one of these distros: ${SUPPORTED_BUILD_DISTS}"
12+
exit -1
13+
;;
14+
esac
15+
}
16+
17+
function check_rpmbuild_installed() {
18+
if ! rpm -q rpmdevtools; then
19+
sudo dnf -y install rpmdevtools;
20+
rpmdev-setuptree;
21+
fi
22+
}
23+
24+
function check_rpmbuild_init() {
25+
if [ ! -d ~/rpmbuild/SOURCES ]; then
26+
rpmdev-setuptree
27+
fi
28+
}
29+
30+
check_build_distro
31+
check_rpmbuild_installed
32+
check_rpmbuild_init
33+
34+
VERSION=$(awk '/Version:/ {print $2}' rpmspecs/opencattus.spec)
35+
cp rpmspecs/opencattus.spec ~/rpmbuild/SPECS/
36+
git archive -o ~/rpmbuild/SOURCES/opencattus-${VERSION}.tar.gz \
37+
--format tgz HEAD --prefix opencattus-${VERSION}/
38+
rpmbuild -ba ~/rpmbuild/SPECS/opencattus.spec
39+
echo "RPM Generated"
40+
ls -l ~/rpmbuild/RPMS/*/opencattus-installer*.rpm

cmake/CommonLibraries.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set(COMMON_LIBS
99
Boost::thread
1010
spdlog::spdlog
1111
gsl::gsl-lite
12-
glibmm::glibmm
12+
${GLIBMM_LIBRARIES}
1313
magic_enum::magic_enum
1414
SimpleIni::SimpleIni
1515
resolv

conanfile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
class MyProjectConan(ConanFile):
55
name = "CloysterHPC"
66
version = "0.1.1"
7-
87
settings = "os", "arch", "compiler", "build_type"
98

109
def requirements(self):
@@ -16,7 +15,9 @@ def requirements(self):
1615
self.requires("gsl-lite/[>=0.41.0 <0.42.0]")
1716
self.requires("doctest/[>=2.4.0 <2.5.0]")
1817
self.requires("sdbus-cpp/[>=2.0.0 <2.1.0]")
19-
self.requires("glibmm/[>=2.78.1 <2.79.0]")
18+
19+
# We're using host's glibmm
20+
# self.requires("glibmm/[>=2.78.1 <2.79.0]")
2021

2122
# Override libmount to unify on 2.39.2.
2223
# This prevents the conflict with glib and sdbus-cpp requirements.

include/cloysterhpc/functions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
#include <boost/process/child.hpp>
66
#include <boost/process/pipe.hpp>
77
#include <cloysterhpc/services/repos.h>
8-
#include <concepts>
98
#include <filesystem>
10-
#include <glibmm/ustring.h>
119
#include <list>
1210
#include <optional>
13-
#include <ranges>
1411
#include <string>
1512

1613
#include <boost/asio.hpp>

include/cloysterhpc/services/files.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ static_assert(cloyster::concepts::IsSaveable<KeyFile>);
9191
static_assert(concepts::IsMoveable<KeyFile>);
9292
static_assert(!concepts::IsCopyable<KeyFile>);
9393

94+
95+
std::string checksum(const std::string& data);
96+
std::string checksum(const std::filesystem::path& path, const std::size_t chunkSize = 16384);
97+
9498
};
9599

96100
#endif

rpmspecs/opencattus.spec

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Name: opencattus-installer
2+
Version: 1.0
3+
Release: 1
4+
Summary: OpenCATTUS Installer
5+
License: Apache 2.0
6+
URL: https://versatushpc.com.br/opencattus/
7+
Source0: opencattus-%{VERSION}.tar.gz
8+
BuildRequires: make,cmake,cppcheck,ninja-build,newt-devel,gcc-toolset-14,gcc-toolset-14-libubsan-devel,gcc-toolset-14-libasan-devel
9+
Requires: newt
10+
11+
# Disable debug package for now
12+
%global _enable_debug_package 0
13+
%global debug_package %{nil}
14+
15+
%description
16+
Use OpenCATTUS installer to setup a HPC cluster from scratch.
17+
18+
%prep
19+
echo "PREP: $PWD"
20+
%autosetup -n opencattus-%{VERSION}
21+
bash -c '
22+
source rhel-gcc-toolset-14.sh;
23+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
24+
'
25+
26+
%build
27+
echo "BUILD: $PWD"
28+
cmake --build build
29+
30+
%install
31+
echo "INSTALL: $PWD"
32+
mkdir -p %{buildroot}/usr/bin
33+
install -m 755 build/src/cloysterhpc %{buildroot}/usr/bin/cloysterhpc
34+
35+
%files
36+
/usr/bin/cloysterhpc
37+
38+
%changelog
39+
* Tue Feb 25 2025 Daniel Hilst <danielhilst@versatushpc.com> - 1.0-1
40+
- Initial release

setupDevEnvironment.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ case "$os_version" in
123123
;;
124124
9)
125125
dnf -y install python pip libasan libubsan gcc-toolset-14 \
126-
gcc-toolset-14-libubsan-devel gcc-toolset-14-libasan-devel cppcheck
126+
gcc-toolset-14-libubsan-devel gcc-toolset-14-libasan-devel cppcheck \
127+
glibmm24 glibmm24-devel
127128
;;
128129
10)
129-
dnf -y install python pip libubsan libasan liblsan libtsan libhwasan
130+
dnf -y install python pip libubsan libasan liblsan libtsan libhwasan \
131+
glibmm-2.68 glibmm-2.68-devel
130132
;;
131133
esac
132134

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ target_link_system_libraries(
2121

2222
# Build a library and a ${cloysterhpc_BINARY_NAME} binary that links to the library
2323
add_library(cloysterhpc_object OBJECT ${SOURCE_FILES})
24+
25+
# Include glibmm headers as SYSTEM header to avoid warnings
26+
target_include_directories(cloysterhpc_object SYSTEM PRIVATE ${GLIBMM_INCLUDE_DIRS})
27+
2428
# add_library(cloysterhpc_static STATIC $<TARGET_OBJECTS:cloysterhpc_object>)
2529
add_library(cloysterhpc_static STATIC $<TARGET_OBJECTS:cloysterhpc_object> $<TARGET_OBJECTS:cloysterhpc_presenter_object>)
2630
add_executable(${cloysterhpc_BINARY_NAME} main.cpp)

0 commit comments

Comments
 (0)