Manjaro Difference between revisions of "Makepkg/ru"

Difference between revisions of "Makepkg/ru"

From Manjaro
(Created page with "=== Выходной пакет ===")
(Updating to match new version of source page)
Line 7: Line 7:
== Конфигурация ==
== Конфигурация ==


{{ic|/etc/makepkg.conf}} - это основной конфигурационный файл для makepkg. Большинство пользователей захотят уточнить параметры конфигурации makepkg перед сборкой каких-либо пакетов.  
{{ic|/etc/makepkg.conf}} - это основной конфигурационный файл для makepkg. Большинство пользователей захотят уточнить параметры конфигурации makepkg перед сборкой каких-либо пакетов.
 
<div lang="en" dir="ltr" class="mw-content-ltr">
A user specific configuration file which takes precedence over the system wide configuration may exist in {{ic|$HOME/.makepkg.conf}}. This is important to note if using i3, cinnamon, or deepin as the manjaro-desktop-settings packages for these desktop environments automatically create the user configuration file for new users by way of {{ic|/etc/skel/.makepkg.conf}}.
</div>


=== Архитектура, флаги компиляции ===
=== Архитектура, флаги компиляции ===
Line 64: Line 68:
=== Выходной пакет ===
=== Выходной пакет ===


<div lang="en" dir="ltr" class="mw-content-ltr">
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where makepkg is run by default.
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where makepkg is run by default.
</div>


{{hc|/etc/makepkg.conf|<nowiki>
{{hc|/etc/makepkg.conf|<nowiki>
[...]
[...]


<div lang="en" dir="ltr" class="mw-content-ltr">
#########################################################################
#########################################################################
# PACKAGE OUTPUT
# PACKAGE OUTPUT
Line 83: Line 90:
#-- Packager: name/email of the person or organization building packages
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
#PACKAGER="John Doe <john@doe.com>"
</div>


[...]
[...]
</nowiki>}}
</nowiki>}}


<div lang="en" dir="ltr" class="mw-content-ltr">
For example, create the directory:
For example, create the directory:
</div>


  $ mkdir /home/$USER/packages
  $ mkdir /home/$USER/packages


