In order to test what list2pkg can do, we are going to create a test
package. A testing
directory is included with list2pkg .
Among other things, it contains some dummy files that can be used to create a
package. First, cd to it.
$
cd testing
list2pkg takes two arguments: a list of the files that will belong to the package, and the package file we will create. List2pkg can also read a file list from standard input.
The format of a list is very simple: each line must contains the path to a file. This path can either be absolute (recommended) or relative to the directory from which list2pkg is invoked.
For this first example, we are going to use the list of files
in filelist
, which contains files
in src
. Feel free to look around.
$
cat filelist$
ls -lR src
Note an important detail: if directories are given in the file
list, they will not be copied recursively. This means that if
the file /home
is in your list, the package will not
contain all files from all home directories, but only an
empty /home
directory.
list2pkg does not create the slackware package directly using the files that are given in the list. Instead, it copies those files to a temporary directory, do some adjustments there, and then call makepkg, which is Slackware's standard tool for package creation. This temporary directory is called the package tree directory by list2pkg .
If the user does not specify one, list2pkg creates a temporary directory in
e.g /var/tmp
, do its stuff and then remove the
directory. If a package tree directory is given on the command line, the
package structure is created inside instead, and it is not
deleted at the end of the process.
Since you want to have a clue what is going on, we are going to use our own package tree directory.
$
mkdir treedir
Following Slackware package's convention, the file name must have several information in it: the program's name, the version, the machine it was compiled for, and the creator's name along with the build version. Each of these fields must be separated by a dash. After this, the file extension, .tgz must follow. For more information on Slackware package naming, see The Perfect Package
As an example, we will use test-0.1-noarch-2usr.tgz
as
a package name.
It's now time to run the package-creating command
$
sudo list2pkg --treedir=treedir --verbose filelist \
test-0.1-noarch-2usr.tgz
The command should finish without errors, and
a test-0.1-noarch-2usr.tgz
file should have been
created. Note that you need root privilege, because otherwise some owner and
groups information might not be saved correctly. You can check that all
files in the file list have been packed correctly (there are subtleties
related to symlinks that are explained in the section called “Tricky cases”)
$
tar --list --verbose -f test-0.1-noarch-2usr.tgz$
ls -lR treedir
Notice that an install/
directory with the necessary
files has been created automatically. A
minimalist install/slack-desc
file was created, along
with a doinst.sh
script. This file deserves special
attention. You should see some special commands between the #BEGIN:
AUTO_LIST2PKG
and #END: AUTO_LIST2PKG
comments. Here is
what mine looks like.
#BEGIN: AUTO_LIST2PKG groupadd john || (if test $? -ne 9; then exit 1; fi) useradd john || (if test $? -ne 9; then exit 1; fi) chown -v john home/john || exit 1 chgrp -v john home/john || exit 1 chmod -v 755 home/john || exit 1 chown -v john home/john/rep || exit 1 chgrp -v john home/john/rep || exit 1 chmod -v 775 home/john/rep || exit 1 chown -v john home/john/rep/list2pkg || exit 1 chgrp -v john home/john/rep/list2pkg || exit 1 chmod -v 775 home/john/rep/list2pkg || exit 1 chown -v john home/john/rep/list2pkg/testing || exit 1 chgrp -v john home/john/rep/list2pkg/testing || exit 1 chmod -v 775 home/john/rep/list2pkg/testing || exit 1 chown -v john home/john/rep/list2pkg/testing/src || exit 1 chgrp -v john home/john/rep/list2pkg/testing/src || exit 1 chmod -v 775 home/john/rep/list2pkg/testing/src || exit 1 chown -v john home/john/rep/list2pkg/testing/src/dir2 || exit 1 chgrp -v john home/john/rep/list2pkg/testing/src/dir2 || exit 1 chmod -v 775 home/john/rep/list2pkg/testing/src/dir2 || exit 1 chown -v john home/john/rep/list2pkg/testing/src/dir1 || exit 1 chgrp -v john home/john/rep/list2pkg/testing/src/dir1 || exit 1 chmod -v 775 home/john/rep/list2pkg/testing/src/dir1 || exit 1 chown -v john home/john/rep/list2pkg/testing/src/dir3 || exit 1 chgrp -v john home/john/rep/list2pkg/testing/src/dir3 || exit 1 chmod -v 775 home/john/rep/list2pkg/testing/src/dir3 || exit 1 chown -v john home/john/rep/list2pkg/testing/src/dir3/dir4 || exit 1 chgrp -v john home/john/rep/list2pkg/testing/src/dir3/dir4 || exit 1 chmod -v 775 home/john/rep/list2pkg/testing/src/dir3/dir4 || exit 1 #END: AUTO_LIST2PKG
(yes, my username is john). This script actually tries to recreate the
owners and groups of the package's file, in case they do not exist on the
target system. If you don't like this, you can use
the list2pkg.conf
file. See
the section called “Users and groups handling” for more information.