using cmake to install files to /usr/sbin - linux

I'm having some issues installing a script into /usr/sbin from a cmake script. In my packaging.cmake I have
install(FILES "${CMAKE_SOURCE_DIR}/kpcmdctrl" DESTINATION /usr/sbin COMPONENT kptester
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
and in the generated spec file:
%files
%defattr(-,root,root,-)
%dir "/opt/mycomp"
%dir "/opt/mycomp/kptester_prog"
%dir "/opt/mycomp/kptester_prog/bin"
"/opt/mycomp/kptester_prog/bin/kptester"
%dir "/opt/mycomp/kptester_prog/etc"
%dir "/usr/sbin"
%config "/usr/sbin/kpcmdctrl"
when I run yum localinstall kptester-0.0.1-1.x86_64.rpm I get the following error:
Error: Transaction test error:
file /usr/sbin from install of kptester-0.0.1-1.x86_64 conflicts with file from package filesystem-3.8-6.el8.x86_64
I've tried installing the script in other places such as /usr/bin and it works without issue. I've checked the package listing for filesystem-3.8-6.el8.x86_6 here and I can't see any reason for it to complain?
Am I missing something obvious or is /usr/sbin a special directory?

Posting my own solution in case anyone else comes across this problem. The problem was that the RPM was trying to own the system folder e.g. /usr/sbin. You can see this from the spec file I posted in the question: %dir "/usr/sbin"
There is an option in cmake to tell it not do to this:
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin")
or if you have more than one system folder:
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin")
The new spec file doesn't have the system folder listed as a directory and install works as expected.

Related

Getting folder conflicts when running yum groupupdate inside a chroot environment

I have a chroot environment where i am getting folder conflicts when I am running the below command.
/usr/bin/yum --verbose --assumeyes --installroot /home/prateek/project/.ova_work_dir/mnt/dst_root --config=/home/prateek/project/.ova_work_dir/mnt/dst_root/etc/yum.repos.d/project-upgrade.repo --obsoletes groupupdate '*' project
Below is the error
Running transaction test
Transaction check error:
file /usr from install of messagebus_c-1.0.0-0.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64
I have below two questions to ask:
1) Why i am getting folder conflict when yum is running transaction test as I have seen file conflicts but not folder conflicts.
2) How would I resolve this folder conflicts.
The messagebus_c RPM specfile needs to be edited to not "own" /usr but instead all the files in it, e.g. /usr/*.
Can you try this ?
/usr/bin/yum --verbose --assumeyes --installroot=/home/prateek/project/.ova_work_dir/mnt/dst_root --config=/home/prateek/project/.ova_work_dir/mnt/dst_root/etc/yum.repos.d/project-upgrade.repo --obsoletes groupupdate '*' project
issue was
missing equal to sign --installroot /home
expected like this --installroot=/home
This can happen when messagebus_c spec file has:
%install
touch %{buildroot}/usr
%files
/usr
I.e. here the /usr is a file. While filesystem provides it as a directory. You cannot have both. A directory cannot be a file. And vice versa.

Why do I get /etc/cups conflicts between attempted installs in Yocto?

I have a recipe to compile a printer driver and have a few simple lines to run in do_install.
do_install() {
install -d ${D}${libdir}/cups/filter
install -m 755 ${B}/src/rastertoprinter ${D}${libdir}/cups/filter/
install -d ${D}${sysconfdir}/cups/ppd
install -m 755 ${B}/../rastertoprinter/printer_name.ppd ${D}${sysconfdir}/cups/ppd/
}
To compile the source I have a DEPENDS on cups and also an RDEPENDS on cups as the OS needs cups installed to print of course.
The printer driver is not publicly available so as such I've renamed it to rastertoprinter and changed my path names.
Essentially I need to simply create or ensure the directory /usr/lib/cups/filter exists, and copy the rastertoprinter program there. I also need to create or ensure the directory /etc/cups/ppd exists and copy the .ppd file into that directory.
The first two lines run fine but the 3rd throws the following errors:
file /etc/cups conflicts between attempted installs of printername-r0.corei7_64 and cups-2.2.2-r0.corei7_64
file /etc/cups/ppd conflicts between attempted installs of printername-r0.corei7_64 and cups-2.2.2-r0.corei7_64
I don't understand why both recipes can't create this directory and put stuff in it? Strangely I'm able to do the first /usr/lib/cups/filter directory though fine.
Turns out the issue is that each file to be packaged in Yocto will also generate a %dir for each parent of each file. We don't want to own a directory that is owned by another package, so if you add this to your recipe:
DIRFILES = "1"
It will cause your package to not own parent directories of the files you package.
This will generate an rpm spec file without the %dir entries.

Restund giving me error: libre.so: cannot open shared object file: No such file or directory

I installed libre 0.4.16 on my server using the following (I did this as root):
wget http://creytiv.com/pub/re-0.4.16.tar.gz
tar xf re-0.4.16.tar.gz
cd re-0.4.16/
make
make install
After that, I went back into the parent folder, and installed restund like so:
wget http://creytiv.com/pub/restund-0.4.12.tar.gz
tar xf restund-0.4.12.tar.gz
cd restund-0.4.12/
make
make install
After this, I tried running the following in the main folder:
restund ./restund-0.4.12/etc/restund.conf
And it gave me this error:
restund: error while loading shared libraries: libre.so: cannot open shared object file: No such file or directory
I searched this up, and I ran ldconfig in the main directory, but to no avail.
Any other fixes for this problem? Is it because I'm running it as the root user?
I'm running CentOS 6.4 Linux on my server, if that helps.
I think libre installs to /usr/local/lib by default. So you need to add that to your library path or set DESTDIR to /usr/lib/ in the Makefile.
nano /etc/ld.so.conf.d/restund.conf
add following line to .conf
/usr/local/lib
and
reload
ldconfig
restart
restund -d /etc/restund.conf
try this on your terminal sudo ldconfig

rpmbuild: common ownership of directories

Suppose packages I'm building for myprog1 and myprog2 are to install in /usr/lib/mysystem/myprog1/ and /usr/lib/mysystem/myprog2/
According to some distros' documentation, such in the case of OpenSUSE, both packages must own the shared directory. But how is that accomplished in the .spec files? Is the following correct?
%files
/usr/lib/mysystem
or do I need to do
%files
%dir /usr/lib/mysystem
/usr/lib/mysystem/myprog<1|2>
Usually only one package owns a given directory. On a typical system, there will be a package such as "filesystem" which may own things such as /bin. In the case of the filesystem package on Red Hat and OpenSUSE, that package owns /usr/bin but none of the files within that directory.
You could do that, by making a wrapper-package which owns things that are shared across your applications, and making it a dependency (Requires) of the applications which install into those directories.
To see what actually owns something with rpm, you can use the -qf options, e.g.,
rpm -qf /usr/lib/mysystem/myprog
The command works for directories as well as files.
The documentation for %dir and %files is the place to start when deciding how to make a package own a directory. In Maximum RPM: Taking the Red Hat Package Manager to the Limit, chapter 13 Directives For the %files list, it says:
As we mentioned in the section called The %files List, if a directory is specified in the %files list, the contents of that directory, and the contents of every directory under it, will automatically be included in the package
The way to get around this, is to use the %dir directive. By adding this directive to the line containing the directory, RPM will package only the directory itself, regardless of what files are in the directory at the time the package is created. Here's an example of %dir in action.
%dir /usr/blather
So the latter of the suggested cases follows the documentation. However, as a check on whether the syntax is correct (even if the rpm happens to build) it is good practice to examine the list of pathnames.
Investigating Fedora 21 to find packages for which rpm -qf shows the same directory finds several. For example, initscripts and chkconfig use the %dir directive to do this:
%dir /etc/rc.d
%dir /etc/rc.d/rc[0-9].d
%dir /etc/rc.d/init.d
in initscripts spec-file, and
/etc/rc.d
/etc/rc.d/init.d
/etc/rc[0-6].d
/etc/rc.d/rc[0-6].d
in chkconfig spec-file. However, the initscripts package requires /sbin/chkconfig, which is provided by the chkconfig package. Because of that dependency, chkconfig is the actual owner of the directory.
That depends, especially if the packages for program1 and program2 are built from one source or form completely different sources.
If they come from one source, you have to differentiate in a more sophisticated way:
%files program1
%dir /usr/lib/mysystem
/usr/lib/mysystem/program1
%files program2
%dir /usr/lib/mysystem
/usr/lib/mysystem/program2
If you build them separately, you can just do
%files programX
/usr/lib/mysystem
if you work with a clean buildroot which nevertheless only contains the files created by your package.
But it doesn't hurt to do
%files programX
%dir /usr/lib/mysystem
/usr/lib/mysystem/programX
as well.
If you have several such packages, you could even create a common package which owns that directory and which as well provides other requirements if you have such. It is then sufficient to require this "parent package", "company package" or how you want to name it.
Then it is enough to do
Requires: mysystemcompanypackage
...
%files
/usr/lib/mysystem/program1

I do not have use/local/src/ on Mac, what should I do?

I am neophyte on Mac especially on terminal. Though I've read lots of materials, I am still very confused and do not know what I should do.
I need to use aspell on MAC. I followed a tutorial (http://wiki.lyx.org/Mac/MacSpelling) to install it and I've installed Xcode and gcc. In one step, it required me to "type ./configure, followed by ". I did it, but terminal showed:
-bash: ./configure: No such file or directory
This webpage (http://ubuntuforums.org/showthread.php?t=1849525) showed the configure in under "/usr/local/src/configure" but when I cd to this directory I found I do not have the /src/ folder.
/usr/local$ ls
CODEOFCONDUCT.md README.md include/ opt/
CONTRIBUTING.md SUPPORTERS.md info/ share/
Cellar/ bin/ lib/
LICENSE.txt etc/ libexec/
Library/ git/ man/
What show I do? How can I use the ./configure?
Thank you so much.
You likely don't have the command line development tools installed.
Try
xcode-select --install
It also looks like you have homebrew installed. I believe that there is a formula for aspell, so you can try
brew install aspell
The aspell-0.60.6.1 tarball does have a configure script inside its own source tree (so it is located at aspell-0.60.6.1/configure). So you should start with something like (to do outside of /usr/local/, for example in your $HOME/freesoftsource/ directory if you have one, or maybe even simply in your $HOME if you dare).
wget ftp://ftp.gnu.org/gnu/aspell/aspell-0.60.6.1.tar.gz
tar xzvf aspell-0.60.6.1.tar.gz
cd aspell-0.60.6.1
./configure
You may want to add some options to the ./configure above.
You should read aspell installing instructions
N.B. As with most GNU software using configure, the location of the source tree (extracted from the source tar archive as above) does not matter much.

Resources