Writing %post section in spec file ,but %post section isn't running - rpmbuild

I'd written a %post section in my spec file.
when looking in rpmbuild output, i can't see this post section, it's like it doesnt exist. Moreover, i can see other sections like %build, %install and %clean.
Can anyone guess way?
Thanks

The %post scriptlet is run after the RPM is installed, not when it is built, so it is normal for it not to appear in 'rpmbuild' output. The %build, %install, and %clean scriptlets are run when the RPM is built, and that is why they are seen in 'rpmbuild' output.

Related

How can I build FreeBSD from source correctly?

I am trying to build FreeBSD from source to see how it works. I googled how to do it, and most of the websites explaining how to build the world tell me to run this command inside the directory of the source code:
sudo make -j1 buildworld KERNCONF=MODEDKERNEL -DNO_CLEAN
For some reason, I keep getting this error...
make: invalid option -- 'D'
make: invalid option -- 'N'
Anyone know how to fix this? The Makefile can be found here
We don't need to see the makefile, because this error is being printed by make due to an invalid command line argument which means it's never even opening the makefile before it fails.
The reason is that -D, etc. are not valid command line options to GNU make. If you run man make (or look online for the GNU make manual) you'll see that -D is not listed as a valid option.
My suspicion is that when the websites you are reading are suggesting that you run make, they mean you should run FreeBSD make, which does support a -D option: https://www.freebsd.org/cgi/man.cgi?make(1)
You are trying to run this using GNU make, which does not have that option.

rpmbuild | specfile | %post | to execute a command or script as part of rpm install

How to execute some commands or scripts immediately after rpm installed and has to be run as part rpm install command.
I wrote a spec file to take back up of some files within directory and tar them.
When I install rpm tar would be copied on file system how ever I had to untar the ball manually to desired location.
RPM spec %post doesn't execute in rpmbuild
The above lost helped me understand we can include %post steps in spec file itself which would do that job and commands get execute as part of rpm install command itself.
The %post section runs when you install an RPM
Note that echo command included for test purpose are not executed.
For more information on %post in spec file please refer http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html#S2-RPM-INSIDE-BUILD-TIME-SCRIPTS

Preserve files/directories for rpm upgrade in .spec file(rpmbuild)

I wrote a .spec file on RHEL and I am building RPM using rpmbuild. I need ideas on how to handle the situation below.
My RPM creates an empty logs directory when it installs first time within the installation folder like below
/opt/MyInstallation-1.0.0-1/some executables
/opt/MyInstallation-1.0.0-1/lib/carries shared objects(.so files)
/opt/MyInstallation-1.0.0-1/config/carries some XML and custom configuration files(.xml, etc)
/opt/MyInstallation-1.0.0-1/log--->This is where application writes logs
When my RPM upgrades MyInstallation-1.0.0-1, to MyInstallation-1.0.0-2 for example, I get everything right as I wanted.
But, my question is how to preserve log files written in MyInstallation-1.0.0-1? Or to precisely copy the log directory to MyInstallation-1.0.0-2.
I believe if you tag the directory as %config, it is expected that the user will have files in there, so it will leave it alone.
I found a solution or workaround to this by hit and trial method :)
I am using rpmbuild version 4.8.0 on RHEL 6.3 x86_64. I believe it will work on other distros as well.
If you install with one name only like "MyInstallation" rather than "MyInstallation-version number-RPM Build Number" and create "logs directory as a standard directory(no additional flags on it)[See Original Question for scenario] Whenever you upgrade, you normally don't touch logs directory. RPM will leave its contents as it is. All you have to do is to ensure that you keep the line below in the install section.
%install
install --directory $RPM_BUILD_ROOT%{_prefix}/%{name}/log
Here, prefix and name are macros. That has to do nothing with underlying concept.
Regarding config files, the following is a very precise table that will help you guarding your config files. Again, this rule can't be applied on logs our applications create.
http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html
Thanks & Regards.

JavaFX native packager custom post-image scripts

Making a JavaFX app that does remote EJB, and it turns out I need the java executable in the bundle. Building for Mac, Windows, deb, and rpm.
Three questions:
1) Is there a way to get the java executable to end up in the bundle without using the post-image scripts?
2) If not, are there post-image scripts for Linux? (deb & rpm both) These don't show up in the verbose notes like they do for Mac and Windows.
3) Still having a problem with my mac script today. I've verified that the java executable is copied to the right place in the dmg-image tree, but doesn't end up in the final. Yesterday they worked, and I cannot for the life of me figure out what I did to make it work or again to make it stop working today.
Yes, I'm using verbose and have tried all sorts of bash tricks to expose inner workings.
More detail here:
https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_cookbook_using_drop
Thanks for any help,
Tim
True, there is no post-image script for linux (that I could find).
However, you can modify the rpm spec file to do what you want by adding a custom script to the %install section.
For example, a default spec file %install section might look like this:
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/opt
cp -r %{_sourcedir}/YOURAPPNAME %{buildroot}/opt
To add the java executable to the build, just add these 2 lines:
mkdir -p %{buildroot}/opt/YOURAPPNAME/runtime/jre/bin
cp -p ${JAVA_HOME}/bin/java %{buildroot}/opt/YOURAPPNAME/runtime/jre/bin/java

Adding --ignore-failed-read to tar causes "unknown function modifier" error

I'm using the tar command in UNIX to perform backups of particular directories. However, some directories contain files/sub-directories which the current user doesn't have any read permissions on. As a result the tar command is returning a non 0 exit code.
I came across the following modifier in the man pages '--ignore-failed-read', which suppresses the non 0 exit code when encountering files it cannot read. However, whenever I try using it I get the error 'unknown function modifier'.
Could anyone help me out here?
my tar command looks something like this:
tar --create --ignore-failed-read --file=test.tar my_dir
Your command seems to be perfectly valid and I don't see any typos/mistakes.
To be absolutely sure, I just tried it on my VM running under 32 bit Debian 7.1 (wheezy) with stock kernel 3.2.0.4. As I suspected, archive has been created successfuly (the only change was, of course, the name of the source directory). I also checked version of my tar with
tar --version
which gave me following output:
tar (GNU tar) 1.26
First of all, you should check this info. If you get the same (with possible difference in version number) output, that's fine. If not (or version that seems much older), it's possible, that you are using tar, which simply doesn't support this feature.
Also, you can check, if your tar really DOES support mentioned flag. To do this, type into console:
tar --help | grep ignore-failed-read
You should see something like this:
--ignore-failed-read do not exit with nonzero on unreadable files
If output stays empty, that means this version of tar does not know this flag at all.
See if any of the above helps.
Another option that might work better in this case is --warning=no-file-changed.
tar --warning=no-file-changed -czf backup.tgz dir1 dir2
--warning controls the display of warning messages. You can add no- to the message keyword to suppress it. So in this case no-file-changed suppresses the file-changed warning.
c.f. https://www.gnu.org/software/tar/manual/html_section/tar_27.html

Resources