From f12f10bc9e1688d88c38050893f0af53cb4398ce Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Sat, 30 Jul 2022 17:43:42 -0500 Subject: [PATCH] git: Added Fedora .rpm packaging to CI (#608) * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update get_deps_fedora.sh * Update build.yml * Update get_deps_fedora.sh * Update build.yml * Update build.yml * Update get_deps_fedora.sh * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Create imhex.spec * Update build.yml * Update build.yml * Update build.yml * Update build.yml * Update imhex.spec * Update build.yml * Update README.md * remove duplicate fedora build deps * Fix license * Use release tag 0 fedora official packaging starts at 1 so this will prevent conflicts and allow someone who manually installs the RPM to then later get updates from fedora repositories * add RPMs to releases * include rpms in releases * fixed order of ops for fedora builds * can't checkout without git... --- .github/workflows/build.yml | 126 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 4 +- README.md | 2 + dist/get_deps_fedora.sh | 18 ++--- dist/rpm/imhex.spec | 84 +++++++++++++++++++++++ 5 files changed, 224 insertions(+), 10 deletions(-) create mode 100644 dist/rpm/imhex.spec diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8597c1446..30062914e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -376,3 +376,129 @@ jobs: path: | build/imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst + fedora-build-rawhide: + name: 🐧 Fedora Rawhide + runs-on: ubuntu-latest + + container: + image: fedora:rawhide + + steps: + - name: ⬇️ Update all packages + run: | + dnf upgrade -y + + - name: ⬇️ Install setup dependencies + run: | + dnf install -y \ + capstone-devel \ + ccache \ + desktop-file-utils \ + fmt-devel \ + git \ + json-devel \ + libcurl-devel \ + llvm-devel \ + mbedtls-devel \ + mock \ + python3-devel \ + rpm-build \ + yara-devel + + - 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-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }} + restore-keys: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build + + - name: 📜 Restore CMakeCache + uses: actions/cache@v3 + with: + path: | + build/CMakeCache.txt + key: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }} + + - 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 Rawhide 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: | + ~/rpmbuild/RPMS/*/*.rpm diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe7a3b9c7..d40233192 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,9 @@ jobs: - name: ⬆️ Upload everything to release uses: softprops/action-gh-release@v1 with: - files: '*' + files: | + '*' + '*/*.rpm' - name: ✒️ Prepare PKGBUILD run: | diff --git a/README.md b/README.md index 431c3b006..3ad64409d 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ Nightlies are available via GitHub Actions [here](https://github.com/WerWolv/ImH - [DEB](https://nightly.link/WerWolv/ImHex/workflows/build/master/Linux%20DEB.zip) - [AppImage](https://nightly.link/WerWolv/ImHex/workflows/build/master/Linux%20AppImage.zip) - [Arch Package](https://nightly.link/WerWolv/ImHex/workflows/build/master/ArchLinux%20.pkg.tar.zst.zip) + - [Fedora Rawhide RPM](https://nightly.link/WerWolv/ImHex/workflows/build/master/Fedora%20Rawhide%20RPM.zip) + - [Fedora Stable RPM](https://nightly.link/WerWolv/ImHex/workflows/build/master/Fedora%20Stable%20RPM.zip) ## Compiling diff --git a/dist/get_deps_fedora.sh b/dist/get_deps_fedora.sh index 2929be57d..646187857 100755 --- a/dist/get_deps_fedora.sh +++ b/dist/get_deps_fedora.sh @@ -1,14 +1,14 @@ #!/usr/bin/env sh -dnf install \ +dnf install -y \ cmake \ - gcc-c++ \ - lld \ + dbus-devel \ file-devel \ - glfw-devel \ - mesa-libGL-devel \ - mbedtls-devel \ - python-devel \ freetype-devel \ - dbus \ - xdg-desktop-portal + gcc-c++ \ + git \ + mesa-libGL-devel \ + glfw-devel \ + lld \ + mbedtls-devel \ + python3-devel diff --git a/dist/rpm/imhex.spec b/dist/rpm/imhex.spec new file mode 100644 index 000000000..42be407fb --- /dev/null +++ b/dist/rpm/imhex.spec @@ -0,0 +1,84 @@ +# ftbfs without this +%global _lto_cflags %{nil} + +Name: ImHex +Version: %{_version} +Release: 0%{?dist} +Summary: A hex editor for reverse engineers and programmers + +License: GPL-2.0-only +URL: https://imhex.werwolv.net/ + +BuildRequires: cmake +BuildRequires: desktop-file-utils +BuildRequires: dbus-devel +BuildRequires: file-devel +BuildRequires: freetype-devel +BuildRequires: fmt-devel +BuildRequires: gcc-c++ +BuildRequires: mesa-libGL-devel +BuildRequires: glfw-devel +BuildRequires: json-devel +BuildRequires: libcurl-devel +BuildRequires: llvm-devel +BuildRequires: mbedtls-devel +BuildRequires: python3-devel +%if 0%{?fedora} >= 37 +BuildRequires: yara-devel +%endif + + +%description +ImHex is a Hex Editor, a tool to display, decode and analyze binary data to +reverse engineer their format, extract informations or patch values in them. + +What makes ImHex special is that it has many advanced features that can often +only be found in paid applications. Such features are a completely custom binary +template and pattern language to decode and highlight structures in the data, a +graphical node-based data processor to pre-process values before they're +displayed, a disassembler, diffing support, bookmarks and much much more. At the +same time ImHex is completely free and open source under the GPLv2 language. + + +%prep +# don't use the setup macro since we're pulling from git +cp -r %{_src_path}/* %{_builddir}/ + + +%build +%cmake \ + -D IMHEX_OFFLINE_BUILD=ON \ + -D USE_SYSTEM_NLOHMANN_JSON=ON \ + -D USE_SYSTEM_FMT=ON \ + -D USE_SYSTEM_CURL=ON \ + -D USE_SYSTEM_LLVM=ON \ +%if 0%{?fedora} >= 37 + -D USE_SYSTEM_YARA=ON \ +# if fedora <= 36 get updated to yara 4.2.x then they should \ +# be able to build against system libs \ +# https://bugzilla.redhat.com/show_bug.cgi?id=2112508 \ +%endif +# when capstone >= 5.x is released we should be able to build against \ +# system libs of it \ +# -D USE_SYSTEM_CAPSTONE=ON + +%cmake_build + + +%install +%cmake_install +desktop-file-validate %{buildroot}%{_datadir}/applications/imhex.desktop + + +%files +%dir %{_datadir}/licenses/imhex +%license %{_datadir}/licenses/imhex/LICENSE +%doc README.md +%{_bindir}/imhex +%{_datadir}/pixmaps/imhex.png +%dir %{_datadir}/imhex +%{_datadir}/imhex/* +%{_datadir}/applications/imhex.desktop +%{_prefix}/lib/libimhex.so + +%changelog