Makepkg
From ArchWiki
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, build the package, install the package into a temporary root, make customizations, generate meta-info and package the whole thing up. As you can see makepkg has a lot of features, the basics of which are described below.
Contents |
[edit] Setting Things Up
[edit] ABS - The Arch Build System
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
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.
As /var/abs is normally owned by root (it's part of the 'filesystem' package) and most people and guides assume for you to build packages inside /var/abs/local, you need to allow your user to access it:
groupadd abs gpasswd -a $USER abs chown root:abs /var/abs/local chmod 775 /var/abs/local
[edit] 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.
[edit] Building a Package
To build a package you either need to create one as described at "The Arch package making HOWTO", 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
Congratulations! You now have successfully installed your own package!