Build one thing, and plan its removal first
Task
Compile a small program from source into a prefix you can delete, having verified its signature rather than only its checksum. The removal plan comes first, because nothing will track the installation for you.
Steps
- Choose a small project with published signatures -- GNU hello is ideal. Download the tarball, its
.sigfile and the project's signing key. - Verify the checksum, then verify the SIGNATURE with
gpg --verify. Note what each one proves, and state the difference in one sentence before continuing. - Attempt
./configureand let it fail on a missing development header if it does. Install the-develpackage it needs and read the error message again -- the library was present all along; the headers were not. - Configure with an explicit, versioned prefix:
./configure --prefix=/opt/hello-2.12. Read./configure --helpfirst and note at least two options you might have wanted. - Build as your ordinary user with
make. Do not use sudo for this step. - Install with
sudo make install, which is the only step needing privilege. - Add the prefix to your PATH, run the program, and confirm it works.
- Remove it:
rm -rf /opt/hello-2.12. That deletion is clean only because of the decision made in step 4.
Verify
gpg --verify hello-*.tar.gz.sig hello-*.tar.gz 2>&1 | grep -qi 'good signature' && echo "signature ok"
/opt/hello-2.12/bin/hello
ls -d /opt/hello-2.12
rm -rf /opt/hello-2.12 && test ! -d /opt/hello-2.12 && echo "removed cleanly"
rpm -qf /opt/hello-2.12/bin/hello 2>&1 | grep -qi 'not owned' && echo "package manager never knew"
The last check is the point of the whole lab: the package manager has no record of the software you just installed, which is why the prefix decision and the removal plan had to come first.
Notes
Had you configured with the default --prefix=/usr/local, the binary, its manual page and its locale files would now be scattered across four directories with nothing recording which ones were yours. That is the state people find themselves in, and the reason checkinstall and stow exist.