
package-setup
@1998 by Antonio Gallo
======================

This is the version 2 of the Bad Penguin installer for .bpp
packages. Note that this package is created with autoconf/automake
but you require an installed version of 'libbadpenguin' in order 
to be able to compile it.


* Help ..............: setup -h|--help
* Local installation : setup [options] [path]package-name<.bpp>
* Implicit upgrade ..: setup [options] package-name
* Remote installation: setup [options] -i|--install  [path]package-name<.bpp>  [target-rootdir]
* Upgrade ...........: setup [options]    --upgrade  package-name  [target-rootdir]
* Removing ..........: setup [options] -e|--remove|--delete  package-name
  [target-rootdir]
* Clean Up / Purge ..: setup [options] --cleanup|--purge|--prune  package-name
  [target-rootdir]
* Dependencies check : setup [options]    --request  <package-name>:[minVer]:[maxVer]:[libName]:[libMin]:[libMax]  [target-rootdir]
* Restore ...........: setup [options]    --restore  package-name  [target-rootdir]
* Update ............: setup [options]    --update   package-name  [target-rootdir]


Options:
  -v    --verbose ...: be verbose
        --debug .....: turn on a lot of unusefull information for the user
        --no-header .: do not show the program banner with name and version




Installation Overview
=====================
There are two kind of installation:
  1. installation of a specified filename containing a package;
  2. installation of a specified software;
and two mode of installing a package:
  1. locally, on the "/" FS;
  2. remote, on a different OS mounted everywhere you want;


Package Installation
====================
- if the package filename includes the extension ".bpp", or if it include
  some path name, it means that the parameter on the command line is 
  referred to a filename. In this case we have a "package installation",
  otherwise we have to discover with different methods which is the 
  package that contains the software we want to install;
- the filename we specified should exist;
- before to parse the package infoes stored into the .bpp we need to
  check that under our temp partitions (/var/tmp/) we have at least
  500 Kb of free space;
- we create a tempdir under /var/temp and we use 'untar()' to extract
  only the '/install' directory from the package. untar() is very
  higly optimized it will stop after copied the latest file from the
  install directory without reading all the file, this is an advantage
  with big packages like X-Window or the Kernel source;
- we make sure that a /install directory exists into the package;  
- we setup a signal callback prodedure that will clean up our temporary
  files in case of trouble;
- the here we go to read and parse the infoes into /install/INFO
  expecially we compose FULLVERSION="${SONAME}_${VERSION}" and we
  check that some important fields are filled correctly;
- we check the architecture of the package and of the target machine;
- we check for the OS of the package and of the target machine;
- we print the name of the package and a short description of what we
  are going to install;
- we use DISKUSAGES to check if there is enough free space under each
  mountpoint we have;
- we check the dependencies;
- after installing some dependencies we have to check again for the
  available free space;
- we remove any package that conflict, i.e. the package itself if it
  is already installed;
- we execute the PRE-INSTALL script if present;
- we extract the whole package under the target directory with untar();
- we run 'ldconfig' in case of an interactive installation;  
- we execute the INSTALL script if present;
- we schedule the POST-INSTALL script if present;
- we schedule the X-POST-INSTALL script if present;
- we register the package moving the /install directory from the temporary
  dir in /var/spool/badpenguin/$FULLVERSION
- we run '--finalize' in interactive mode after the package has been
  successfully installed;
That's all



Checking DISKUSAGES
===================
To check the diskusages we ...
  1. build a list of all the mount points from the target /etc/fstab
  2. the list of mount points is ordered alphabeticalling from the 'z' to 'a';
  3. we check the freespack on each mount point
  4. for each dir mentioned into DISKUSAGE we find under wich mount point
     it is present. If there isn't any match we assume "/" (root)
  5. The amount of disk usage for the matched dir is decreased from the
     free space of the mountpoint; if free space goes under 10MB we issue 
     a warning, if free space goes under 10KB you cannot install the package



Checking Dependencies
=====================
To check the dependencies we ...
  1. first build a list of them from the REQUEST variable
  2. for each found deps we ...
     a. try to see if the requested package is installed;
     b. try to see if the requested bin or lib is present;
  3. if some deps is not found we currently halt;
That's all



Handling Dependencies
=====================
A dependencie is made of 6 value:
- package name, is the global mask of the package to be matched;
- min version, is the minimum version of the package requested;
- max version, if present is the maximum version of the package requested;
- lib name, if this file is present the dependencie is resolved
  if it is not an absolute path then its name is searched into the most
  common libraries directories;
- lib min, is the minimum version of the libName requested;
- lib max, is the maximum version of the libName requested;

Syntax:
- package name is the only one mandatory required field;
- if max version is filled also min version should;
- if lib max version is filled also lib min version should;
- if lib max or lib min are filled also lib name should;



Removing or Cleaning Up a package
=================================
To remove or cleaning up a package we ...
  1. check the packagename and targetdir values
  2. check if the package is already installed
  3. ... and if the MANIFEST file is present
  4. run the PRE-REMOVE script
  5. open the MANIFEST file and
     a. remove all the files except the ones in /install and /incoming
     b. if cleaning up then remove also the file in /incoming
     c. if a file is not delete then is threathed as a directory and 
        is scheduled into a TChain
  6. go thru' the list of all the cached directories to be removed from
     the tail to the head, in this way all the EMPTY directories will be
     removed
  7. run the REMOVE script
  8. if cleaning up then run the CLEANUP script
  9. schedule the POST-REMOVE script if any
  10. un-register the package removing is spool directory
That's all



Implicit install or Upgrading a package
=======================================
To upgrade a package we ...
  1. check the packagename and targetdir values
  2. find the more upgraded installed version of the package
  3. open a depot and try to find a version of the package more updated
     then the installed one, when a package is found the loop is ended
  4. if found something it will be installed otherwise you get an error
     message
That's all



Restoring & Updating
====================
1. restore work using the setup_install() code but it just try to restore
   missed files without touching anything else, it does not run any script.
   Restore is usefull when you delete some files.
2. update, instead, run the installation scripts and replace out of date
   files. Update is usefull when you untar some old data upon the new one.
That's all
   