-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Variables not preserved between functions. #1006
Comments
|
Yep, but you could also drop |
If you dropped those flags then you'd end up with problems from prepare being ran twice (as well as the added time for extracting twice). As far as I'm concerned pkgbuilds should declare their variables in every function where they need them and to do otherwise is incorrect. Not doing so also breaks useful makepkg features like |
You've got a point there. Perhaps moving variable logic outside of functions would be a proffered solution, despite it's ugly and hacky 😞 and I will have a ton of packges to refactor |
I didn't say outside of functions but instead inside each one. Not sure if there's a difference there but I believe that to be the recommended way to do it. |
And here lays the problem.
As an |
I've a canny plan, you can put a tail on i and call it a fix 😉 I'll just call |
Just wonder, if we could have |
No, if just for the fact that AUR helpers are unsupported and you don't need to care about them. When it comes to this issue my suggestion to set the variables in every function that needs them is because I believe it is the correct way to write a PKGBUILD. Makepkg has flags for skipping functions, When it comes to #1004 though, I stand by my opinion. Yay does not support dynamically changing depends. If yay users complain then tough luck, use makepkg or a helper that does support it. Also I just read your pkgbuild. Turns out all your prepare function did was set variables. The point of the prepare function prepare the sources for building (hence why |
Indicate to PKGBUILD that it is executed within yay context. refers to Jguer#1006 Jguer#1004 Jguer#893
Yap, that's why I've changed it. Still thinks adding |
@bartoszek, allow me to put on my "I am an upstream makepkg developer" hat. DO NOT USE PREPARE JUST TO SET VARIABLES. You are violating the PKGBUILD specification, and as a result your PKGBUILD sucks. Furthermore, You may consider this to be my advice that the recommended way to write a PKGBUILD is to declare your variables in every function that needs them, or alternatively in the global scope. Not that it matters for your use case as it is very clearly information specific to the build() function and the invocation of cmake, which you are illegitimately moving elsewhere. |
I don't even understand what your "magma" PKGBUILD is supposed to be doing, since apparently it passes different options to CMake depending on whether cuda is installed, then compiles with nvcc which I believe means it links to the cuda runtime libraries. Therefore it would seem to me that the package must also add a You should be using something like The result is of course that aurutils is unable to build the software using cuda. So much for using aurutils? Or maybe being unable to use cuda if you are an aurutils user is a feature? More generally, what exactly do you feel is dirty about setting a global variable outside of the prepare function? The variable you already had is global too, as soon as you execute prepare() it adds a global variable. Luckily it is also defined with a leading underscore to prevent clashes... If you wanted to avoid global variables you would need to use the local keyword, but of course that would mean it would not be available in build() anymore, since that is a different function... If it is about checking for the existence of some directory, but only after prepare() started, then given that cuda is not listed as a dependency neither that directory nor anything else cuda related will ever be missing as a global check, but suddenly be present during prepare(). So you might as well have it be global. It is true that things like |
This won't reliably work across different AUR-helpers. |
Nothing, just having some problems with variables using subshell to initialize (like mentioned |
I'm having this stupid issue with one of my packages (magma). Users keep reporting that binaries are installed in
/usr/local/magma
instead of/opt/magma
path. In spite thatPKGBUILD
have explicitly statedCMAKE_INSTALL_PREFIX=/opt/magma
inprepare()
function.I've just tested this in clean chroot, and it looks like
yay
in fact somehow is changing cmake install prefixis not preserving variables betweenprepare()
andbuild()
. This is really strange as plainmakepkg
is working as intended 😕I'm not a
yay
user and a compleat noob ingo
, can't pin point the issue further...The text was updated successfully, but these errors were encountered: