pkgcheck - User Guide
Version 0.06
1. Overview
1.1. What is pkgcheck?
pkgcheck is a program to check the sanity of a Slackware package. This should be done in two situations:
- before submitting a package to LinuxPackages or passing a self-build package to somebody else
- before installing a package created by somebody else, as an incorrectly fomatted package can compromise the stability of your system.
As pkgcheck does some checks against the current system, the results may actually be different for a same package on two different computers. Therefore, you must not rely on a check having been done on the building system - always check the package on the system where it is about to be installed.
I wrote this progran before starting to create my own SlackBuilds, which is the recommended way of creating Slackware packages, by gathering the requirements from different sources. Not being an expert at it means that the program is certainly incomplete; nevertheless, it's a starting point.
1.2. Technical requirements
pkgcheck is written in Python and needs a Python interpreter, version 2.4 or above. It has been developped and tested on Slackware 10.1 and 10.2 installations.
1.3. Installation
pkgcheck comes as a Slackware package and is installed via the installpkg
or upgradepkg
commands. If you are not familiar with these commands, have a look at the corresponding chapter in Slackware Linux Essentials
1.4. Known limitations
None so far, except from being incomplete :-)
1.5. Feedback
Please feel free to send your feedback to <uselpa (a) gmail com>. I welcome all comments and will try to enhance this software as much as possible. If you request changes, additions or corrections, please send an example package along with your mail so that I can test the corrections on the specific case.
1.6. License
pkgcheck is licensed according to the GPL.
1.7. Download
from my website or from linuxpackages.net
2. Errorlevels
2.1. Semantic errorlevels
- "none" (level 0) : messages with this errorlevel are not displayed (and checks not performed)
- "info" (level 1) : purely informational
- "Warn" (level 2) : a probable error - needs investigation
- "ERR" (level 3) : improper package
2.2. Technical errorlevels
- "?" (level 4) : an undefined error, this is due to an error in the configuration files (see below)
- "*KO*" (level 5) messages did not allow pkgcheck to continue its analysis
2.3. Configuration files
Each check that pkgcheck knows of is associated with an errorlevel. Semantic errorlevels are defined in configuration files, whereas technical errorlevels are internal errorlevels that cannot be changed by the user.
A configuration file is a text file that associates a check with an errorlevel. Checks have an error code and a default errorlevel, and are indicated in the form {errorcode : errorlevel} in the rest of this document. The default configuration file is /etc/slackpkg/default.conf
and is automatically read at startup.
If the default values do not make sense in your particular context, you can use custom configuration files. Create /etc/slackpkg/<configname>.conf
or ~/slackpkg/<configname>.conf
based on default.conf, modifying the errorlevels to suit your needs. To use a different configuration, add the -c <configname>
switch at startup.
If pkgcheck finds both /etc/slackpkg/<configname>.conf
and ~/slackpkg/<configname>.conf
, both will be read in sequence. If multiple definitions are found for the same error, the last definition will be kept.
3. Performed checks
3.1. Package name
- must end in
.tgz
{pkgtgz : ERR}
- must have a name-version-arch-build structure; name may contain dashes {pkgnvab : KO}
- "architecture" must be {arch? : WARN}
- "i486", "i586" and "i686" (classic 32-bit Intel processors)
- "x86_64" (AMD 64-bit processors as used by Slamd64)
- "s390" (Slack/390 port to IBM Mainframes)
- "noarch" (packages which are not processor-bound, i.e. scripting languages and documentation)
- An information message is given if architecture "i386" is used {arch386 : INFO}. "i386" is considered obsolete, but there are still a lot of packages in the Slackware distro itself that are labelled this way.
3.2. Required files
- ./ must exist {-./ : ERR} and have permissions 755 {perm/ : ERR}
- install/slack-desc
- Each package must have an install/slack-desc file which is used to describe the package in the package database (/var/log/packages) {-i/sdesc : ERR}.
- A slack-desc file must contain between 1 and 13 lines that start with "packagename: " {sd11 : WARN}, and the text after this prefix must be at max. 70 characters {sd2long : WARN}.
3.3. Optional files
- install/slack-required: optional but useful dependency information used by tools like slapt-get {-i/req : INFO}
- the user documentation in usr/doc/"name"-"version" or usr/share/doc/"name"-"version": the directory should exist {-docdir : INFO}, and contain at least a README {-README : INFO} and a COPYING {-COPYING : INFO} file
- install/doinst {-i/doinst : NONE}, install/slack-conflicts {-i/sconfl : NONE} and install/slack-suggests {-i/ssugg : NONE}
3.4. Files that should not be in the package
- usr/info/dir: the GNU info system index {+uidir : WARN}
- files that go into the usr/local directory {local : WARN}
3.5. Permissions
- SUID {suid : WARN} , SGID {sgid : WARN} and sticky bits {sticky : WARN} are reported
- objects writable by group {wrtgrp : WARN} or others {wrtoth : WARN} are reported
- permissions where a group have more rights than the owner has, or when others have more rights than the group are considered "illogical" {modill : WARN}
- all objects should be owned by root {u-root : WARN}
- all objects should have group root {g-root : WARN} or bin {g-bin : WARN} depending on their location
- files in bin directories should be executable
3.6. Existing objects
- if the object already exists, check that permission bits {xmode : WARN}, uid {xuid : WARN} and gid {xgid : WARN} are the same; this is especially important for top-level directories (/, /usr, /var ...)
- if it's a file under /etc, warn that the file will be overwritten (provided it has changed) {xover : WARN}
3.7. Various
- LinuxPackages is a central place for Slackware packages. Packages can be hosted there up until 5MB. pkgcheck will inform you if your package is too large to be hosted by them {pkglarge : INFO}
- man {man-zip : INFO} and info {info-zip : INFO} files should be gzipped
- wrong man file names are reported {manname : WARN}
- ELF executables and shared libraries should be stripped {-stripped : INFO}
- empty directories are reported {edir : INFO}
- symlinks {symlnk : INFO} and hardlinks {hardlnk : INFO} are reported
- duplicate directories are reported {dupdir : ERR}
- missing parent directories are reported {parent : ERR}
4. Usage
The basic usage form is pkgcheck <list of packages>
. To list the contexts of packages without performing any check, add the -l
option.
pkgcheck's return code will correspond to the highest error level it encountered. In order to filter out lower errorlevels, you may add the -e (n)
option, where (n) corresponds to the lowest errorlevel you want to be reported (i.e. -e 2 will suppress all info messages). On the other hand, adding -e 0
will also report messages that have been assigned to errorlevel "none".
To use a custom configuration file, add -c <configname>
.
5. Additional information
5.1. Things to keep in mind when building packages
- Always build your packages on a clean machine. Ideally, have a dedicated partition ready that you can restore to its initial state.
- The install/doinst.sh must only contain relative path names, as installpkg permits to install a package into a specified directory
5.2. Package building resources
5.2.1. Instructions for package building
5.2.2. Package creation tools
5.2.3. Package managers
6. Revision History
- 0.06 (30 oct 2006)
- added an explicit check that / is chmod 755
- added option "-s" when calling cmp in order to prevent any output
- added "diffutils" to slack-required because of /usr/bin/cmp
- added architectures 'sparc' and 'powerpc'
- added a check that files in bin directories are executable {binx}
- fixed a bug that prevented unzipped non-english man pages from being detected
- 0.05 (9 sep 2005)
- added configuration files
- added a check for hardlinks {hardlnk}
- slackdesc can be between 1 and 13 lines instead of exactly 11
- fixed a bug in {info-zip}
- normalised the labels "info","Warn","ERR"
- *KO* errorlevel is now 5 instead of 4 - 4 is used for "?" i.e. undefined errors (something you should never see). If you check the return code, keep considering >=4 as a blocking error.
- 0.04 (30 Aug 2005)
- install/doinst.sh, install/conflicts and install/suggests are no longer checked (they will be back with configuration files)
- added checks against existing objects (mode, uid and gid)
- added warning against overwriting /etc files
- 0.03
Document last updated on Sunday 30 Oct 2005 11:19:44.