$Id: README lfs-pkg,v 0.4 2005/11/08 20:16:42 bish Exp $

LFS-pkg README

Introduction

LFS-pkg  is  a single bash  script for  package  management of  
LFS systems which depends on the installwatch utility. 

Installwatch

The  main   job  here  is   done  by  the   excellent  utility
'installwatch'  by Pancrazio  `Ezio' de  Mauro <p@demauro.net>
written in 1998. Since then Pancrazio has left maintainance of
the program  has passed reins  to Felipe Eduardo  Sanchez Diaz
Duran <izto at asic-linux.com.mx>

The URL : http://asic-linux.com.mx/~izto

No, you  don't need  to go net  hunting now.  The installwatch
sources (in original) are bundled with this tarball.  Just  cd
to the installwatch dir and do a make. Just 2 files from there
installwatch and installwatch.so needs to be  installed with a
'make install'.

The installwatch utility monitors <command> and logs using the 
syslog(3) facility for every file created or modified.

Aims and Objectives of lfs-pkg

Rather humble in scope, with just about  the bare  essentials I
would need, to cater for package management of an LFS system:

o Keep a record of 'what has gone where' in the install process
o Be able to remove any package from a convenient interface
o Keep an archive of deleted stuff, so that  need for recompile
  can be avoided (if for some reason the need arises).
o Be able to see what all have been hogging my disk space.
o Find details of files installed for any package any time.
o Be able to find out which  binary/ program  belongs to  which
  of the packages installed 
o To be able to find out packages from part-names.

To these ends, all requirements satisfied.

How does lfs-pkg work ?

Essentially all  this script  does is to  perform installation
process under  installwatch, and  then filter the  output file
crosschecking  every  freshly  created/ renamed  file  in  the
installation process,  and creates  a 'package  catalog'. This
catalog is  kept in  a specified repository.  The rest  of the
process is simple manipulations of this repository created.

This script does not presently do any dependency checks (is it
needed for LFS?),  nor does it take care  of configuration and
other files needed/ created/ edited manually post install.

Usage

Command Line interface. Options are, in short,  exactly as what 
is shown in the help screen:

--------------------------<snip>--------------------------------

lfs-pkg Ver-[0.4] : LFS package management

lfs-pkg                                            [ver. 0.4]

This script is meant for LFS package management 

Usage: lfs-pkg [-h | --help] [-I] [-U string] [-v] [-L string] [-f string]

Options:

-h, --help                 Display this help message and exit.
-v                         View list of all packages installed
-l  search_string          List contents of a specified package
-f  search_string          Find which package a file belongs to

-I                         Install     [root privileges]
-U  search_string          Un-Install  [root privileges]
   
Note: search_string may be the name or part name of package,  in 
which case all packages matching the search_string are displayed 	

--------------------------</snip>-------------------------------

All these are self explanatory, and none of these  require any
further treatment except for the '-I' (Install) option.

In concept, the '-I' option  can  handle  any  type  of install
process, though not all have been tried. Things that  have been
tried so far are:

o make install (GNU)
o scorns -k
o install.sh
o direct binary install (e.g jdk-1_5_0_05-nb-4_1-linux-ml.bin)
o no other method tested (please do it for me!).

The '-I' (Install) option:

In essense, there are two types of installs:

a) From the prompt : 'Command to execute'
b) Scripted install (which is essentially the same but a group
   of commands can be bundled in a script, and the script name
   furnished on the prompt above. 
 
Examples of prompt installs ...

a) Command to execute : 'make install'
b) Command to execute : 'scorns -k'
c) Command to execute : 'make --prefix=/usr install' 
d) Command to execute : './install.sh'

The single quotes above is just to higlight  the portion which 
needs to be typed by the user, the quotes should be excluded.

Example of a scriped installs ...

You may make a script out  of a group of commands, and execute
that too ! This is a real life example for installtion of bind
(as per the BLFS-6.1 book) :

#!/bin/sh
PD=`pwd`
make install 
chmod 755 /usr/lib/{lib{bind9,isc{,cc,cfg},lwres,dns}.so.*.?.?}
cd doc
install -v -d -m755 /usr/share/doc/bind-9.3.1/{arm,draft,misc,rfc}
install -v -m644 arm/*.html /usr/share/doc/bind-9.3.1/arm 
install -v -m644 draft/*.txt /usr/share/doc/bind-9.3.1/draft 
install -v -m644 rfc/* /usr/share/doc/bind-9.3.1/rfc 
cd $PD
exit

Then, chmod +x ./filename.sh
On running 'lfs-pkg -I' with root privileges; 
To the prompt as shown below, enter the script name:

viz: Command to execute: './filename.sh'

LFS build system and lfs-pkg

I suppose every person has his/ her own way of building an LFS
system. I for one, do all builds under $HOME, with each source
package in a sub-directory of its own. Since most  source tar-
balls are version stamped, I use the same as the base  name of
the package installed. To this is  appended  the  architecture
and processor stamp of the build system. So, packages built on 
my Intel box have installation names (under lfs-pkg) like:
  
automake-1.9.6-i686-pentium4
bc-1.06-i686-pentium4
bind-9.3.1-i686-pentium4
cdrdao-1.2.0-i686-pentium4

You may ofcourse form your own system. Just  edit the relevant
section of lfs-pkg (which as of now, is heavily commented  and
absolutely straight forward DUMB piece of code).

There are times, the build directory may not have name-version
format. In which case you may opt to do a build in a directory
created specifically so, OR type in the  desired  package name 
to the prompt - 'Edit package name : '   

From then on things are automatic. There are a  total  of four
break points, prresently set to review what is going on ...

The Uninstall (-U) option

The  uninstall  process  only  removes files  created  by  the
install  process. All  uninstalled  packages  may be  retained
optionally in  a bzip2 archive for  subsequent re-installation
by a simple  untarring process later (if such  a need arises).
All  deleted  packages  are archived  in  $ATTIC_DIR.  Purging
of  $ATTIC_DIR  is  manual.  The uninstall  process  does  NOT
remove  the directories  to  prevent  accidental deletions  of
post-install files,  configuration files or data.  You need to
remove such stub directores manually yourself.

The essentials:

For installation read INSTALL file. 

Before you run this script, do the following:

a) Edit the script lfs-pkg and set following variables in case
   you are not happy with the defaults:

   MY_PAGER="less"
   PKG_DIR="/var/lfs/packages"
   ATTIC_DIR="/var/lfs/attic" 
   INSTALLWATCH="/usr/local/bin/installwatch"

b) Set some package-naming convetion for your builds.

c) Create the directories $PKG_DIR and $ATTIC_DIR (If not, the
   the default  directories as in the script  would be created
   during the first install/ uninstall attempts).
   
Last bit ...

This is the first release of lfs-pkg (released for testing and
user  feed-back purposes).  If  there are  any suggestions  or
modifications done by any of you kindly post back the changes.

Dependencies:

coreutils, gcc, bash and gawk ... IOW, it can be used once the 
early LFS installation is in place.If the build directories of 
gcc, bash, gawk and coreutils  are still  on your  system, you  
may do a 'lfs-pkg -I' to place installation details of earlier 
installed packages later with no adverse effect.

The ideal time to start the 'lfs-package' is at the end of the
LFS build and before BLFS. Since the full system is functional
by this stage. All build directories of the  permanent  system
are usually present at that stage to do a 'lfs-pkg -I'

TODO:

Sort out the numerous unknown bugs and shortfalls ...
Anything else that is needed ;-)

Are there any others ?
Suggestions welcome.


USM Bish <bish@touchtelindia.net>
Bangalore,
LFS user: #16142 (rather naive!)

08 Nov 2005
