Difference between revisions of "Makepkg"

From ArchWiki
Jump to: navigation, search
m
m (Building a Package: fixing gaps)
Line 63: Line 63:
  
 
  pacman -U rufus-0.7.0-1.pkg.tar.gz
 
  pacman -U rufus-0.7.0-1.pkg.tar.gz
 
 
  
 
=== [[ABS - The Arch Build System]] ===
 
=== [[ABS - The Arch Build System]] ===

Revision as of 20:28, 1 November 2009

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

makepkg is used for compiling your own packages suitable for Pacman to use. It uses a script-based build system which can download and validate source files, check dependencies, configure build time settings, compile the sources, install into a temporary root, make customizations, generate meta-info and package the whole thing up.

Setting Things Up

Makepkg

If you want to be able to install dependencies with makepkg as user (with makepkg -s, see below) you need to install sudo and add yourself to /etc/sudoers:

USER_NAME    ALL=(ALL)    NOPASSWD: /usr/bin/pacman

The above will negate the need to enter a password with pacman. See the Sudo wiki for detailed information.

Next you need to decide where you want your finished packages to be placed, for instance you could have them under your home directory under a separate folder. You can also skip this step, and your packages will be created in the same directory where you've started makepkg.

Create the directory:

mkdir /home/$USER/packages

Then modify the PKGDEST variable in /etc/makepkg.conf accordingly.

While you're at it, you could also have a look at the other values in makepkg.conf. For example, you could edit PACKAGER, or remove the ! from docs in the default OPTIONS array, in case you don't want the /usr/share/doc/<package> directory to be deleted by makepkg. See Makepkg.conf for more.

Building a Package

Before you continue, make sure you have the base-devel group installed. Packages belonging to this group are not required to be listed as dependencies in PKGBUILD files. You can install the base-devel group by issuing (as root):

pacman -Sy base-devel
Warning: Remember this before complaining about missing (make)dependencies. The "base" group is assumed already installed in all Arch setups . The group "base-devel" is assumed already installed when building with makepkg .

To build a package you either need to create one as described at "Building Packages in Arch Linux", or obtain one from AUR or ABS (see above) or some other source. You should be careful where you obtain your packages from and only install those from people and sources you trust.

Say you found an excellent package on AUR that you wanted to build and install (in this example we will use "rufus", a Python based bit torrent client). You can obtain the PKGBUILD and all files needed from its AUR page, click on the "Tarball" link.

cd /path/to/file
tar -zxf rufus.tar.gz
cd rufus

You will notice there are a number of files located under this directory, including the PKGBUILD script that is used to build your package. To build this package just issue (as your normal user):

makepkg

which will then set up, download and attempt to build your package. If you don't have all the required dependencies installed, makepkg will warn you before failing. To build your package and install these dependencies, simply use the command:

makepkg -s

Note that these dependences will need to be in your configured repositories. Alternatively, you can manually download the packages first using pacman -Sy dep1 dep2 etc.

Once you have satisfied all the dependencies and your package builds successfully you should now have the rufus-0.7.0-1.pkg.tar.gz file in the directory you run makepkg in. To install it (as the root user) issue:

pacman -U rufus-0.7.0-1.pkg.tar.gz

ABS - The Arch Build System

Note that you do not need abs installed to use makepkg. Makepkg comes with pacman and is used to build packages from PKGBUILDs. The ABS system is just the full tree of PKGBUILDs used to build the binary packages in the official Arch Linux repositories. If you only want to build a few packages, there are other tools available to retrieve individual PKGBUILDs and local source files such as pbget.

First make sure you have all the necessary tools installed in order to run abs/makepkg and to actually compile software from their sources:

pacman -Sy base-devel
pacman -S abs

Answer 'Y' or just press Enter.

You could now run abs to fetch all the PKGBUILDs and associated files from which the original Arch packages are being built:

abs

That will recreate an SVN hierarchy of the repos under /var/abs on your hard drive. By default some repositories are disabled; you'd have to edit /etc/abs.conf first and remove the exclamation marks.

Create a build directory. Example:

$ mkdir ~/abs

Installing from buildscripts

Sometimes from 3rd party repos we get *.pkgbuild file only. In that case use:

$ makepkg -p <file>


Congratulations! You now have successfully installed your own package!

Useful Links