I need to build a RPM, with the sole purpose of installing a few fonts. I have read several tutorials about that, however everyone seems to suggests something different and I haven't been able to find something like a very basic setup to do that.
Is it possible to just reference the files within the %files section of the spec? I tried however, rpm always tries to find the files within the tmp directory. Do I need to add a specific build step that copies everything I need to the tmp directory?
Should these files go into the SOURCE or the BUILD directory when building the rpm? I have been finding a lot of different information on that. Some suggest to build a tarball that contains the files and place that under the SOURCE directory, however that seems kind of wrong, as font files are not actual source files to me.
Ideally, I would like to just put all the font files within the BUILD folder under a directory structure like './usr/share/fonts/' and then reference that within the %file section of the SPEC and let RPM do its magic. Probably I am missing or misunderstanding something here.
Does the %files section always expect to find the source files within the tmp directory, or is there something wrong with my setup? I have created ~/.rpmmacros which contains
%_topdir /Users/user/rpm
which is the root build directory and contains the BUILD, RPMS, SOURCES, SPECS and tmp directories.
I would be glad if someone could provide which are the least required items in the spec file to get that to work cleanly.
Edit
Following user3159253's suggestions, I am using the following spec file:
Name: test
Version: 1.0.0
Release: 1
Copyright: Copyright info
Group: Applications/System
BuildArch: noarch
%description
Brief description of software package.
%prep
%build
%install
mkdir -p %{buildroot}/usr/share/fonts
cp ./usr/share/fonts/* %buildroot/usr/share/fonts/
%clean
%files
/usr/share/fonts/*
I copied the fonts into the BUILD/usr/share/fonts/ directory. If I query the rpm for a list of files, all fonts are there. However, when I install the rpm, it complains about
/usr/share/fonts is needed by test-1.0.0-1.noarch
However, it doesn't matter if this directory exists or not, so I guess rpm is complaining that this resource is not listed in its database.
I have been able to fix this by changing the %file section to:
/usr/
/usr/share/
/usr/share/fonts/
/usr/share/fonts/*
However, I doubt that this is such a good idea. Is there a better way to fix this?
when you list files in %files
section these files are expected to reside within %{buildroot} directory. As Fedora documentation says since Fedora 10 buildroot can't be redefined in the spec, so yes, you have to create a required filesystem hierarchy within %buildroot, copy there your font files and then mention them in %files
:
...
%install
mkdir -p %{buildroot}/usr/share/fonts
cp /path/to/existing/MyFont.ttf %buildroot/usr/share/fonts/
...
%files
%defattr(0644, root,root)
/usr/share/fonts/*
your distribution probably has handy macros for standard font files locations, their proper registation in the system upon installation of the rpm etc, but most of these macros are vendor-specific. Also, you should copy your font files into SOURCES/ subdirectory and mention them in Source:
(Source<N>:
) tag in the rpm spec (just an example, a number can be any):
Name: myfonts
Summary: my fonts package
...
Source5: MyFont.ttf
...
Then you may use something like this in the %install
section:
cp %{SOURCE5} %buildroot/usr/share/fonts/
instead of a full path to the MyFont.ttf.
Update:
You're right about missing dependencies: this is not artifacts (files, directories etc) on the filesystem, this is records in the RPM db (in /var/lib/rpm). So to solve the problem you have to work with that DB.
So if you have unsatisifed dependencies in the generated RPM package you have two options:
- if you simply wish to have a convenient way to distribute few files w/o tight integration with standard system facilities (see below), then you may simply turn off all
rpm
automatic dependency calculations. Use AutoReqProv: no
to completely disable all that stuff.
- However you may need to build a package with a better integration with the rest of the OS. For example, fonts may need a registration within appropriate system facilities, e.g.
fontconfig
. Unfortunately, different Linux rpm distributions have slightly different, eh-hm, customs regarding that. Actually you have to check how this process is organized in your distribution in already existing font packages. You may take a suitable source rpm package (check http://rpmfind.net or http://rpm.pbone.net RPM search engines), extract its .spec-file and study how %prein
, %postin
, %preun
and %postun
section of the spec are organized. Obviously, font packages usually carry -fonts- in their name :)
Afterall, you may display dependencies and provides of an uninstalled rpm package with rpm --query --requires --package </path/to/file.rpm>
and rpm --query --provides --package </path/to/file.rpm>
. Installed packages' deps are shown with rpm --query --requires <rpm_name>
and so on.
As an answer for your edited question, the following might be the answer you seek:
Name: test
Version: 1.0.0
Release: 1
Copyright: Copyright info
Group: Applications/System
BuildArch: noarch
%description
Brief description of software package.
%prep
%build
%install
mkdir -p %{buildroot}/
cp -r ./* %buildroot/
%clean
%files
/*
Here we consider every file in the BUILD directory to be a part of the package. This is done by placing /*
under %files
.
Hope this addresses your question correctly.