Originally posted on linuxquestions.org by me.
This article describes how to build software packages for slackware linux from source code.
It is not easiest method, but it is useful for quick package creation.
If you simply want to install software, and do not want to compile it, then either download precompiled packages from www.linuxpackages.net, or get slackbuild from www.slackbuilds.org. Another option is to use src2pkg utility or checkinstall (but checkinstall is mostly broken since Slackware 11.0).
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.
WARNING!:
- howto is pretty short and doesn't dive into details too much (although I initially thought about overview of commonly used build systems).
- This doesn't work for all packages, only for most of them. Method is not universal
- 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 www.linuxpackages.net, or search for slackbuild on www.slackbuilds.org.
This method will work only if following conditions are met:
- program package contains ./configure script.
- Makefile produced by ./configure contains word DESTDIR (case-sensitive).
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)
Short explanation
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:
- ./configure
- make
- mkdir pkg
- make DESTDIR=`pwd`/pkg install
- cd pkg
- su
- makepkg programname-programversion-1xyz.tgz
- chown me.users ./programname-programversion-1xyz.tgz (instead of "me" use your user name)
- mv ./programname-programversion-1xyz.tgz ..
- cd ..
- rm -r pkg
- Ctrl+D (exits "su")
If package meets requirements mentioned before, this sequence will create slackware package for you.
How it works
- "./configure" - configures package according to our system.
- "make" - compiles package.
- "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. - "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. - "cd pkg" we are going into "pkg" subdirectory.
- "su" (enter password here) - changing privilegies to root, because makepkg (which is used to create packages) won't work with other privilegies.
- "makepkg programname-programversion-1xyz.tgz" This creates slackware package without description. 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.
- "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.
- "mv ./programname-programversion-1xyz.tgz .." We are moving our package into the source directory - i.e. one level up.
- "cd .." Going one level up. (back into directory with "configure")
- "rm -r pkg" we are cleaning up and removing our pkg subdirectory.
- "Ctrl+D" - this equivalent to "exit" command which ends "su" session.
Done
Now you have your slackware package.
If something doesn't work, or you don't understand something, ask it on slackware forums.
Few Notes
Package created this way normally will end in "/usr/local" instead of "/usr". This is because "/usr/local" is default location for user-built packages. "/usr/local/" is fine if you are creating packages for yourself, but, for example, linuxpackages.net rejects packages that are not in "/usr". So if you want to distribute your packages, or submit them to linucpackages.net, then change installation location from "/usr/local" to "/usr" using --prefix configure option.
No comments:
Post a Comment