I'm wondering what are good practices about compilation and manual installation of software on Linux systems. I mean getting, building and installing code by this usual way :
git clone https://a-repo/foo.git
cd foo/
./configure
make
make install
- Should that be avoided ? Or is it recommended ? Maybe it is better to make a package for the distribution in use ?
- Are there some tricks to manage versions and updates ?
- Does good practices exists when doing
./configure
, particularly with--prefix=
? - How can I install / uninstall properly ? Should I always keep the
sources to do
make uninstall
? - I have seen some tools like
stow
, but this seems to be a controversial solution... Maybe an other one ?
I prefer solutions that are independents of distro, but all suggestions and advices are welcome !
Thank you !
EDIT: It seems that people don't understand my question. I'm not opening a debate, I just want an answer as clear as possible for the various points above. I really think this could be helpful for some people. Thank you for your contribution.
1 Answer 1
The problem with your method is figuring out what files have to be deleted when you want to uninstall the software.
The best practice is to build a package for the distribution. This has several advantages. It allows you to easily install, upgrade, & remove packages. It allows you to compile the software on a seperate machine avoiding putting compilers on every machine. It allows you to easily upgrade the package when the upstream goes to another version/release. And, it allows you to build the software without being root.
A quick & dirty work around I used before I learned how to use rpmbuild & spec files was to:
./configure
make
make DESTDIR=/tmp/build install
This puts all the "installed" files with the correct installation tree under the /tmp/build directory. Then change the owner/group for all the files in the directory. Then:
tar cvfj <filename> -C /tmp/build/
To install them:
tar xvf <filename> -C /
To uninstall them:
tar tf <filename> | xargs rm
-
Thanks for this tip, I think this is something like that I want ! I tried this
bash tar cvjf ed.tar.bz2 -C /tmp/build/ tar: Cowardly refusing to create an empty archive Try 'tar --help' or 'tar --usage' for more information.` But I got this error as you can see.
So triedtar cvjf ed.tar.bz2 -C /tmp/build/ .
, but this creates a problem when uninstalling:bash rm: impossible de supprimer './usr/local/': Aucun fichier ou dossier de ce type
ramius– ramius2022年11月03日 08:31:14 +00:00Commented Nov 3, 2022 at 8:31 -
I did this but it is a little dirty ;-)
tar tf ed.tar.bz2 | sed -e 's/^.//' | xargs rm
ramius– ramius2022年11月03日 08:37:31 +00:00Commented Nov 3, 2022 at 8:37 -
@thiblcr Whatever works. However, if you are going to be doing a lot of these, you should take the time to learn how to build packages. Another resource is "pkgs.org". Someone may have already built the package for your distro.Garnet– Garnet2022年11月03日 22:03:23 +00:00Commented Nov 3, 2022 at 22:03
-
Yeah thank you very much, your solution is very simple, I 'll keep this trick... I'm mainly on Gentoo, so I'll need to learn how to write ebuilds. I think you're right about building packages, this seems to be the better way !ramius– ramius2022年11月04日 07:39:05 +00:00Commented Nov 4, 2022 at 7:39
You must log in to answer this question.
Explore related questions
See similar questions with these tags.
--prefix=/opt/something
or even--prefix=/opt/something-VERSION
. No issues with deinstalling, installing, keeping track of versions, etc. Don't wanna write an answer - there's just too much to talk about.stow
, I like the concept of this minimalistic software. The problems I encountered withstow
were about some symlinks not working, mainly forsystemd
services.