Open kevin-j-smith opened 7 years ago
For the first part pf your question I think preinstall is just doing a linux commandline to echo what you've given it, that is "echo %_macros_variable_here. preinstall, postinstall, etc. are just shell scripts. I don't know if you can expect _macros_variable_here to exist as an environment variable in the shell. Or maybe you should try doing it in postinstall, rather than preinstall, since it might not be getting defined until the actual install.
That's the easy one.
Why the doubling? Not sure. You don't say if you've done anything on the nebula side to create this variable or not. I see no such functionality there. So I must assume that the first time the rpm knows about _macros_variable_here
is when you run rpm to install the rpm. Could be a bug either in rpm or in rpmbuild.
For the lack of information as to what I am doing, sorry. I've tried many things to get the correct behavior and may have overlooked things to mention of things in which I was thinking at first. Here is what I have:
build.gradle: buildscript { repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:gradle-ospackage-plugin:+'
}
}
def percentage = Character.toString((char)37); apply plugin: 'nebula.ospackage'
ospackage { packageName = 'example' version = '6.0.8.1' release = '1' arch = NOARCH os = LINUX
into '/opt/ibm/example'
//preInstall file('scripts/rpm/acceptedLicense.sh')
//has the exact same string a below in an actual file
preInstall("""#!/bin/bash
echo %_accepted_license
""")
from('x') {
createDirectoryEntry = true
fileMode 0755
}
}
buildRpm {
}
gradle buildRpm rpmrebuild --package --notest-install -e build/distributions/example-6.0.8.1-1.noarch.rpm
You can scroll down and now see a double %% in the %pre macros.
If you remove the extra % sign (and add Licenses, Distribution....I just put example in all of that) Type :q and y to save the new rpm.
To run the new rpm
sudo rpm -i <
You will see the output true
If you run the nebula built rpm you will see %_accepted_license
For further information the %pre section can use macros in the scripts. There are many places these macros can be defined: rpm --showrc will list the list where the macros come from. Or they can be defined on the command line or spec file. I am just choosing the command line.
To reply to your replies first paragraph. The spec file can substitute macros' in the scriptlets. Rpm doesn't insert them into the env and then run the script. Rpm substitues the macros (which can be a value or method) into the script then runs the script.
I hope this helps. I really couldn't find where an extra % would come from. I see the strings and collections of string being passed from nebula to redline and redline using StringBuilder to write them to the Message's Entry. Even if there was a string format happening anywhere I did try a %% in the gradle file and that was represented as %%%% in the spec file. In java %% is an escape for % when using string format.
I also have this same issue. Was trying to include a systemd service in my RPM and wanted to use the %{systemd_requires}
macro.
Hello,
While working with the nebula rpm plugin for gradle I have found a difficult issue and I cannot locate the exact location as to where this is happening or how to escape it. Please help.
In the ospackage for nebula I am using:
preInstall(""" echo %_macros_variable_here """
When I go to install the rpm --define '_macros_variable_here hereIam' I see output
%_macros_variable_here
Where I am looking for the actual value of the variable (where ever it is defined...command line, ~/.rpmmacro, ...)
The actual issue with when the spec file is created the % turns into %%. I have looked through nebula and this code and I cannot find where it is being replace or how it is turning into %%. I have tried \% and \% and %% in order to escape the sign, without avail.
To work around this I have been manually running: rpmrebuild --package --notest-install -e example.rpm
This new rpm will handle the defined macros properly. Do you have any idea 1) how the the extra percent sign is being inserted or 2) how to properly get only one % inserted in the generated spec file?