Generating an RPM to also run "make" and "make install" - redis

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

Related

CMake support "make uninstall"?

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.

CMake error not providing FindGnuradio.cmake

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.

How to save php files as .phar or edit source code saved as .phar?

I have downloaded Codeception source code (in .phar format), but I need to add same changes there. So, I want to edit this .phar file, but cannot find a solution, how to do this.
You can build your own phar by using Robo tool.
It is documented in http://codeception.com/install
Clone from GitHub:
git clone git#github.com:Codeception/Codeception.git
Install dependencies with Composer
cd Codeception
curl -s http://getcomposer.org/installer | php
php composer.phar install
Make your changes
Install Robo
wget http://robo.li/robo.phar
Build package
php robo.phar build:phar
Use one of the tools listed in http://cweiske.de/tagebuch/php-phar-files.htm#tools to extract and then re-add the file you want to edit.
The phar executable shipped with PHP is able to extract files and you can add the modified file afterwards.

All AUR packages..after builded by makepkg .. necessarily create an *.pkg.tar.xz file?

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

Where are makepkg outputs packages built?

I'm trying to install a AUR package.
It seems easy, and I follow the Wiki description for it.
I downloaded the tarball, did makepkg -S to download the source and build it.
Apparently no error messages at output.
The process created some tar.gz files, that I tried to target when I use pacman -U
But none of them is the file expected by this command,
'missing metadata package in' ....
I did a research on web. I found that the place that makepkg output the package for Pacman is set in makepkg.conf, using PKGDEST item.
I changed that in /etc/makepkg.conf. It didn't create any file in that place when I tried to make that AUR package again (makepkg -S -f).
How to find the package for Pacman? Did the build go wrong and have no obvious message?
--Well .. after hours of search.. i give up and installed yaourt.. using that this to insall my package
According to https://wiki.archlinux.org/index.php/Makepkg and my firsthand experience, they are put into the working directory by default:
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where makepkg is run by default.