I am trying to find some sudo-free solution to enable my users install and unistall my application. Using
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/opt/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}/")
SET(CMAKE_INSTALL_RPATH "$ENV{HOME}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}/")
I can direct the files to the user's home directory, and
make install
works fine. With reference to
What's the opposite of 'make install', ie. how do you uninstall a library in Linux?
I did not find any idea, which is sudo-free and is not complex for a non-system-admin person.
Is anyhow make uninstall supported by CMake?
My uninstall is quite simple: all files go in a subdirectory of the user's home. In principle, removed that new subdirectory could solve the problem. Has make install, with parameters above, any side effect, or I can write in my user's guide that the newly produced subdirectory can be removed as 'uninstall'?
If you want to add an uninstall target you can take a look to the official CMake FAQ at:
https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
If you just want a quick way to uninstall all files, just run:
xargs rm < install_manifest.txt
install_manifest.txt file is created when you run make install.
No there is not. See in the FAQ from CMake wiki:
By default, CMake does not provide the "make uninstall" target, so you
cannot do this. We do not want "make uninstall" to remove useful files
from the system.
If you want an "uninstall" target in your project,
then nobody prevents you from providing one. You need to delete the
files listed in install_manifest.txt file. [followed by some example code]
Remove files and folders (empty only) added by make install from a cmake project:
cat install_manifest.txt | sudo xargs rm
cat install_manifest.txt | xargs -L1 dirname | sudo xargs rmdir -p
The second command will print a bunch of errors because it recursively deletes folders until it finds one that is not empty. I like seeing those errors to know which folders are left. If you want to hide these errors you can add --ignore-fail-on-non-empty to rmdir.
From the source folder:
open install_manifest.txt (created by make install)
remove all the directories/files listed
remove any remaining files you missed:
xargs rm < install_manifest.txt
remove any hidden directories/files:
$rm -rf ~/.packagename
Remove the source folder.
# make uninstall
add_custom_target("uninstall" COMMENT "Uninstall installed files")
add_custom_command(
TARGET "uninstall"
POST_BUILD
COMMENT "Uninstall files with install_manifest.txt"
COMMAND xargs rm -vf < install_manifest.txt || echo Nothing in
install_manifest.txt to be uninstalled!
)
Add this to CMakeLists.txt, then an uninstall target is made by hand.
One solution is to use packaging with CPack. In Linux, that will create a package that can be installed/uninstalled by your package manager. In Windows with the NSIS generator, you'll get an installer which also deploys uninstall.exe to your program files.
Here's a basic example of creating a debian package:
$ touch file
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
install(FILES file DESTINATION etc)
set(CPACK_PACKAGE_NAME foo)
set(CPACK_PACKAGE_CONTACT "me <me#example.com>")
set(CPACK_GENERATOR DEB)
include(CPack)
$ cmake .
$ cpack
Then instead of make install DESTDIR=/usr/local use sudo dpkg -i foo-0.1.1-Linux.deb.
To uninstall use sudo dpkg -P foo or sudo apt purge foo.
The advantage of using a package manager over make install are numerous. Here are a few:
If you lose the source code, you can still uninstall the software.
If you dpkg -S /etc/foo, it will tell you which package "owns" this file.
If you want to install a new version of the software, you won't need to manually uninstall the previous version. It's all automatic.
You can publish the package so others can install it.
If your package deploys a file that is also owned by another package, it will fail to install. That's good because it prevents you from accidentally destroying other packages.
You have the ability to add scripts to the installation. Instead of simply copying files, you can add system users, enable serves, or perform compatibility operations on old databases during upgrade.
Related
I am adding Conan support to my CMake projects. I followed Recipe and sources in the same repo tutorial and I end up with the expected package. Exploring the local repository folder, I found out that my source files are copied in 3 different folders (source, build and export_source) so the repo is growing fast even with small projects.
Is there a way to clean repository folders where sources are duplicated, after package creation (keeping only the folder needed for "dependency build from sources")?
Sure, you can remove things from the cache with the conan remove command. In this case you probably want to do:
conan remove "*" -s -b -f
* to match all packages in your local cache
-s to remove the source folders
-b to remove the build folders
-f to not ask for confirmation
The sources stored together with the conanfile.py in the cache, can't be removed, cause they are stored with the conanfile to be able to rebuild from sources when conan install --build is done.
I want to install redis by creating a rpm. I want to run all the commands that need to happen:
tar xvzf redis-3.2.1.tar.gz
cd redis-3.2.1/
make
make test
make install
Is there any documentation on creating a .spec file to do this?
While you can write a *.spec file from scratch, it is usually easier to modify an existing *.rpm. E.g. you can often easily upgrade to redis-3.2.1 from the existing resist-3.0.6 package here: http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/source/tree/Packages/r/redis-3.0.6-3.fc24.src.rpm
I am trying to write a PKGBUILD for the AUR right now for a github project consisting of several sub applications.
So basically the CMake file of this project just runs a make to make && make install the sub applications.
These are my build and package steps:
build() {
cd "$srcdir/$_gitname"
[[ -d build ]] && rm -r build
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/od ..
}
package() {
cd "${_gitname}/build"
sudo make all
}
My problem is now that everything works except:
makepkg -i is never asking for sudo rights during build (therefore I had to add sudo in front of the make all)
When asking for installing, makepkg does not recognize the size of the package. Therefore the package does also not uninstall when running packman -R packagename
I cannot change the CMake file though, because the project is not mine and all the different subapplications belong together and if I try make && make install them separately I get a bunch of errors that they are depending each other.
The package function cannot install into the root hierarchy. Instead, makepkg is intended to install into the pkgdir under a fakeroot, where the pkgdir replicates the actual root directory structure. See ArchWiki/Creating Packages.
You can do this by adding DESTDIR="$pkgdir/" to the make options in your package function.
When pacman is invoked on the created package, it will copy the files over into the real root hierarchy.
As an exmaple
package()
{
cd "$pkgname"
DESTDIR="$pkgdir" cmake --install out
}
This will install things to $pkgdir, and then packaged to zst file.
Getting the following error when running cmake and am unsure how to fix it. It seems like it's telling me exactly what to do, but not very familiar with Linux.
CMake Error at CMakeLists.txt:153 (find_package):
By not providing "FindGnuradio.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Gnuradio",
but CMake did not find one.
Could not find a package configuration file provided by "Gnuradio"
(requested version 3.7.3) with any of the following names:
GnuradioConfig.cmake
gnuradio-config.cmake
Add the installation prefix of "Gnuradio" to CMAKE_PREFIX_PATH or set
"Gnuradio_DIR" to a directory contaning one of the above files. If
"Gnuradio" provides a separate development package or SDK, be sure it has
been installed.
EDIT: So I've located something called FindGnuradioRuntime.cmake but am still unsure what to do with it. The error message makes me think it was looking for something named "FindGnuradio.cmake" when it was actually called "FindGnuradioRuntime.cmake"
Commands that were run on a fresh Ubuntu install:
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr/
mkdir build
cd build/
cmake ../ (here is where I ran into a the problem above)
Install / build GNU Radio.
Remove the CMakeCache.txt
When you call cmake .. you can pass arguments. Add the path to the parent directory of GnuradioConfig.cmake or FindGnuRadio.cmake as in
cmake -DCMAKE_PREFIX_PATH=/gnu/radio/path ..
Making my somewhat hidden response an actual answer:
Just found out that the install script provided on GNURadio's website not only installs GNURadio, but also the RTL SDR requirements as well, so I wiped my VM and started over and was successful. It takes a few hours, but it is complete and automated so definitely the best way to install GNURadio. Script is here http://www.sbrac.org/files/build-gnuradio
As previous answers noted you didn't describe where you ran into this problem. I'm going to assume it happened when creating an Out Of Tree (OOT) module.
On the OOT Module Page, see the "Notes" Section. They note that you need to install gr-dev. That package will install GnuradioConfig.cmake. You can find it in the standard yum repos, and install it with sudo yum install gnuradio-devel.
Well .. this question came from another one closed question that i posted here. I installed android using yaourt.. and that was ok.. it worked fine.
But, before that i was trying doing manually.. using makepkg. But it seems that it did not create any package named *.pkg.tar.xz .
After a search.. and some question for my friends.. they told me that maybe the make process had problems and, it had some silent problem that not created the *.pkg.tar.xz.
So.. what do you think.. all AUR packages necessarily create *.pkg.tar.xz file and it was a problem when i was trying to build. Or has certain packages , as android , that do not create such *.pkg.tar.xz files?
An AUR package is a PKGBUILD file with instructions to makepkg to build a package (which is a .pkg.tar.xz file), so yes, unless there is any error on the build process, all AUR packages create a .pkg.tar.xz file.
You could try downloading the PKGBUILD file and running the makepkg -si manually to check any build error. Here's an example to build and install the android-sdk package, adjust accordingly to your desired package. This should create a android-sdk-*-x86_64.pkg.tar.xz file.
cd $(mktemp -d)
wget https://aur.archlinux.org/packages/an/android-sdk/android-sdk.tar.gz
tar xzvf android-sdk.tar.gz
cd android-sdk/
makepkg -si
Used arguments to makepkg:
-s, --syncdeps Install missing dependencies with pacman
-i, --install Install package after successful build