Welcome to the most active Linux Forum on the web.
Go Back > Blogs > ErV
User Name


Rating: 4 votes, 4.00 average.

Howto: making slackware packages from source without slackbuilds

Posted 12-30-2008 at 06:33 PM by ErV
Updated 02-21-2009 at 08:50 AM by ErV

[SIZE="5"][b]Making slackware packages from source[/b][/SIZE]

I'm posting this because some people have problems with making packages from source code, and howto where I learned how to do it isn't available anymore.

1) howto is pretty short and doesn't dive into details too much (although I initially thought about overview of commonly used build systems).
2) This doesn't work for all packages, only for most of them. Method is not universal
3) This stuff is written for people that don't like Slackbuilds, or want to compile software without slackbuild. If you simply want to install program as fast as possible, search for compiled package on [url][/url], or search for slackbuild on [url][/url].

This method will work only if following conditions are met:
1) program package contains ./configure script.
2) Makefile produced by ./configure contains word [i]DESTDIR[/i] (case-sensitive).
Seems pretty restrictive, but, fortunately, this covers 95% of all available linux software.

If there is no ./configure, or makefile doesn't have "DESTDIR" inside, this will not work. (there are exceptions from that rule, of course, but explaing them will take too much space)

[SIZE="4"][b]Short explanation[/b][/SIZE]
In this example I assume that we have extracted our package, and right now are within source code directory, where ./configure script is located. In example our program has name "programname" and version "programversion". When compiling your own package, replace "programname" and "programversion" with values you need.

Most software can be turned into slackware package using this sequence:
1) ./configure
2) make
3) mkdir pkg
4) make DESTDIR=`pwd`/pkg install
5) cd pkg
6) su
7) makepkg programname-programversion-1xyz.tgz
8) chown [color=red]me[/color].users ./programname-programversion-1xyz.tgz (instead of "me" use your user name)
9) mv ./programname-programversion-1xyz.tgz ..
10) cd ..
11) rm -r pkg
12) Ctrl+D (exits "su")

If package meets requirements mentioned before, this sequence will create slackware package for you.

[SIZE="4"][b]How it works[/b][/SIZE]
1) "./configure" - configures package according to our system.
2) "make" - compiles package.
3) "mkdir pkg" - creates directory called "pkg" within same directory where ./configure is located. This "pkg" directory will be used to
store files that will be put into package.
4) "make DESTDIR=`pwd`/pkg install":
This tells to the "make" command to install package as if "pkg" subdirectory (that we created in current directory) were root "/" folder.
"`pwd`" inserts output of "pwd" command into current command line. DESTDIR is a variable used inside makefile. DESTDIR specify the root of installations, and because GNU make allows to override some variables during compilation, we can change it, and say that "pkg" subdirectory is a root of installation.
5) "cd pkg" we are going into "pkg" subdirectory.
6) "su" (enter password here) - changing privilegies to root, because makepkg (which is used to create packages) won't work with other privilegies.
7) "makepkg programname-programversion-1xyz.tgz" This creates slackware package [b][i]without description[/i][/b]. Answer "yes" to all questions (well, unless it doesn't suit your needs). Also, notice "1xyz" part of the filename instead of numbers. When you build custom packages, you need to be able to distinguish them from stock packages. To do that, instead of standard numbers numbers, use custom signature, something like "1abc", "2abc", etc. Use whatever combination you want (I use number + my nickname), as long as you can distinguish your package from packages made by other people.
8) "chown me.users ./programname-programversion-1xyz.tgz" Created package has "root.root" owner. If we want to be able later to move it somewhere, we need to change owner to our user ID.
9) "mv ./programname-programversion-1xyz.tgz .." We are moving our package into the source directory - i.e. one level up.
10) "cd .." Going one level up. (back into directory with "configure")
11) "rm -r pkg" we are cleaning up and removing our pkg subdirectory.
12) "Ctrl+D" - this equivalent to "exit" command which ends "su" session.

Now you have your slackware package.
If something doesn't work, or you don't understand something, ask it on slackware forums.

Hope this will be useful.
Posted in Uncategorized
Views 9748 Comments 0
« Prev     Main     Next »


All times are GMT -5. The time now is 06:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration