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
RFE: set builsubdir to the *first* extracted archive not the last one #551
Comments
I believe that's what the |
The problem is not setting it. The problem is that rpm uses the last extracted directory as default workdir, preventing any preparation that involves this directory before every archive has been extracted |
You're supposed to use For example: |
I don't doubt that's what the setup authors intended, but really, it's overly clever for human beings, that like their commands simple and easy to remember, it's overly clever for scripts, that like to loop over the same command not compute complex lists of arguments, it's overly clever for whoever is tasked to explain it so anyone else, and besides, it does not handle patching of intermediate sources well, packagers want to operate disabling or removal of aditional Sources by commenting out or removing related spec lines, not by argument surgery, and so on. Which is why from time immemorial, starting with the heroic period when maximum rpm was written¹, the documented and actual So could we make the way people actually use ¹ http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html#S3-RPM-INSIDE-SETUP-MULTI-SOURCE |
Part of the problem is the lengths people go to in order to use %setup for unpacking sources even when it ends up being counter-beneficial. Just call it once to setup the main directory and do the rest with tar/unzip/whatever. It's not like the magic %setup incantation required to unpack dozen sources in just the right combo is going to be somehow easier to understand than doing the same manually as a script. Another point is that indeed, if it's not supposed to be used more than once then rpm should prevent that, or at least warn about it. Telling people "it's not supposed to be used that way" doesn't scale. |
Panu, one huge reason There are layers over layers of workarounds in So you have to shoehorn archive names behind an artificial # in So it's not surprising people just use Just provide in rpm a Or, alternatively, fix But having sour grapes about people using |
@n3npq It looks like you are deleting most of your comments after posting them here. This disrupts the discussion and renders the tickets unusable. Also note that they are still available in the mailing-list archive and everyone's mail folder - if you don't want your words to be archived and available for future review please post them else where. |
@nim-nim, but isn't that just about exactly what %setup by default does? Calling it once with no fancy arguments will unpack the first source and define %_buildsubdir, and from there on you can do whatever you want with the rest. Or call it just to create a directory of your choosing and do the rest manually. Like said rpm could do better there, and having different semantics for %_buildsubdir is trivial, but if calling %setup multiple times hurts and makes things unnecessarily complicated, then don't! |
Not really, since the chaining interferes People just want to align %somesetup -z 1
%somesetup -z 2
%somesetup -z 3 Like they align path or source declarations And they want to have some simple way to set the primary root where They do not want to use one macro for
No it won't, the variable is not really set before |
NOW we're getting somewhere. %setup parsing certainly defines it, and this happens before any shell script is executed, but I see it gets lost somewhere in the cracks of %prep parsing. I can take a look at it, all I remember off-hand is that %prep parsing is entirely different from the rest of the build-sections. However I still don't see the big problem here. %buildsubdir is not some magic random value calculated by rpm, it's always %{name}-%{version}, or literally whatever you pass to %setup with -n argument. It's also the directory you'll find yourself in the shell, so derivable from "basename ${PWD}" inside %prep. I have no idea what you mean by chainbuild in this context, nor do I know what %somesetup -zN is supposed to do. Please give us concrete examples and issues so we don't need to guess and assume because I'm sure we all know how well that works. What I can see here is that you be in charge of %buildsubdir. Well, here's an artificial example that will unpack all your sources in a pre-determined randomly named directory and prove that it's what ends up as %buildsubdir.
You could hide the detail of calling %setup exactly once in the %somesetup macro I'm sure. Note that none of this is average "something people want to do", I can only assume this is you wanting to do something with the %forgesetup stuff. Which is all fine and cool, but please speak about the needs of your macros instead of some vague "they" that doesn't exist. |
Oh and BTW, if the reason for wanting to use %setup "at any cost" is that it knows how to extract tar, zip, ruby gems and whatnot automatically, then that might be another concrete something we could look into, ie add a simpler lower level %extract or such helper macro/tool that can do what %setup can, but only for one source, and without the side-effects. |
The packaging pattern is Source0: main-archive
Source1: addon1
Source2: addon2
Source3: addon3
[...]
%prep
%setupsomething -z 0 (main archive)
%setupsomething -z 1 (addon 1)
%setupsomething -z 2 (addon 2)
%setupsomething -z 3 (addon 3 It has the nice properties that:
ASIDE
ASIDE END That's the packaging pattern Maximum rpm already documented in the last century, and having spent some months writing macros which are intended to be used in Maximum rpm is the main vulgarisation document that attemps to explain how to use Now, as Neal explains, those quirks are largely due to the historical However, even even if you use Because So packagers mostly accept this is dark rpm vodoo and that rpm will chdir to the last addon directory in This RFE is about setting
Therefore this is tthe directory the packager can use to centralize files that need centralizing in Alternatively, just making it possible to override in I'm definitely not interested in anything that would be equivalent to %prep
%myprepmacro
%build
%fixprep ← workaround %{buildsubdir} selection in %prep |
And that can be trivialy declined in %prep
%setup -z 0
%patch0
%setup -z 1
%patch1
%setup -z 2
%patch2 (of course one could genereate But anyway I'm not here to discuss why single archive is simpler than multiple archives. That's self-evident. However some people do want to process multiple archives. Being able to handle multiple archive was the first request of Fedora's rpm maintainers when I posted my first macro iterations months ago. So bzzzt people wanted me to look at it, so I looked at it. And it was a major PITA due to many rpm quirks that ended up as RFEs here. My personal use cases do not necessarily match the use cases of everyone in the distribution or its derivatives.
I'm not in the business of setting policies, this is free software, people will use the result if they find it useful and convenient, which is why I make damn sure it is useful and convenient, because I have no interest in wasting my efforts on things almost no one uses in reality, or in explaining to the users of my macros they are idiots that should just do unnatural and unintuitive xxx due to some rpm historical implementation quirk they have no interest in (and just want to be fixed). Also, I do not rely on others to vulgarize and document the usage of my macros, which is a wonderful way to detect an implementation detail is stupid from the user point of view, because documenting it suddenly takes pages. |
This could potentially be solved by #860 (ie just allow macros to do what they want with it) |
Thanks, I need to investigate if #860 solves the problem for me |
FWIW, #1976 moves all the Changing it as per requested here is still being considered, but that has the chance to break stuff that has been carefully arranged for the current, strange scheme. |
With the latest changes to the |
rpm convention is to put the main archive in
SOURCE0
and ancilliary sources inSOURCEX
(this way
SOURCE0
is sure to exist and be stable, and can be aliased toSOURCE
, while the number of addons and their index can vary over a package time)However rpm does not respect its own convention, sets
buildsubdir
to the last processed archive, and cds to this last archive at the start of buildThis has the following deleterious side effects:
the packager ends up working in an addon subdirectory, which is utterly confusing, because this is not the subdirectory he cares about most, and will change over time depending on the number of addon archives he adds to his spec. So his first addition to the spec will be to cd back to the correct directory, or change
%setup
invocation order to processSOURCE0
last (let's all count up towards zero, yay, hard to be less natural)you can not do any cleanup of the extracted archives in
%prep
, that involves things that should end up in the packager main work directory, because this directory does not exist before all archives have been extracted. Instead of the natural:you need to code two loops
This is needlessly byzantine, just set
builsubdir
to the first archive subdirectory, so it is garanteed to exist after the first%setup
invocation, and packagers get warped to their main project files at the start of%build
(or better, to the subdir that matchesSOURCE0
, so%setup
order does not matter past%prep
)The text was updated successfully, but these errors were encountered: