How to make a TGZex package
From WikiDoc
Indispensable information
TGZx packages are a wider version of well known slackware TGZ. The package frame is very simple - it's a compressed TAR archive containing a folder tree. Before you create a package, you have to compile the program (the object that is supposed to be packed). Remember to compile the package on the clean Kate OS installation, so that system users will not have any problems with dependencies. Before the compilation process, read README and INSTALL files (found in source archives) very carefully. Always think about any problem that may arise. Remember also to choose additional program options adequately, as some additional programs seemingly needeed may destabilize the program or increase its requirements. Next important thing during the program compilation is setting up the right flags for the compiler. By default the following flags: -O2 -march=i486 -mcpu=i686 -pipe. are used while creating packages for Kate OS. Remember to use a default compiler widely accessible. If the majority of users use 3.3 version (we assume they do), we do not compile the program by using a newer gcc version.
If you deal with a standard source archive, then the basic procedure is simple: ./configure && make && make install DESTDIR=/$ path to the temporary folder.
Remember however, that this is just an example how to proceed with sources, do not forget about places where individual program parts should go.
Let's assume that:
- Programs, libraries absoltely indispensable for system start up and its proper functioning are located in system's root, it means in "/".
- Programs important for the system like all the servers, graphic environments etc. should be located in /usr folder.
- all less important programs, mostly multimedia, are directed to /usr/local folder.
- Games should be placed in /usr/local folder, and theirs binary code in /usr/local/games folder.
- All the programs, libraries least important for the system, should be optionally placed in /opt folder.
- Manual should be located in /usr/man folder, or optionally (not recommended) in /usr/local/man folder.
- Files with *.desktop extension serving as a part of menu in standard freedesktop.org should be located in /usr/share/applications folder.
- Icons for *.desktop files should be located in /usr/share/pixmaps folder, or in /usr/share/icons.
- "*.info" files should be located in /usr/info/ folder.
The content of each package should have suitable permissions. Root.root with 755 permissions should be a default files owner.
All executable files and root.bin should have 755 permissions, except for games that should have 754 root.games permissions. It is not very important to use a bin group, it's just difficult to give up an old tradition.
Text files (manual, documentation etc.), that should not be modified should have 644 permissions with root.root as the owner.
Files that require different permissions should have them set up accordingly. Remember not to start any daemons or server with root permissions whenever possible. Wherever possible, use alternative users or groups created for this specific purpose. Remember that special users or groups have only id accessible till 500, any numbers above are allocated for ordinary users.
Specific packages have specific groups (with set id) assigned to them, so check if an id is not used in a different package before you create a new group for a program in this package. To do this, ask a member of the Kate_Team (at present it would be Damian who knows best).
The structure of TGZex package
Kate OS packages consist of a main tree that starts from the root and additional install folder that contains specific contents for the package. Below you will find a content of a hypothetical package (it has been shortened):
var/www/htdocs/manual/new_features_1_3.html.html
var/www/htdocs/manual/new_features_1_3.html.en
var/www/htdocs/manual/new_features_1_0.html
var/www/htdocs/manual/new_features_1_1.html
var/www/htdocs/manual/new_features_1_2.html
var/www/htdocs/index.html.ru.cp-1251
var/www/cgi-bin/
var/www/cgi-bin/test-cgi
var/www/cgi-bin/printenv
var/cache/
var/cache/proxy/
usr/
usr/bin/
usr/doc/mm-1.3.0/THANKS
usr/doc/mm-1.3.0/INSTALL
usr/doc/mm-1.3.0/PORTING
usr/doc/mm-1.3.0/ChangeLog
usr/doc/apache-1.3.33/
usr/doc/apache-1.3.33/LICENSE
usr/doc/apache-1.3.33/README
usr/doc/apache-1.3.33/README.configure
usr/doc/apache-1.3.33/ABOUT_APACHE
usr/doc/apache-1.3.33/README.EAPI
usr/doc/apache-1.3.33/INSTALL
usr/doc/apache-1.3.33/Announcement
usr/man/man8/logresolve.8.gz
usr/man/man8/apachectl.8.gz
usr/man/man8/apxs.8.gz
usr/man/man8/ab.8.gz
usr/man/man8/httpd.8.gz
usr/sbin/
usr/sbin/ab
usr/sbin/apxs
usr/sbin/httpd
usr/sbin/logresolve
usr/sbin/rotatelogs
usr/sbin/apacheconfig
usr/sbin/apachectl
usr/libexec/apache/mod_define.so
usr/libexec/apache/mod_dir.so
usr/libexec/apache/mod_env.so
usr/libexec/apache/mod_auth_anon.so
usr/libexec/apache/mod_digest.so
usr/libexec/apache/mod_headers.so
usr/include/
usr/include/mm.h
usr/include/apache/httpd.h
usr/include/apache/http_main.h
usr/include/apache/ap_alloc.h
install/
install/build
install/doinst.sh
install/slack-desc
install/postinst.sh
install/preinst.sh
You will notice that install folder contains some bizarre files.
build file is an ordinary text file, containing only date in DDMMYYYY format.
slack-desc file contains package description, here is an example content of such a file:
{tu hash} HOW TO EDIT THIS FILE:
{tu hash} The "handy ruler" below makes it easier to edit a package description. Line
{tu hash} up the first '|' above the ':' following the base package name, and the '|'
{tu hash} on the right side marks the last column you can put a character in. You must
{tu hash} make exactly 11 lines for the formatting to be correct. It's also
{tu hash} customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
apache: apache (The Apache HTTP Server)
apache:
apache: Apache is an HTTP server designed as a plug-in replacement for the
apache: NCSA HTTP server. It fixes numerous bugs in the NCSA server and
apache: includes many frequently requested new features, and has an API which
apache: allows it to be extended to meet users' needs more easily.
apache:
apache: Apache is the most popular web server in the known universe; over
apache: half of the servers on the Internet are running Apache or one of
apache: its variants.
apache:
Remember not to go outside a "Handy ruler" with package description. In the first line you should write a package name with a short description in brackets, then a break line and the proper descripion in the next line. doinst.sh file contains a script that most often creats links to the libraries and checks if configuration files were changed. A new group or user is often added in this script. An example of file content:
{tu hash}!/bin/sh
config() {
NEW="$1"
OLD="`dirname $NEW`/`basename $NEW .new`"
{tu hash} If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
rm $NEW
fi
{tu hash} Otherwise, we leave the .new copy for the admin to consider...
}
config etc/rc.d/rc.apache.new
config etc/apache/access.conf.new
config etc/apache/httpd.conf.new
config etc/apache/magic.new
config etc/apache/mime.types.new
config etc/apache/srm.conf.new
rm -f etc/rc.d/rc.apache.new
( cd usr/lib ; rm -rf libmm.so )
( cd usr/lib ; ln -sf libmm.so.13.0.20 libmm.so )
( cd usr/lib ; rm -rf libmm.so.13 )
( cd usr/lib ; ln -sf libmm.so.13.0.20 libmm.so.13 )
preinst.sh file is a script, that is executed before the package installation (e.g. to switch any service off).
An example content:
- !/bin/sh
if [ -x /etc/rc.d/rc.apache ]; then sh /etc/rc.d/rc.apache stop &>/dev/null fi
postinst.sh file is a script, that is executed after the package installation and before its removal. You can place an option of adding or deleting a user/group here.
If the package stopped a server/process before the installation, here is the right place to switch the server back on. This file contains two functions: afterinstall and beforeremove. Within these functions you place the code before the package is removed (beforeremove) and after it is installed (afterinstall).
An example of file content:
{tu hash}!/bin/sh
afterinstall(){
if [ -x /etc/rc.d/rc.apache ]; then
sh /etc/rc.d/rc.apache start &>/dev/null
fi
}
beforeremove(){
if [ -x /etc/rc.d/rc.apache ]; then
sh /etc/rc.d/rc.apache stop &>/dev/null
fi
}
case "$1" in
'--afterinstall')
afterinstall
'--beforeremove')
beforeremove
- )
esac
Package creation
When the program is compiled, use a command make install DESTDIR=/$path_to_a_temporary_folder, where $path_to_a_temporary_folder variable describes a working folder, where the package will be created.
When you have done this, place all the earlier prepared files in install folder, set up file permissions and adequately strip binaries (it is the best to do the following in a working folder):
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
The last thing to do is to enter a working folder and to create a package by using a makepkg command.
The program will ask you whether to place in doinst.sh file any symbolic links found. Always confirm it as links should not be located in the catalogue tree. Remember about a suitable package name! The name usually starts with a lowercase letter and looks like this:
{package-name}-{program version}-{structure}-{package version}.tgz
The package name should not contain more than two hyphens, program version must not contain hyphens, the structure should be determined taking into consideration the flag used earlier - march, if the program would work on 486 than write i486. Package version is set up to 1 by default, change it when you pack your program once again in the same version and you want to distinguish between a newer package and the older one. NEVER IGNORE DATE FOUND IN build FILE AND PACKAGE VERSION !!!
If you follow the above instructions and use your brain while creating a package, you will get a good package ready to be shared with other users:)
