• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

[HOWTO] Create packages

Recommended Posts

ujjwal    0

How to create packages from source compiled software in Linux/Unix

Most users of linux systems will have encountered software that are provided as their source code, and which use a Makefile to automate their build and install process. Now, the problem with this is that uninstalling the software is not so easy, especially if you have deleted the source code directory. It would require hunting and deleting each file manually. Easy enough when the whole software is a single binary, not so trivial if it contains several libraries, shared files, man pages and binaries.

So here are three methods which will create a package out of the compiled binaries, which can be installed/uninstalled at will.

1. checkinstall

This is a very convenient and useful tool which will keep track of all files installed by "make install" (or any other install script), and will create a Slackware tgz, Debian, or RPM package out of them. Get more information, and the program itself, here.

2. GNU Source Installer

Although this does not create native packages for your distribution (it keeps its own index of installed software), it provides a very easy way to keep track of and uninstall source packages. I have not used this program personally, but I have heard a lot of good stuff about it. Get it here.

3. The scratch method

This last method is tougher and requires some experience of the unix command line. As a trade off, it is more flexible in some ways. Like checkinstall, it will create a package for your distribution, which will be integrated with the rest of your official and unofficial packages.

This method basically will install the files in a temporary directory (say /tmp/pkg) which can later be converted into a package for your distribution. If the files were to go into /usr/local, now they would be placed in /tmp/pkg/usr/local/.

So, here we go ...

1. Compile the software, which can usually done by typing "./configure" followed by "make".

2. Instead of running "make install", type -

make DESTDIR=/tmp/pkg/ install

This should carried out as root user, to make sure that all the files created are owned by root.

3. Check that the directory /tmp/pkg contains the relevant files in their correct locations.

4. Convert the directory /tmp/pkg to a package for your distribution. Here are ways to create popular package formats -

Slackware (tgz) - cd to /tmp/pkg and run "makepkg [name_of_package.tgz]". Read "man makepkg" for more info.

RPM - http://erizo.ucdavis.edu/~dmk/notes/RPMs/Creating_RPMs.html

Debian - http://www.tldp.org/HOWTO/html_single/Debi...-Building-HOWTO

Arch Linux - The Arch Build System does exactly this, in a very elegant manner. Read the Arch package making HOW TO for details - http://wiki.archlinux.org/index.php/The_Ar...with_guidelines

Notes -

1. Not all makefiles recognise the variable DESTDIR. In this case, you will have to look through the file "Makefile" present in the main source directory, and look about for anything that could be changed for the purpose. A variable "prefix" is also very commonly used, this controls the exact location of the files to be installed (/usr/local is used by default in most cases), so running

make prefix=/tmp/pkg/usr/local/ install

should give the same result.

In case you don't find either variable, search the file for /usr/local (or whatever location the software was to be installed to) and change its occurance to /tmp/pkg/usr/local. This should be done after compiling the program with "make".

2. Of course, all this could have been avoided by simple running the configure script with /tmp/pkg/usr/local as the install location. The problem is that this location would be coded into the binary files, and hence, even after you copy the files to their final location, the binaries would still be looking in /tmp/pkg for some data.

3. If you want to run the make install process as a non-root user, do so, but remember to chown the ownership of all files in /tmp/pkg to root. Basically, you will have to run -

chown -R root:root /tmp/pkg

View HTML version of article

Edited by ujjwal

Share this post


Link to post
Share on other sites
kevcart3    0

Very nice guide, I've kinda wondered how to do this myself, I will try it sometime when I have some software to install :)

Share this post


Link to post
Share on other sites
markjensen    101

In my years of using Linux, I think I have only had to do this maybe once or twice. It is good to have here as a reference (even though knowledgable *nixers will think this is basic).

Maybe one day I will get into compiling things from tarballs...

Share this post


Link to post
Share on other sites
kevcart3    0
In my years of using Linux, I think I have only had to do this maybe once or twice.  It is good to have here as a reference (even though knowledgable *nixers will think this is basic).

Maybe one day I will get into compiling things from tarballs...

586592205[/snapback]

Even though some users may see it as basic, (i've been using linux for a while) I have never had a use for it, so I never learned it. ( :blush: ) I usually just compile from source.

Share this post


Link to post
Share on other sites
ujjwal    0

Hey Mark, yes this guide was meant for newer users, but those who know/can learn how to compile software from source. Yes, installing a binary package is always more convenient, and generally a better idea (especially if you use debian, with its thousands of packages), but then there is always the advantage of being able to customise some aspects of the program by recompiling it. And if, like me, you scavenge after lesser known software on freshmeat and sourceforge, it becomes necessary to compile them to get them running ;)

I was basically looking for something like the third method sometime back, and found the best answer only when I tried arch linux. After realising how the makepkg process worked in arch, I tried it out with other distro's/package managements, and hence this guide, for anyone interested blush.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.