<div lang="en" dir="ltr" class="mw-content-ltr">
Then modify the {{ic|PKGDEST}} variable in {{ic|/etc/makepkg.conf}} accordingly.
Then modify the {{ic|PKGDEST}} variable in {{ic|/etc/makepkg.conf}} accordingly.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The {{ic|PACKAGER}} variable will set the {{ic|packager}} value within compiled packages' {{ic|.PKGINFO}} metadata file. By default, user-compiled packages will display:
The {{ic|PACKAGER}} variable will set the {{ic|packager}} value within compiled packages' {{ic|.PKGINFO}} metadata file. By default, user-compiled packages will display:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{hc|pacman -Qi package|<nowiki>
{{hc|pacman -Qi package|<nowiki>
[...]
[...]
Line 100: Line 115:
[...]
[...]
</nowiki>}}
</nowiki>}}
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Afterwards:
Afterwards:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{hc|pacman -Qi package|<nowiki>
{{hc|pacman -Qi package|<nowiki>
[...]
[...]
Line 108: Line 127:
[...]
[...]
</nowiki>}}
</nowiki>}}
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
This is useful if multiple users will be compiling packages on a system, or you are otherwise distributing your packages to other users.
This is useful if multiple users will be compiling packages on a system, or you are otherwise distributing your packages to other users.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Signature checking ===
=== Signature checking ===
The following procedure is not necessary for compiling with makepkg, for your initial configuration proceed to [[#Usage]]. To temporarily disable signature checking call the makepkg command with the {{ic|--skippgpcheck}} option.
The following procedure is not necessary for compiling with makepkg, for your initial configuration proceed to [[#Usage]]. To temporarily disable signature checking call the makepkg command with the {{ic|--skippgpcheck}} option.
If a signature file in the form of .sig is part of the [[PKGBUILD]] source array, makepkg validates the authenticity of source files. For example, the signature pkgname-pkgver.tar.gz.sig is used to check the integrity of the file pkgname-pkgver.tar.gz with the gpg program. If desired, signatures by other developers can be manually added to the gpg keyring. Look into the [[GnuPG]] article for further information.
If a signature file in the form of .sig is part of the [[PKGBUILD]] source array, makepkg validates the authenticity of source files. For example, the signature pkgname-pkgver.tar.gz.sig is used to check the integrity of the file pkgname-pkgver.tar.gz with the gpg program. If desired, signatures by other developers can be manually added to the gpg keyring. Look into the [[GnuPG]] article for further information.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{Note|The signature checking implemented in makepkg does not use pacman's keyring. Configure gpg as explained below to allow makepkg reading pacman's keyring.}}
{{Note|The signature checking implemented in makepkg does not use pacman's keyring. Configure gpg as explained below to allow makepkg reading pacman's keyring.}}
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The gpg keys are expected to be stored in the user's {{ic|~/.gnupg/pubring.gpg}} file. In case it does not contain the given signature, makepkg shows a warning.
The gpg keys are expected to be stored in the user's {{ic|~/.gnupg/pubring.gpg}} file. In case it does not contain the given signature, makepkg shows a warning.
{{hc|makepkg|<nowiki>
{{hc|makepkg|<nowiki>
Line 136: Line 163:
</nowiki>}}
</nowiki>}}
When configured as before, the output of {{ic|gpg --list-keys}} contains a list of keyrings and developers. Now makepkg can compile AUR packages submitted by Arch Linux developers with successful signature checking.
When configured as before, the output of {{ic|gpg --list-keys}} contains a list of keyrings and developers. Now makepkg can compile AUR packages submitted by Arch Linux developers with successful signature checking.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
== Usage ==
== Usage ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Before continuing, ensure the "base-devel" group is installed. Packages belonging to this group are not required to be listed as dependencies in [[PKGBUILD]] files. Install the "base-devel" group by issuing (as root):
Before continuing, ensure the "base-devel" group is installed. Packages belonging to this group are not required to be listed as dependencies in [[PKGBUILD]] files. Install the "base-devel" group by issuing (as root):
</div>


  # pacman -S base-devel
  <div lang="en" dir="ltr" class="mw-content-ltr">
# pacman -S base-devel
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{Note|Before complaining about missing (make) dependencies, remember that the "base" group is assumed to be installed on all Manjaro Linux systems. The group "base-devel" is assumed to be installed when building with '''makepkg'''.}}
{{Note|Before complaining about missing (make) dependencies, remember that the "base" group is assumed to be installed on all Manjaro Linux systems. The group "base-devel" is assumed to be installed when building with '''makepkg'''.}}
</div>


To build a package, one must first create a [[PKGBUILD]], or build script, as described in [[Create Manjaro Packages]], or obtain one from the [https://gitlab.manjaro.org Manjaro Gitlab Repositories], [[Arch User Repository]], or some other source.  
<div lang="en" dir="ltr" class="mw-content-ltr">
To build a package, one must first create a [[PKGBUILD]], or build script, as described in [[Create Manjaro Packages]], or obtain one from the [https://gitlab.manjaro.org Manjaro Gitlab Repositories], [[Arch User Repository]], or some other source.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{Warning|Only build and/or install packages from trusted sources.}}
{{Warning|Only build and/or install packages from trusted sources.}}
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Once in possession of a {{ic|PKGBUILD}}, change to the directory where it is saved and issue the following command to build the package described by said {{ic|PKGBUILD}}:
Once in possession of a {{ic|PKGBUILD}}, change to the directory where it is saved and issue the following command to build the package described by said {{ic|PKGBUILD}}:
</div>


  $ makepkg
  $ makepkg


<div lang="en" dir="ltr" class="mw-content-ltr">
To have makepkg clean out leftover files and folders, such as files extracted to the $srcdir, add the following option. This is useful for multiple builds of the same package or updating the package version, while using the same build folder. It prevents obsolete and remnant files from carrying over to the new builds.
To have makepkg clean out leftover files and folders, such as files extracted to the $srcdir, add the following option. This is useful for multiple builds of the same package or updating the package version, while using the same build folder. It prevents obsolete and remnant files from carrying over to the new builds.
</div>


  $ makepkg -c
  $ makepkg -c


<div lang="en" dir="ltr" class="mw-content-ltr">
If required dependencies are missing, makepkg will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:
If required dependencies are missing, makepkg will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:
</div>


  $ makepkg -s
  $ makepkg -s


<div lang="en" dir="ltr" class="mw-content-ltr">
Note that these dependencies must be available in the configured repositories; see [[pacman]] for details. Alternatively, one can manually install dependencies prior to building ({{ic|pacman -S --asdeps dep1 dep2}}).
Note that these dependencies must be available in the configured repositories; see [[pacman]] for details. Alternatively, one can manually install dependencies prior to building ({{ic|pacman -S --asdeps dep1 dep2}}).
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Once all dependencies are satisfied and the package builds successfully, a package file ({{ic|pkgname-pkgver.pkg.tar.xz}}) will be created in the working directory. To install, run (as root):
Once all dependencies are satisfied and the package builds successfully, a package file ({{ic|pkgname-pkgver.pkg.tar.xz}}) will be created in the working directory. To install, run (as root):
</div>


  # pacman -U pkgname-pkgver.pkg.tar.xz
  # pacman -U pkgname-pkgver.pkg.tar.xz


<div lang="en" dir="ltr" class="mw-content-ltr">
Alternatively, to install, using the {{ic|-i}} flag is an easier way of running {{ic|pacman -U pkgname-pkgver.pkg.tar.xz}}, as in:
Alternatively, to install, using the {{ic|-i}} flag is an easier way of running {{ic|pacman -U pkgname-pkgver.pkg.tar.xz}}, as in:
</div>


  $ makepkg -i
  $ makepkg -i


<div lang="en" dir="ltr" class="mw-content-ltr">
== Tips and Tricks ==
== Tips and Tricks ==
=== Improving compile times ===
=== Improving compile times ===
Line 176: Line 229:
{{hc|/etc/makepkg.conf|<nowiki>
{{hc|/etc/makepkg.conf|<nowiki>
[...]
[...]
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
#########################################################################
#########################################################################
# BUILD ENVIRONMENT
# BUILD ENVIRONMENT
Line 199: Line 254:
#-- Specify a directory for package building.
#-- Specify a directory for package building.
#BUILDDIR=/tmp
#BUILDDIR=/tmp
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[...]
[...]
</nowiki>}}
</nowiki>}}
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Uncommenting the {{ic|1=BUILDDIR=/tmp}} line and setting it to e.g. {{ic|1=BUILDDIR=/tmp/builds}} (or leaving it to its default value) will make use of Arch default {{ic|/tmp}} [[tmpfs]].
Uncommenting the {{ic|1=BUILDDIR=/tmp}} line and setting it to e.g. {{ic|1=BUILDDIR=/tmp/builds}} (or leaving it to its default value) will make use of Arch default {{ic|/tmp}} [[tmpfs]].
{{Note|The [[tmpfs]] folder needs to be mounted without the {{ic|noexec}} option, else it will prevent build scripts or utilities from being executed. Also, as stated in [[fstab#tmpfs]], its default size is half of the available RAM so you may run out of space.}}
{{Note|The [[tmpfs]] folder needs to be mounted without the {{ic|noexec}} option, else it will prevent build scripts or utilities from being executed. Also, as stated in [[fstab#tmpfs]], its default size is half of the available RAM so you may run out of space.}}
For more information, please refer to [[fstab]] and [[Tmpfs#Improving compile times]].
For more information, please refer to [[fstab]] and [[Tmpfs#Improving compile times]].
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Generate new md5sums ===
=== Generate new md5sums ===
Since [http://allanmcrae.com/2013/04/pacman-4-1-released/ pacman 4.1] {{ic|makepkg -g >> PKGBUILD}} is no longer required as pacman-contrib was [https://projects.archlinux.org/pacman.git/tree/NEWS merged] along with the {{ic|updpkgsums}} script that will generate new checksums and replace them in the PKGBUILD:
Since [http://allanmcrae.com/2013/04/pacman-4-1-released/ pacman 4.1] {{ic|makepkg -g >> PKGBUILD}} is no longer required as pacman-contrib was [https://projects.archlinux.org/pacman.git/tree/NEWS merged] along with the {{ic|updpkgsums}} script that will generate new checksums and replace them in the PKGBUILD:
  $ updpkgsums
  $ updpkgsums
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Makepkg source PKGBUILD twice ===
=== Makepkg source PKGBUILD twice ===
Makepkg sources the PKGBUILD twice (once when initially run, and the second time under fakeroot). Any non-standard functions placed in the PKGBUILD will be run twice as well.
Makepkg sources the PKGBUILD twice (once when initially run, and the second time under fakeroot). Any non-standard functions placed in the PKGBUILD will be run twice as well.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== WARNING: Package contains reference to $srcdir ===
=== WARNING: Package contains reference to $srcdir ===
Somehow, the literal strings {{ic|$srcdir}} or {{ic|$pkgdir}} ended up in one of the installed files in your package.
Somehow, the literal strings {{ic|$srcdir}} or {{ic|$pkgdir}} ended up in one of the installed files in your package.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
To identify which files, run the following from the makepkg build directory:
To identify which files, run the following from the makepkg build directory:
  $ grep -R "$(pwd)/src" pkg/
  $ grep -R "$(pwd)/src" pkg/
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[http://www.mail-archive.com/arch-general@archlinux.org/msg15561.html Link] to discussion thread.
[http://www.mail-archive.com/arch-general@archlinux.org/msg15561.html Link] to discussion thread.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Create uncompressed packages ===
=== Create uncompressed packages ===
If you only want to install packages locally, you can speed up the process by avoiding compression and subsequent decompression. In {{ic|makepkg.conf}}, change {{ic|<nowiki>PKGEXT='.pkg.tar.xz'</nowiki>}} to {{ic|<nowiki>PKGEXT='.pkg.tar'</nowiki>}}.
If you only want to install packages locally, you can speed up the process by avoiding compression and subsequent decompression. In {{ic|makepkg.conf}}, change {{ic|<nowiki>PKGEXT='.pkg.tar.xz'</nowiki>}} to {{ic|<nowiki>PKGEXT='.pkg.tar'</nowiki>}}.
</div>
[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page{{#translation:}}]]

Revision as of 09:53, 22 February 2023

Other languages:
English • ‎Türkçe • ‎русский

makepkg используется для компиляции и сборки пакетов, пригодных для установки с помощью pacman. makepkg - это скрипт, автоматизирующий сборку пакетов. Он может загружать и проверять исходные файлы, проверять зависимости, настраивать параметры времени сборки, компилировать исходные тексты, устанавливать во временный корень, выполнять настройки, генерировать мета-информацию и упаковывать все вместе.

makepkg предоставляется пакетом pacman.

Конфигурация

/etc/makepkg.conf - это основной конфигурационный файл для makepkg. Большинство пользователей захотят уточнить параметры конфигурации makepkg перед сборкой каких-либо пакетов.

A user specific configuration file which takes precedence over the system wide configuration may exist in $HOME/.makepkg.conf. This is important to note if using i3, cinnamon, or deepin as the manjaro-desktop-settings packages for these desktop environments automatically create the user configuration file for new users by way of /etc/skel/.makepkg.conf.

Архитектура, флаги компиляции

Опции MAKEFLAGS, CFLAGS и CXXFLAGS используются make, gcc и g++ при компиляции программ с помощью makepkg. По умолчанию эти опции генерируют общие пакеты, которые могут быть установлены на широкий спектр машин. Повышения производительности можно добиться, настроив компиляцию для конкретной машины. Недостатком является то, что пакеты, скомпилированные специально для процессора компилирующей машины, могут не работать на других машинах.


Примечание
Имейте в виду, что не все системы сборки пакетов будут использовать экспортированные вами переменные. Некоторые переопределяют их в исходных Make-файлах или PKGBUILD.
/etc/makepkg.conf
[...]

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"

# -- Exclusive: будет работать только на x86_64
# -march (или -mcpu) собирает исключительно для архитектуры
# -mtune оптимизирует для архитектуры, но собирает для всего семейства процессоров
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
#-- Make Flags: измените это для систем DistCC/SMP
#MAKEFLAGS="-j2"

[...]

Стандартные makepkg.conf CFLAGS и CXXFLAGS совместимы со всеми машинами в рамках соответствующих архитектур.

На машинах x86_64 редко бывает достаточно значительный прирост производительности в реальном мире, чтобы оправдать затраты времени на пересборку официальных пакетов.

Начиная с версии 4.3.0, GCC предлагает переключатель -march=native, который включает автоопределение процессора и автоматически выбирает оптимизации, поддерживаемые локальной машиной во время выполнения GCC. Чтобы использовать его, просто измените настройки по умолчанию, изменив строки CFLAGS и CXXFLAGS следующим образом:

# -march=native также устанавливает правильную -mtune=
CFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
CXXFLAGS="${CFLAGS}"

Template:BoxTip

Дополнительная оптимизация под тип процессора теоретически может повысить производительность, поскольку -march=native включает все доступные наборы инструкций и улучшает распределение для конкретного процессора. Это особенно заметно при пересборке приложений (например: инструменты кодирования аудио/видео, научные приложения, математически тяжелые программы и т.д.), которые могут использовать преимущества новых наборов инструкций, не включенных при использовании стандартных опций (или пакетов), предоставляемых Manjaro Linux.

Очень легко снизить производительность, используя "нестандартные" CFLAGS, потому что компиляторы склонны сильно увеличивать размер кода с помощью разворачивания циклов, плохой векторизации, безумного инлайнинга и т.д. в зависимости от переключателей компилятора. Если вы не можете проверить/протестить что что-то работает быстрее, есть очень большая вероятность, что это не так!

Полный список доступных опций см. на странице GCC man. Более подробная информация содержится в вики-статье Gentoo Руководство по оптимизации GCC и Safe CFLAGS.

MAKEFLAGS

Опция MAKEFLAGS может быть использована для указания дополнительных опций для make. Пользователи многоядерных/многопроцессорных систем могут указать количество одновременно выполняемых заданий. Это можно сделать с помощью nproc для определения количества доступных процессоров, например, -j4 (где 4 - результат nproc). Некоторые PKGBUILD специально отменяют эту функцию -j1 из-за условий гонки в некоторых версиях или просто потому, что она не поддерживается изначально. Пакеты, которые не собираются из-за этого, должны быть отмечены на багтрекере после того, как убедитесь, что ошибка действительно вызвана вашими MAKEFLAGS.

Полный список доступных опций см. в разделе man make.

Выходной пакет

Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where makepkg is run by default.

/etc/makepkg.conf
[...]

<div lang="en" dir="ltr" class="mw-content-ltr">
#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
#SRCPKGDEST=/home/srcpackages
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
</div>

[...]

For example, create the directory:

$ mkdir /home/$USER/packages

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

The PACKAGER variable will set the packager value within compiled packages' .PKGINFO metadata file. By default, user-compiled packages will display:

pacman -Qi package
[...]
Packager       : Unknown Packager
[...]

Afterwards:

pacman -Qi package
[...]
Packager       : John Doe <john@doe.com>
[...]

This is useful if multiple users will be compiling packages on a system, or you are otherwise distributing your packages to other users.

Signature checking

The following procedure is not necessary for compiling with makepkg, for your initial configuration proceed to #Usage. To temporarily disable signature checking call the makepkg command with the --skippgpcheck option. If a signature file in the form of .sig is part of the PKGBUILD source array, makepkg validates the authenticity of source files. For example, the signature pkgname-pkgver.tar.gz.sig is used to check the integrity of the file pkgname-pkgver.tar.gz with the gpg program. If desired, signatures by other developers can be manually added to the gpg keyring. Look into the GnuPG article for further information.

Note
The signature checking implemented in makepkg does not use pacman's keyring. Configure gpg as explained below to allow makepkg reading pacman's keyring.

The gpg keys are expected to be stored in the user's ~/.gnupg/pubring.gpg file. In case it does not contain the given signature, makepkg shows a warning.

makepkg
[...]
==> Verifying source file signatures with gpg...
pkgname-pkgver.tar.gz ... FAILED (unknown public key 1234567890)
==> WARNING: Warnings have occurred while verifying the signatures.
    Please make sure you really trust them.
[...]

To show the current list of gpg keys use the gpg command.

gpg --list-keys

If the pubring.gpg file does not exist it will be created for you immediatly. You can now proceed with configuring gpg to allow compiling AUR packages submitted by Arch Linux developers with successful signature checking. Add the following line to the end of your gpg configuration file to include the pacman keyring in your user's personal keyring.

~/.gnupg/gpg.conf
[...]
keyring /etc/pacman.d/gnupg/pubring.gpg

When configured as before, the output of gpg --list-keys contains a list of keyrings and developers. Now makepkg can compile AUR packages submitted by Arch Linux developers with successful signature checking.

Usage

Before continuing, ensure the "base-devel" group is installed. Packages belonging to this group are not required to be listed as dependencies in PKGBUILD files. Install the "base-devel" group by issuing (as root):

  1. pacman -S base-devel
Note
Before complaining about missing (make) dependencies, remember that the "base" group is assumed to be installed on all Manjaro Linux systems. The group "base-devel" is assumed to be installed when building with makepkg.

To build a package, one must first create a PKGBUILD, or build script, as described in Create Manjaro Packages, or obtain one from the Manjaro Gitlab Repositories, Arch User Repository, or some other source.

Warning
Only build and/or install packages from trusted sources.

Once in possession of a PKGBUILD, change to the directory where it is saved and issue the following command to build the package described by said PKGBUILD:

$ makepkg

To have makepkg clean out leftover files and folders, such as files extracted to the $srcdir, add the following option. This is useful for multiple builds of the same package or updating the package version, while using the same build folder. It prevents obsolete and remnant files from carrying over to the new builds.

$ makepkg -c

If required dependencies are missing, makepkg will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:

$ makepkg -s

Note that these dependencies must be available in the configured repositories; see pacman for details. Alternatively, one can manually install dependencies prior to building (pacman -S --asdeps dep1 dep2).

Once all dependencies are satisfied and the package builds successfully, a package file (pkgname-pkgver.pkg.tar.xz) will be created in the working directory. To install, run (as root):

# pacman -U pkgname-pkgver.pkg.tar.xz

Alternatively, to install, using the -i flag is an easier way of running pacman -U pkgname-pkgver.pkg.tar.xz, as in:

$ makepkg -i

Tips and Tricks

Improving compile times

As an I/O intensive task, the use of a tmpfs for compiling packages may bring signifiant improvements in build times. Relevant option in /etc/makepkg.conf is to be found at the end of the BUILD ENVIRONMENT section:

/etc/makepkg.conf
[...]
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(fakeroot !distcc color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- fakeroot: Allow building packages as a non-root user
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(fakeroot !distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
#BUILDDIR=/tmp
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
[...]

Uncommenting the BUILDDIR=/tmp line and setting it to e.g. BUILDDIR=/tmp/builds (or leaving it to its default value) will make use of Arch default /tmp tmpfs.

Note
The tmpfs folder needs to be mounted without the noexec option, else it will prevent build scripts or utilities from being executed. Also, as stated in fstab#tmpfs, its default size is half of the available RAM so you may run out of space.

For more information, please refer to fstab and Tmpfs#Improving compile times.

Generate new md5sums

Since pacman 4.1 makepkg -g >> PKGBUILD is no longer required as pacman-contrib was merged along with the updpkgsums script that will generate new checksums and replace them in the PKGBUILD:

$ updpkgsums

Makepkg source PKGBUILD twice

Makepkg sources the PKGBUILD twice (once when initially run, and the second time under fakeroot). Any non-standard functions placed in the PKGBUILD will be run twice as well.

WARNING: Package contains reference to $srcdir

Somehow, the literal strings $srcdir or $pkgdir ended up in one of the installed files in your package.

To identify which files, run the following from the makepkg build directory:

$ grep -R "$(pwd)/src" pkg/

Link to discussion thread.

Create uncompressed packages

If you only want to install packages locally, you can speed up the process by avoiding compression and subsequent decompression. In makepkg.conf, change PKGEXT='.pkg.tar.xz' to PKGEXT='.pkg.tar'.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.