This article is outdated. See Slackware package management for a newer version.
Creating a Slackware isn't a hard job. In contrast to rpm or deb it is very easy. In this article I will show you how to compile a small (but very cool) piece of software, how to create a appropiate directory structure and finally how to create a Slackware package that you can install and remove with the default tools installpkg and removepkg. To show you how to create a Slackware package I will use Lua but you can use what ever you want. Lua is a very small and easy to compile piece of software and should work out of the box. First get the software:
# cd /usr/src
# wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
...
Then extract the source and change into the new directory:
# tar xf lua-5.1.4.tar.gz
# cd lua-5.1.4
Now build the software using make but don't install it:
# make linux
...
In the src directory you have a couple of files which are more less important: two binaries (lua and luac), headers (lua.h, luaconf.h, lualib.h and lauxlib.h), a library (liblua.a) and two man pages for lua and luac (lua.1 and luac.1). The next thing you have to do is to create a directory structure that fits your system. Binaries are stored under /usr/bin, headers under /usr/include, libraries under /usr/lib and man pages under /usr/man:
# mkdir -p /usr/src/build/usr/bin
# mkdir -p /usr/src/build/usr/include
# mkdir -p /usr/src/build/usr/lib
# mkdir -p /usr/src/build/usr/man/man1
# mkdir -p /usr/src/build/install
The above commands will create a reduced layout of your systems directories under /usr/src/build. The install directory will be used later. Now copy all files to the right directory. Binaries into /usr/src/build/usr/bin, headers into /usr/src/build/usr/include and so on:
# cd /usr/src/lua-5.1.4
# cp src/lua src/luac /usr/src/build/usr/bin
# cp src/lua.h src/luaconf.h src/lualib.h src/lauxlib.h /usr/src/build/usr/include
# cp src/liblua.a /usr/src/build/usr/lib
# cp doc/lua.1 doc/luac.1 /usr/src/build/usr/man/man1
Now check that everything is at it's desired directory (tree is still one of my favorite tools):
# tree /usr/src/build
/usr/src/build
|-- install
`-- usr
|-- bin
| |-- lua
| `-- luac
|-- include
| |-- lauxlib.h
| |-- lua.h
| |-- luaconf.h
| `-- lualib.h
|-- lib
| `-- liblua.a
`-- man
`-- man1
|-- lua.1
`-- luac.1
Now go into the unused install directory. Next you have to create a so called slack-desc file which holds the description while installing a Slackware package. It could look like this (the original file was taken from the ppp package and all texts are from http://www.lua.org/about.html):
# cd /usr/src/build/install
# vi slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
lua: lua (a powerful, fast, lightweight, embeddable scripting language)
lua:
lua: Lua combines simple procedural syntax with powerful data description
lua: constructs based on associative arrays and extensible semantics. Lua
lua: is dynamically typed, runs by interpreting bytecode for a
lua: register-based virtual machine, and has automatic memory management
lua: with incremental garbage collection, making it ideal for
lua: configuration, scripting, and rapid prototyping.
lua:
lua:
lua:
Save the file and leave your editor. Finally create the package:
# cd /usr/src/build
# makepkg -l y -c n /tmp/lua-5.1.4-i486-1.txz
That's it. You can install the package now:
# installpkg /tmp/lua-5.1.4-i486-1.txz
Verifying package lua-5.1.4-i486-1.txz.
Installing package lua-5.1.4-i486-1.txz:
PACKAGE DESCRIPTION:
# lua (a powerful, fast, lightweight, embeddable scripting language)
#
# Lua combines simple procedural syntax with powerful data description
# constructs based on associative arrays and extensible semantics. Lua
# is dynamically typed, runs by interpreting bytecode for a
# register-based virtual machine, and has automatic memory management
# with incremental garbage collection, making it ideal for
# configuration, scripting, and rapid prototyping.
#
Package lua-5.1.4-i486-1.txz installed.
For testing purpose run lua:
# lua
lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> print "Hello World"
Hello World
> ^D
And remove the package (if necessary):
# removepkg lua
Removing package /var/log/packages/lua-5.1.4-i486-1...
Removing files:
--> Deleting /usr/bin/lua
--> Deleting /usr/bin/luac
...
As you can see creating packages for Slackware is real easy. The above shows only some basics.
No comments:
Post a Comment