function fake_install
This function is the heart of the src2pkg method for creating
packages. It performs some of the most important and delicate
operations in the whole process. This function tracks the creation of
files on your system during package creation, normally with the command
'make install'.
Main purpose
- Backup exisiting files which will be overwritten by the install
command before overwriting them.
- Track and log the creation of files, links and directories from
the INSTALL_LINE command.
- Copy the newly created files, directories and links to the
package tree (PKG_DIR).
- Restore backups of any files which were overwritten.
- Remove any leftover new files, links or directories which were
created on your system.
- Correct or remove installed files when needed.
Notes
Originally src2pkg(PkgBuild) tried to use a DESTDIR or 'fake'
installation directory, hence the function name. But DESTDIR is not
supported by many sources. Even worse, many sources only partially
support DESTDIR or have faulty config files which cause some files to
be really installed and others to be installed in the DESTDIR. For
sources which didn't support DESTDIR we used the installwatch library
to track the installation, parsing the logfile it creates to get a list
of the files and directories which were installed. The files could then
be copied into the PKG_DIR for further processing. This is exactly what
the checkinstall program does, then after creating the package it is
installed with the Slackware 'installpkg' program so that the files are
registered in the pkgtool database.
However, I wanted src2pkg to create packages without having them
installed by default. Since not all sources work correctly with DESTDIR
I looked for a more dependable way. I did lots of testing and comparing
of logs and found that many times even 'make uninstall' fails to remove
what 'make install' installs.
Using installwatch allows us to accurately track the creation of all
files since it creates a very detailed log. Careful parsing of this log
provides us with lists of files, directories and links which get
created. installwatch also has a backup feature which allows us to
create copies of any file which is about to be overwritten. By
combining these two features src2pkg is able to safely package most
software whithout damaging your original system. When files do get
overwritten they are restored a fraction of a second later -even before
proceeding with package building. ldconfig gets run a couple of times
also, so you can usually even rebuild libraries and programs which are
in use during the build. But it's safer to avoid this, if possible.
You should avoid using this method for creating basic system packages
like glibc, bash or gcc. Instead, skip this step and write manual
installation code into your src2pkg build script.
fake_install will also work with multiple Makefile rules or alternate
commands besides 'make' by spcifying the INSTALL_LINE variable. This
includes tracking installations which use an install.sh (or other)
script and require input from the user during installation.
Some source code contains no installation routine at all, requiring you
to write instalaltion code into your script. Still, if no 'install'
rule is found src2pkg will search the SRC_DIR for a binary with the
same name as the package. If found it will be copied to the PKG_DIR
along with any man-pages found.
This function can also create compressed archives of any backup files
which were created above. This is useful if you are using
REALLY_INSTALL=YES to have src2pkg install the package using
'installpkg' after finishing.
The default behaviour of this function should leave your running system
exactly as before, even if files were overwritten during package
creation.
Avoid interrupting or cancelling this function while it is running. If
you do so, any files which have been overwritten must be backed up by
an emergency backup routine which is not as pretty as the orderly
backup done by default. Please avoid pressing CTRL+c when you see the
"Tracking Installation" prompt!
After all installation is finished and all files have been copied to
the PKG_DIR, fake_install does a few sanity checks and corrections on
the package content. Any info or man-pages or documents which have been
badly installed under /usr/share/man(info) or /usr/share/doc are moved
to /usr/man(info) and /usr/doc. A similar check is done later during
package creation -we do it twice just to distinguish between who is at
fault. If it happens here we assume the Makefile(and the developer that
wrote it) is at fault If badly placed content is found later we assume
that you have written the code which is doing it and scold you more
personally. :-)
This function also includes an advanced package making option which
takes care of removing development libraries and header files from the
package tree. This allows you to create packages that contain only the
needed runtime libraries, without the static '*.a' libs or '*.h'
development headers.