[Index] [About]  
Author Simes
Created:  2005-11-18
Last changed:  2005-11-18
[Root]  [Prev] [Idx] [Next] http://www.bpfh.net/computing/software/pkg-tools/how.html 

How it works

The following is a simple description of how parts of the package tools system works.


build-pkg

build-pkg performs its job by doing the following:

At the end of the above the package will be in the work directory as a single file. With the default options you will see, relative to the current working directory, the following file:

InstallPackage/%PKG%-v%VERSION%-%ARCH%.pkg

Where the values surrounded by % signs are macros set for the current package. Thus if the package has a name of SomePackage, with a version of 1.0.2 and was built in the SPARC architecture then the name would be:

InstallPackage/SomePackage-v1.0.2-sparc.pkg

This package is suitable for adding to a system by using the following command line:

#pkgadd -d InstallPackage/SomePackage-v1.0.2-sparc.pkg

Note that to run pkgadd you have to be the root user.

[Top] [Manual page]


chroot-install

chroot-install builds and environment suitable for installation of software within a chroot()ed environment by doing the following:

Whilst this may appear to be a large amount of work the result is that it appears to the installation process occuring within the chroot() jail that it has access to the entire system can do what it wants.

This is due to chroot() changing the root directory of the process which calls the chroot() system call. Every process has a pointer to the physical directory the root file system, or / resides on. This pointer is used in all file handling operations where the system is called upon to find the location of /. Thus to open the file /somefile the system will do something similar to the following:

This means that if the pointer for / in a process is changed to a different directory then the entire world view of the process will be changed.

This is what the chroot() system call does.

Due to this world view change, a working environment has to be built for the chroot()ed process as essential system files will not be present within the new world view the process has.

So if the following lines of code were executed:

chdir("/some/directory");
chroot("/some/directory");

Then the root directory for the calling process would stop being / and start being /some/directory. Effectively this would mean that chdir("/") would actually take you to /some/directory.

This does cause some problems as there are files which are essential to the sane running of the system. For example if you wanted to run the most basic shell, /bin/sh in a chroot()ed environment, you'd have to provide at least the following inside the directory the process was going to be chroot()ed to:

[Top] [Manual page]

[Root]  [Prev] [Idx] [Next] http://www.bpfh.net/computing/software/pkg-tools/how.html 
 [Index] [About] Powered by WML
Author Simes
Created:  2005-11-18
Last changed:  2005-11-18
 
More by the same author Comments? EMail webmaster@bpfh.net
 
© Simes