Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] IMHEX_OFFLINE_BUILD not working properly #2054

Open
1 task done
xoores opened this issue Jan 5, 2025 · 5 comments
Open
1 task done

[Bug] IMHEX_OFFLINE_BUILD not working properly #2054

xoores opened this issue Jan 5, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@xoores
Copy link

xoores commented Jan 5, 2025

Operating System

Linux

What's the issue you encountered?

I'm adding the latest version of ImHex (1.36.2) to my portage overlay so Gentoo users can install it using standard package manager and the current version fails to build in the Gentoo sandbox even when I have IMHEX_OFFLINE_BUILD=ON-

How can the issue be reproduced?

Build from the latest sources in network sandbox.

ImHex Version

1.36.2

ImHex Build Type

  • Nightly or built from sources

Installation type

Portage

Additional context?

Used CMAKEARGS:

-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_C_FLAGS="-fuse-ld=lld" \
-D CMAKE_CXX_FLAGS="-fuse-ld=lld" \
-D CMAKE_OBJC_COMPILER_LAUNCHER=ccache \
-D CMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_SKIP_RPATH=ON \
-D IMHEX_USE_BUNDLED_CA=OFF \
-D IMHEX_PLUGINS_IN_SHARE=OFF \
-D IMHEX_STRIP_RELEASE=OFF \
-D IMHEX_OFFLINE_BUILD=ON \
-D IMHEX_IGNORE_BAD_CLONE=ON \
-D IMHEX_PATTERNS_PULL_MASTER=OFF \
-D IMHEX_IGNORE_BAD_COMPILER=OFF \
-D IMHEX_USE_GTK_FILE_PICKER=OFF \
-D IMHEX_DISABLE_STACKTRACE=OFF \
-D IMHEX_VERSION="${PV}" \
-D PROJECT_VERSION="${PV}" \
-D USE_SYSTEM_CAPSTONE=ON \
-D USE_SYSTEM_CURL=ON \
-D USE_SYSTEM_FMT=ON \
-D USE_SYSTEM_LLVM=ON \
-D USE_SYSTEM_NFD=OFF \
-D USE_SYSTEM_NLOHMANN_JSON=ON \
-D USE_SYSTEM_YARA=ON

Error, where some plugin seems to try & pull something from the internet during the compilation despite having OFFLINE_BUILD=ON:

/opt/dotnet-sdk-bin-8.0/sdk/8.0.107/NuGet.targets(156,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/var/tmp/portage/app-misc/imhex-1.36.2/work/ImHex/plugins/script_loader/support/dotnet/AssemblyLoader/AssemblyLoader.csproj]
/opt/dotnet-sdk-bin-8.0/sdk/8.0.107/NuGet.targets(156,5): error :   Resource temporarily unavailable (api.nuget.org:443) [/var/tmp/portage/app-misc/imhex-1.36.2/work/ImHex/plugins/script_loader/support/dotnet/AssemblyLoader/AssemblyLoader.csproj]
/opt/dotnet-sdk-bin-8.0/sdk/8.0.107/NuGet.targets(156,5): error :   Resource temporarily unavailable [/var/tmp/portage/app-misc/imhex-1.36.2/work/ImHex/plugins/script_loader/support/dotnet/AssemblyLoader/AssemblyLoader.csproj]
@xoores xoores added the bug Something isn't working label Jan 5, 2025
@WerWolv
Copy link
Owner

WerWolv commented Jan 5, 2025

Hey! Interesting, I'm not sure there's much I can do about that besides just disabling script support entirely. Are there any other packages that build .NET applications? How do they handle Nuget?

As a workaround for now, the easiest you can do is disable the script loader plugin using the following cmake variable:
-DIMHEX_EXCLUDE_PLUGINS="script_loader"

@xoores
Copy link
Author

xoores commented Jan 5, 2025

Aah, nice - I just deleted the offending folder and it build correctly without it 🙂 Thanks, definietly is a cleaner way to do it.

I'm not really sure - I will check that out. Normally things like that are done by "pre-downloading" all the packages/files necessary for the compilation. There also seems to be a nuget.eclass that (probably) might help with that, I will explore that for sure & let you know.

@yretenai
Copy link
Contributor

yretenai commented Feb 4, 2025

I'm not really sure - I will check that out. Normally things like that are done by "pre-downloading" all the packages/files necessary for the compilation. There also seems to be a nuget.eclass that (probably) might help with that, I will explore that for sure & let you know.

You have to build the related assembly loader independently from cmake due to how gentoo's dotnet eclass handles things.

This is how I resolved it in my overlay (common eclass requirements like rdeps, src_uri=nuget_uris are omitted in the following snippet, and my ebuild is not sane as it is a live git ebuild.)

DOTNET_PKG_COMPAT="8.0"
NUGETS="
[email protected]
[email protected]
[email protected]
[email protected]
"
inherit dotnet-pkg 
DOTNET_PKG_PROJECTS=( "${S}/plugins/script_loader/support/dotnet/AssemblyLoader/AssemblyLoader.csproj" )

pkg_setup() {
	default
	dotnet-pkg-base_setup
}

src_prepare() {
	# build dotnet script loader separately.
	sed -e "s|^add_dotnet_assembly|#|g" -i plugins/script_loader/support/dotnet/CMakeLists.txt || die
	sed -e "s|add_dependencies|#|g" -i plugins/script_loader/CMakeLists.txt || die
}

src_configure() {
	local mycmakeargs=(
		...
		-D IMHEX_OFFLINE_BUILD=ON \
		-D IMHEX_PLUGINS_IN_SHARE=ON
		...
	)

	cmake_src_configure
	dotnet-pkg_src_configure
}

src_compile() {
	cmake_src_compile
	dotnet-pkg_src_compile
}

src_install() {
	cmake_src_install
	dotnet-pkg-base_install "/usr/share/imhex/plugins/"
}

For the cmake files to support this layout properly, there needs to be some way to override where nugets are stored since portage dumps them all in one place. dotnet allows for you to specify the nuget cache location but I don't know if cmake itself can handle that at all.

There are also some issues with using both dotnet-pkg/nuget and cmake in the same ebuild.

@WerWolv
Copy link
Owner

WerWolv commented Feb 4, 2025

I'm happy to adjust some things in the build script if it helps you guys package ImHex more easily.
The CSharp build is mostly done manually using a add_custom_command call that directly just runs dotnet build on the files. If dotnet supports it already, it would be trivial to change the nuget path

@yretenai
Copy link
Contributor

yretenai commented Feb 4, 2025

I need to investigate further how nuget.eclass/dotnet-pkg.eclass functions but I think most of it can be resolved with a bunch of environment variables judging by the msdn article about nuget folders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants