Code Monkey home page Code Monkey logo

lintpkg's Introduction

lintpkg

About

lintpkg is a tool for checking common errors in slackware packages. It can be used for example to test downloaded packages for common packaging mistakes, or to check a package you created yourself for things you might have missed. By default all available checks are performed, but specific checks can be performed using command line parameters.

lintpkg is heavily based on rpmlint and tries to keep compatibility to it where possible in order to make integration into CI systems that already support rpmlint simple. It does however also try to keep close to the other pkgtools of slackware.

Install

At this point there is no install script provided as it's not really necessary. lintpkg will look for checks by default in one of two locations:

  • /usr/share/lintpkg as a global location
  • a "checks" directory within the same directory as the "lintpkg" script

Alternatively you can tell lintpkg to use checks from a different location using

lintpkg --checkdir /path/to/checks

Checks

Currently lintpkg ships with a small set of checks:

  • Binaries in wrong architecture paths (architecture_check)
  • Directories that should not be used for packages (disallowed_dirs_check)
  • Icon theme cache update in doinst.sh (icon_check)
  • Correct path for and compression of info pages (info_check)
  • Correct path for and compression of man pages (man_check)
  • Correct folder permissions under /usr and /etc (permissions_check)
  • Correct formatting of the slack-desc file (slack_desc_check)
  • Existence of an /install directory within the package (install_dir_check)
  • Correct ownership of system directories (ownership_check)
  • Leftover symlinks in the package, not handled by doinst.sh (symlink_check)
  • Package created with tar-1.13 (tar113_check)
  • Unstripped binaries (unstripped_binaries_check)
  • Binaries under /usr/share (usr_share_check)
  • Valid libtool archives (shared_libraries_check)

More checks and comments on existing ones welcome :)

Return codes

Depending on the result of the checks lintpkg will return with different exit codes:

  • 0: No errors
  • 1: Unspecified error
  • 64: One or more error/warning messages are printed

Writing checks

Writing checks is intentionally kept rather simple. A check needs to provide two functions:

check()

The check() function performs the actual tests that should be performed on the package. All necessary information is available in global variables:

  • $WORKING_DIR - This is the location of the uncompressed package content
  • $PKG_FULLNAME - This is the full name of the package, sans the file extension
  • $PKG_NAME - This is the name of the package
  • $PKG_VERSION - This is the version of the package
  • $PKG_ARCH - This is the architecture the package was built for
  • $PKG_BUILD - This is the build number of the package
  • $PKG_EXTENSION - This is the compression format used by the package
  • $PKG_LISTING - This contains a list of all files and folders contained in the package
  • $PKG_DETAILED_LISTING - This contains a list of all files and folders contained in the package, including ownership and permission information

Additionally there are several functions one can use for reporting issues. All of these take variable arguments, where the first is the messageid of the issue, and any further argument is additional optional information. Most commonly the first additional argument (so the second argument over all) would be the name of the offending file.

  • log_error() logs an issue as an error.
  • log_warning() logs an issue as a warning.
  • log_notice() logs an issue as a notice.

info()

The info() function is used for providing detailed information on the issues that the check() function can raise. It's only argument is the messageid of an issue.

lintpkg's People

Contributors

idlemoor avatar pprkut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lintpkg's Issues

Run testsuite with GitHub Actions

It would be nice if we could run the testsuite with GitHub Actions. The challenge here is that (by default) GitHub Actions run on ubuntu. Running on Slackware would require a custom runner being hosted somewhere.
We can investigate, however, if we can get all the required dependencies available on a ubuntu system (pkgtools, primarily).
Another alternative would be trying to run the testsuite inside a Slackware docker container.

lintpkg does not take relative paths as argument

but I inserted one line and now it does:

--- lintpkg.orig 2017-01-20 12:15:41.699471760 +0000
+++ lintpkg 2017-01-20 13:19:24.493022010 +0000
@@ -437,6 +437,7 @@
PKG_LISTING=$(cat $PACKAGE | $packagecompression -dc | $TAR ts)
PKG_DETAILED_LISTING=$(cat $PACKAGE | $packagecompression -dc | $TAR tvs)

  • PACKAGE=$( realpath $PACKAGE )
    cd $WORKING_DIR

    ( umask 000 ; cat $PACKAGE | $packagecompression -dc | $TAR xf - 2> /dev/null )

typo

Should be 'Existence' in README.md at 'Existance of an /install directory ...'

Support package specific overrides

Not every rule is going to be universally applicable. There will always be room for exceptions. However, coding these exceptions directly into the lint checks isn't going to scale very well and may very well impact performance.
Instead, a way to let lintpkg know that a certain warning/error is not applicable is preferable. Still, they shouldn't be hidden completely. There should still be a way to see those warnings/errors, if one wants.

The override functionality from lintian is a pretty close match to that behavior. The idea would be to introduce a /usr/share/lintpkg/overrides directory holding override information per package. The content of such a file would look like this:

# Binary needs to retain debugging info to be useful:
foo: unstripped-binary /usr/bin/foo 

As a start, every file affected should be listed. We can introduce support for wildcards later.

Sync with latest pkgtools

Incorporate the changes to pkgtools from pkgtools 15.0 (and newer). Most importantly:

  • Change meaning of .tlz to tar.lz (lzip)
  • If possible, use multiple decompression threads.
  • Use recent tar, and support restoring POSIX ACLs and extended attributes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.