LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Question about rpm spec files and %post scripts (https://www.linuxquestions.org/questions/linux-software-2/question-about-rpm-spec-files-and-post-scripts-399462/)

rpg 01-04-2006 10:08 AM

Question about rpm spec files and %post scripts
 
I have been trying to fix up a spec file for some xemacs packages so that it properly installs all of its info files.

The problem is that there is a set of info files that are installed, but that never get install-info invoked on them.

What I would like to do is to say (in the %post script)

Code:

for all info files being installed to %{_infodir}
    /sbin/install-info $f %{_infodir}/dir --section="Xemacs"

and then the inverse for the %postun script.

Unfortunately, I'm not sure how to translate "info files being installed to %{_infodir}" into bash code. Can anyone advise me?

Similarly, I need to translate "info files being removed from %{_infodir}" into bash code, and I have, if possible, even less notion of how to do that task.

I have had a look at the Maximum RPM book, but its examples of scripting are pretty limited, and don't seem to describe any environment variables, bound in the scripts, that would help with this. I would have thought that there would some way be access to the file list in the scripts, but I have not been able to determine what this is, if it exists.

Thanks!

GrueMaster 01-04-2006 11:46 AM

Unfortunately, Maximum RPM is severly out of date, but updated documentation is available online here. The script you want to run is almost complete as is. Here is what the xemacs script for Mandriva does with the info files:

for f in /usr/share/info/xemacs/*.info.bz2; do
/sbin/install-info $f /usr/share/info/dir --section="XEmacs"
done

Hope this is helpful

rpg 01-04-2006 11:59 AM

Clarifying the question....
 
Quote:

Originally Posted by GrueMaster
Unfortunately, Maximum RPM is severly out of date, but updated documentation is available online here. The script you want to run is almost complete as is. Here is what the xemacs script for Mandriva does with the info files:

Code:

for f in /usr/share/info/xemacs/*.info.bz2; do
  /sbin/install-info $f /usr/share/info/dir --section="XEmacs"
done

Hope this is helpful

I have looked at the Red Hat documentation as well. All the documentation on RPM that I can find is distressingly vague about what is the precise environment in which post install scripts will be evaluated. For example: What environment variables are available? What macros (%files?) may be employed? What directory will you be in?

The problem with the above script snippet is that xemacs also installs some files in /usr/share/info (as well as /usr/share/info/xemacs). The info files in /usr/share/info are not correctly indexed.

AFAICT, I cannot simply do:
Code:

for f in /usr/share/info/*.info.bz2; do
  /sbin/install-info $f /usr/share/info/dir --section="XEmacs"
done

...because if I do I will pick up not only the info files installed by xemacs, but also all the info files that are already there, turning the info directory into a mess. So the open question is "how do I find a list of the newly-added info files?" I don't see anything in the RPM docs that tells me how to do this...

Note that this problem does not arise in the code snippet you offered, because the packagers have carefully put those info files into a pristine new directory (/usr/share/info/xemacs).

Best,
R

GrueMaster 01-04-2006 09:32 PM

I guess I'd have to see your spec file. The snippit I got was from the rpm's post script, not the actual spec file. I assumed from other spec files I do have that this should work if you manually install the info files during the install process of building the rpms. I'll check it more thoroughly when I get home from class.

GrueMaster 01-06-2006 01:56 AM

Sorry for getting back so late on this.

The emacs package manually defines an rpm macro containing all the info file names, then uses the macro name in the post section to install them:

Quote:

%define info_files ada-mode autotype ccmode cl dired-x ebrowse ediff efaq emacs emacs-mime eshell eudc forms gnus idlwave info message mh-e pcl-cvs reftex sc speedbar vip viper widget woman

%post
# --section="GNU Emacs"
for f in %info_files; do %_install_info $f
done
:
Bad for dynamically added files, which is what I'd assume you are trying to acomplish. I'll continue to experiment and see what I can come up with.

rpg 01-06-2006 07:20 AM

emacs versus xemacs
 
Yes, I believe that would work for FSF emacs, which is distributed rather differently. Unlike FSF emacs (AFAIK), Xemacs provides packaging of a large set of emacs-lisp packages. This is a modified Mandriva RPM, and rather than trying to keep on top of the set of emacs lisp packages, Mandriva simply repackages the "sumo tarball," of xemacs lisp packages. This leads to the approach you see here, where an attempt is made to automatically find the info files and package them up into one big xemacs-packages rpm.

FWIW, if it's inelegant to package this way, trying to use FSF emacs on Mandriva has shown me the value of it. Instead of the sumo tarball, FSF emacs is packages with a flood of individual emacs-lisp packages, which are nightmarish to track and get installed. It's much nicer to just get one big rpm and install that.

A second problem, which I have just found, is that there can be a fair amount of collision between xemacs and FSF emacs info files, so it's all the more important to find all the info files and operate on them.

One possibility, it seems to me, would be to find all the info files during the build process, when they're easy to get your hands on (I know how to do this). The problem with doing that is that I don't know how to pass information from the build process into the install process. It seems possible to push information from the build process in the special case of writing a file and then reading it into the %files (the %files -f filename trick). I don't know if there's any similar trick to more generally record information during a build cycle and then use it later in the install process.

Thanks for your help.


All times are GMT -5. The time now is 05:18 PM.