Re: [opensuse-packaging] Variables in %Files Section
Hello,
You define the variable to the verbatim string "`/bin/hostname -s`". In the scripts this is substituted for the output of /bin/hostname -s, but it fails in the %files section.
But the real problem is somewhere else -- why do you need to store the build host name in the package?
i package some server-tools which have to be installed on this individual folder cause control domain of server points to this document-root
But you do realize that such package will only work on the machine where you build it? There must be a number of ways how to avoid this kind of packaging.
I use similar specs for a time. Variables in %install or %post sections work on each maschine where i installed it. if there is no way to use my variable in %files section i have to install on hard linked folder and copy/remove in %post and %postun section. not very nice... why %files is different to %install etc? Andre --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Hi, On Tue, 3 Jun 2008, Andre Hübner wrote:
I use similar specs for a time. Variables in %install or %post sections work on each maschine where i installed it. if there is no way to use my variable in %files section i have to install on hard linked folder and copy/remove in %post and %postun section. not very nice... why %files is different to %install etc?
Because the %files section provides the list of filenames (rpm -ql) whereas the %install section simply expands to a shell script (hence you can use backticks). The filenames stand for themself and don't have to be interpreted, and that's a good thing, you don't want to run huge shell-scripts just to get a file list. If your package really insists on having its file in a directory named according to its hostname, and can't be configured in some other way, then I would advise you to place the files in some fixed directory, and only create a softlink (named like hostname) to that directory. Ciao, Michael.
Andre, besides the fact that is seems sort of wrong to embed the host name of the building machine into an RPM, as others explained already, let me try to explain what's going on: On Tue, 3 Jun 2008 at 15:17, Andre Hübner wrote:
if there is no way to use my variable [...]
What you have is not a variable, it is a macro. The expansion of the macro is the verbatim string "`/bin/hostname -s`" and not the output of this command as you seem to expect.
why %files is different to %install etc?
Because %install (as well as %prep, %build, %check and %clean) are shell scripts, but %files is just a list of file names. RPM performs macro and glob expansion on the files list, but no variable or command substitution. Now when processin the spec file RPM first replaces %{HOSTNAME_SHORT} by the string `/bin/hostname -s` in all sections and then runs the resulting shell scripts or processes the files list, respectively. It is the shell running the scripts who then interprets the backticks and replace the commands by their output. The solution for your question (though probably not the right solution for packaging your package - I am repeating myself and others here) would be to let RPM run the command once and set the macro to the command's output rather than the command string: %define HOSTNAME_SHORT %(/bin/hostname -s) cu Reinhard --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
participants (3)
-
Andre Hübner
-
Michael Matz
-
Reinhard Max