2

From Arch Wiki:

Packages in Arch Linux are built using the makepkg utility. When makepkg is run, it searches for a PKGBUILD file in the current directory and follows the instructions therein to either compile or otherwise acquire the files to build a package archive (pkgname.pkg.tar.xz). The resulting package contains binary files and installation instructions, readily installable with pacman.

Make is a GNU utility that is used to build and install packages from source and to do so it searches for a makefile in the appropriate directory which feeds in the requiured inputs to make.

So makepkg is used to make pacman installable binaries and optionally makepkg -si can resolve dependencies(mainly used for AUR packages). Is the difference just in this dependency resolution and pacman specific stuff? It is just automation of stuff which could be manually done by make but on every distro.

Am I correct? Sorry if this is a dumb question.

1 Answer 1

5

TL;DR

Advantages of makepkg over make:

  • Abstracts the build system (make, configure, cmake, qmake, npm, pybuild, ninja, pybuild)
  • Manages dependencies (build & runtime)
  • Creates package which can be distributed or installed
  • Allows distro-specific patches or configurations
  • Supports installation/uninstallation/upgrade scripts
  • Tracks files on system so you know why a specific file has been installed (who owns it)
  • Makes uninstallation easier.
  • Makes upgrades easier (renamed files in source package will not leave orphans, scripts can safely migrate databases).

--verbose

make will execute a MakeFile in the current directory, building required targets. make install will attempt to install those targets into DESTDIR.

makepkg -i builds based on the rules of PKGBUILD. This could be:

configure
make
make install DESTDIR=/usr

or

cmake .
cmake --build . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
ctest .
cmake --build . --target=install

or any of

cargo build --release
npm --build
pybuild
qmake
...

There are lots of build systems. make is only one of them, and is often only a part of one (e.g. autoconf). PKGBUILD is a nice way so that arch package users (or build machines) can use a single command (makepkg) without the need to know anything about the build system. It's meant to define how to build a package instead of how to build the sources.

PKGBUILD also gives the opportunity to define build-dependencies or runtime dependencies. This means if you need cmake to build a package, it will be automatically installed (if -s is specified) and automatically removed (if -r is specified). If your package depends on python3, then it will ensure that python3 is installed on your system automatically.

PKGBUILD also gives the possibility for Arch maintainers to add their own patches/customizations to original source packages. If a upstream package installs a library executable to /usr/lib/, but Arch's standards would rather have these in /usr/libexec/, then the PKGBUILD file allows these kind of customizations.


If you don't use the -i option, makepkg does not try to install the build. Instead the output is a .tar.xz file which could be uploaded to an archive and installed by other users with pacman. This is how the official arch repositories work.

Arch developers will write PKGBUILD files, then build machines will parse those files, build packages, and upload them to the official repository so that you can use pacman to download/install them.


Another advantage of using makepkg over make install is that your package manager keeps an index of what is installed, where, and which version. This means if you ever have a question about why a file is on your system, you should be able to query the package manager who will tell you which package "owns" the file and which version it is. When you uninstall the package, the package manager knows of all files so that it doesn't leave anything orphaned. When you upgrade your package, the package manager knows which files to replace/rename/delete during the installation and may also run a script or two to ensure that things migrate smoothly.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .