1
0
mirror of synced 2024-11-12 02:00:52 +01:00

build: Fix CI for Fedora, added caching, various other fixes (#613)

* Ci: use matrix for Fedora

* Ci: use ccache in Fedora build

* Ci: cache CMakeCache for Fedora

* build type release fedora

* Rawhide with lowercase

* strip binaries on Linux

* strip files for CPack (didn't test)

* add soversion to libimhex on Linux and MacOS

* fixed that typo
This commit is contained in:
iTrooz_ 2022-07-31 17:29:57 +02:00 committed by GitHub
parent 43988b8a7e
commit df94370598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 75 deletions

View File

@ -366,7 +366,7 @@ jobs:
sudo -u nobody makepkg sudo -u nobody makepkg
# Remplace the old file # Replace the old file
rm imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst rm imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst
mv *.pkg.tar.zst imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst mv *.pkg.tar.zst imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst
@ -377,12 +377,21 @@ jobs:
path: | path: |
build/imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst build/imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst
fedora-build-rawhide: fedora-build:
name: 🐧 Fedora Rawhide strategy:
matrix:
include:
- docker_image: fedora:latest
release: Latest
- docker_image: fedora:rawhide
release: Rawhide
name: 🐧 Fedora ${{ matrix.release }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: fedora:rawhide image: "${{ matrix.docker_image }}"
steps: steps:
- name: ⬇️ Update all packages - name: ⬇️ Update all packages
@ -392,7 +401,6 @@ jobs:
- name: ⬇️ Install setup dependencies - name: ⬇️ Install setup dependencies
run: | run: |
dnf install -y \ dnf install -y \
capstone-devel \
ccache \ ccache \
desktop-file-utils \ desktop-file-utils \
fmt-devel \ fmt-devel \
@ -401,7 +409,6 @@ jobs:
libcurl-devel \ libcurl-devel \
llvm-devel \ llvm-devel \
mbedtls-devel \ mbedtls-devel \
mock \
python3-devel \ python3-devel \
rpm-build \ rpm-build \
yara-devel yara-devel
@ -420,15 +427,15 @@ jobs:
with: with:
path: | path: |
~/.cache/ccache ~/.cache/ccache
key: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }} key: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }}
restore-keys: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build restore-keys: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build
- name: 📜 Restore CMakeCache - name: 📜 Restore CMakeCache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: | path: |
build/CMakeCache.txt ~/rpmbuild/BUILDROOT/CMakeCache.txt
key: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }} key: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }}
- name: 📜 Set version variable - name: 📜 Set version variable
run: | run: |
@ -436,70 +443,11 @@ jobs:
- name: 📦 Build RPM - name: 📦 Build RPM
run: | run: |
rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" --define "_build_type $BUILD_TYPE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec
- name: ⬆️ Upload RPM - name: ⬆️ Upload RPM
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: Fedora Rawhide RPM name: Fedora ${{ matrix.release }} RPM
path: |
~/rpmbuild/RPMS/*/*.rpm
fedora-build-stable:
name: 🐧 Fedora Stable
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: ⬇️ Update all packages
run: |
dnf upgrade -y
- name: ⬇️ Install setup dependencies
run: |
dnf install -y \
ccache \
desktop-file-utils \
fmt-devel \
git \
json-devel \
libcurl-devel \
llvm-devel \
mbedtls-devel \
python3-devel \
rpm-build
- name: 🧰 Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: ⬇️ Install ImHex dependencies
run: |
dist/get_deps_fedora.sh
- name: 📜 Restore ccache
uses: actions/cache@v3
with:
path: |
~/.cache/ccache
key: fedora-stable-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }}
restore-keys: fedora-stable-${{ secrets.CACHE_VERSION }}-build
- name: 📜 Set version variable
run: |
echo "IMHEX_VERSION=`cat VERSION`" >> $GITHUB_ENV
- name: 📦 Build RPM
run: |
rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec
- name: ⬆️ Upload RPM
uses: actions/upload-artifact@v3
with:
name: Fedora Stable RPM
path: | path: |
~/rpmbuild/RPMS/*/*.rpm ~/rpmbuild/RPMS/*/*.rpm

View File

@ -1,5 +1,12 @@
include(FetchContent) include(FetchContent)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CPACK_STRIP_FILES TRUE)
endif()
macro(addVersionDefines) macro(addVersionDefines)
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
# Get the current working branch # Get the current working branch
@ -219,9 +226,11 @@ macro(createPackage)
install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
downloadImHexPatternsFiles("./") downloadImHexPatternsFiles("./")
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
configure_file(${CMAKE_SOURCE_DIR}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control) configure_file(${CMAKE_SOURCE_DIR}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control)
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex) install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex)
install(FILES ${CMAKE_SOURCE_DIR}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) install(FILES ${CMAKE_SOURCE_DIR}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES ${CMAKE_SOURCE_DIR}/resources/icon.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.png) install(FILES ${CMAKE_SOURCE_DIR}/resources/icon.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.png)
@ -231,6 +240,9 @@ macro(createPackage)
if (CREATE_BUNDLE) if (CREATE_BUNDLE)
include(PostprocessBundle) include(PostprocessBundle)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
# Fix rpath # Fix rpath
add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $<TARGET_FILE:main>) add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $<TARGET_FILE:main>)

2
dist/Arch/PKGBUILD vendored
View File

@ -26,7 +26,7 @@ package() {
tar -xf imhex-$pkgver-ArchLinux.pkg.tar.zst tar -xf imhex-$pkgver-ArchLinux.pkg.tar.zst
install -DT $srcdir/usr/bin/imhex $pkgdir/usr/bin/imhex install -DT $srcdir/usr/bin/imhex $pkgdir/usr/bin/imhex
install -DT $srcdir/usr/lib/libimhex.so $pkgdir/usr/lib/libimhex.so install -DT $srcdir/usr/lib/libimhex.so.$pkgver $pkgdir/usr/lib/libimhex.so.$pkgver
for plugin in $srcdir/usr/share/imhex/plugins/*.hexplug; for plugin in $srcdir/usr/share/imhex/plugins/*.hexplug;
do do

5
dist/rpm/imhex.spec vendored
View File

@ -47,11 +47,14 @@ cp -r %{_src_path}/* %{_builddir}/
%build %build
%cmake \ %cmake \
-DCMAKE_BUILD_TYPE=%{_build_type} \
-D IMHEX_OFFLINE_BUILD=ON \ -D IMHEX_OFFLINE_BUILD=ON \
-D USE_SYSTEM_NLOHMANN_JSON=ON \ -D USE_SYSTEM_NLOHMANN_JSON=ON \
-D USE_SYSTEM_FMT=ON \ -D USE_SYSTEM_FMT=ON \
-D USE_SYSTEM_CURL=ON \ -D USE_SYSTEM_CURL=ON \
-D USE_SYSTEM_LLVM=ON \ -D USE_SYSTEM_LLVM=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
%if 0%{?fedora} >= 37 %if 0%{?fedora} >= 37
-D USE_SYSTEM_YARA=ON \ -D USE_SYSTEM_YARA=ON \
# if fedora <= 36 get updated to yara 4.2.x then they should \ # if fedora <= 36 get updated to yara 4.2.x then they should \
@ -79,6 +82,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/imhex.desktop
%dir %{_datadir}/imhex %dir %{_datadir}/imhex
%{_datadir}/imhex/* %{_datadir}/imhex/*
%{_datadir}/applications/imhex.desktop %{_datadir}/applications/imhex.desktop
%{_prefix}/lib/libimhex.so %{_prefix}/lib/libimhex.so.%{_version}
%changelog %changelog