Difference between revisions of "PKGBUILD/ru"
Views
Actions
Namespaces
Variants
Tools
(Created page with "=== epoch === Используется для того, чтобы заставить пакет считаться более новым, чем все предыдущие...") Tags: Mobile web edit Mobile edit |
(Created page with "=== pkgbase === Необязательная глобальная директива доступна при сборке разделенного пакета, pkgbase исп...") Tags: Mobile web edit Mobile edit |
||
Line 27: | Line 27: | ||
=== pkgbase === | === pkgbase === | ||
Необязательная глобальная директива доступна при сборке разделенного пакета, pkgbase используется для ссылки на группу пакетов в выводе makepkg и в именовании tarballs, содержащих только исходники. Если она не указана - используется первый элемент массива pkgname. Все опции и директивы для разделенных пакетов по умолчанию имеют глобальные значения, указанные в PKGBUILD. Тем не менее, следующие из них могут быть переопределены в функции упаковки каждого разделенного пакета: pkgver, pkgrel, epoch, pkgdesc, arch, url, license, groups, depends, optdepends, provides, conflicts, replaces, backup, options, install и changelog. Переменная не может начинаться с дефиса. | |||
=== pkgdesc === | === pkgdesc === |
Revision as of 17:44, 2 January 2023
PKGBUILD - это файл описания сборки пакетов Manjaro Linux (на самом деле это сценарий shell), используемый при создании пакетов.
Пакеты в Manjaro Linux собираются с помощью утилиты makepkg и информации, хранящейся в PKGBUILD. Когда запускается утилита makepkg, она ищет PKGBUILD
в текущем каталоге и, следуя инструкциям в нем, компилирует или получает файлы для создания пакета (pkgname.pkg.tar.xz
). Полученный пакет содержит двоичные файлы и инструкции по установке, которые легко устанавливаются с помощью pacman.
Переменные
Ниже перечислены переменные, которые могут быть заполнены в файле PKGBUILD. pkgname
, pkgver
, pkgrel
и arch
являются обязательными. license
не является строго необходимым для сборки пакета, но рекомендуется для любых PKGBUILDS, которыми вы, возможно, захотите поделиться с другими. При его отсутствии makepkg
выдает предупреждения.
Обычно принято определять переменные в PKGBUILD в том же порядке, который приведен здесь. Однако это не является обязательным, если используется правильный синтаксис Bash.
pkgname
Название пакета. Оно должно состоять из буквенно-цифровых и любого из следующих символов @ . _ + - (символ собака, точка, подчеркивание, плюс, дефис). Все буквы должны быть строчными, а имена не должны начинаться с дефиса. Для единообразия pkgname
должно совпадать с именем исходного tarball'а программы, которую вы упаковываете. Например, если программа находится в foobar-2.5.tar.gz
, значение pkgname
должно быть foobar
. Текущий рабочий каталог, в котором находится файл PKGBUILD, также должен соответствовать pkgname
.
pkgver
Версия пакета. Значение должно совпадать с версией, выпущенной автором пакета. Оно может содержать буквы, цифры, точки и знаки подчеркивания, но НЕ МОЖЕТ содержать дефис. Если автор пакета использует дефис в своей схеме нумерации версий, замените его на знак подчеркивания. Например, если версия 0.99-10, ее следует заменить на 0.99_10. Если переменная pkgver
используется позже в PKGBUILD, то подчеркивание можно легко заменить на тире при использовании, например:
source=($pkgname-${pkgver//_/-}.tar.gz)
pkgrel
Номер выпуска пакета, характерный для Arch Linux. Это значение позволяет пользователям различать последовательные сборки одной и той же версии пакета. Когда новая версия пакета выпускается впервые - номер выпуска начинается с 1. По мере внесения исправлений и оптимизаций в файл PKGBUILD
, пакет будет перевыпущен, а номер выпуска будет увеличен на 1. Когда выходит новая версия пакета - номер выпуска возвращается к 1.
pkgdir
Эта переменная отражает корневой каталог того, что будет помещено в пакет. Она обычно используется в make DESTDIR="$pkgdir" install
.
epoch
Используется для того, чтобы заставить пакет считаться более новым, чем все предыдущие версии с более ранней датой выпуска, даже если номер версии обычно не вызывает такого обновления. Это значение должно быть положительным целым числом; если оно не указано, то по умолчанию равно 0. Это полезно, когда схема нумерации версий пакета меняется (или становится буквенно-цифровой), нарушая обычную логику сравнения версий. Дополнительные сведения о сравнении версий см. в pacman(8).
pkgbase
Необязательная глобальная директива доступна при сборке разделенного пакета, pkgbase используется для ссылки на группу пакетов в выводе makepkg и в именовании tarballs, содержащих только исходники. Если она не указана - используется первый элемент массива pkgname. Все опции и директивы для разделенных пакетов по умолчанию имеют глобальные значения, указанные в PKGBUILD. Тем не менее, следующие из них могут быть переопределены в функции упаковки каждого разделенного пакета: pkgver, pkgrel, epoch, pkgdesc, arch, url, license, groups, depends, optdepends, provides, conflicts, replaces, backup, options, install и changelog. Переменная не может начинаться с дефиса.
pkgdesc
The description of the package. The description should be about 80 characters or less and should not include the package name in a self-referencing way. For instance, "Nedit is a text editor for X11" should be written as "A text editor for X11."
arch
An array of architectures that the PKGBUILD
file is known to build and work on. Currently, it should contain i686
and/or x86_64
, arch=('i686' 'x86_64')
. The value any
can also be used for architecture-independent packages.
You can access the target architecture with the variable $CARCH
during a build, and even when defining variables. See also FS16352. Example:
depends=(foobar) if test "$CARCH" == x86_64; then depends+=(lib32-glibc) fi
url
The URL of the official site of the software being packaged.
license
The license under which the software is distributed. A licenses
package has been created in [core]
that stores common licenses in /usr/share/licenses/common
, e.g. /usr/share/licenses/common/GPL
. If a package is licensed under one of these licenses, the value should be set to the directory name, e.g. license=('GPL')
. If the appropriate license is not included in the official licenses
package, several things must be done:
- The license file(s) should be included in:
/usr/share/licenses/pkgname/
, e.g./usr/share/licenses/foobar/LICENSE
. - If the source tarball does NOT contain the license details and the license is only displayed elsewhere, e.g. a website, then you need to copy the license to a file and include it.
- Add
custom
to thelicense
array. Optionally, you can replacecustom
withcustom:name of license
. Once a license is used in two or more packages in an official repository (including[community]
), it becomes a part of thelicenses
package.
- The BSD, MIT, zlib/png and Python licenses are special cases and could not be included in the
licenses
package. For the sake of thelicense
array, it is treated as a common license (license=('BSD')
,license=('MIT')
,license=('ZLIB')
andlicense=('Python')
) but technically each one is a custom license because each one has its own copyright line. Any packages licensed under these four should have its own unique license stored in/usr/share/licenses/pkgname
. Some packages may not be covered by a single license. In these cases, multiple entries may be made in the license array, e.g.license=('GPL' 'custom:name of license')
. - Additionally, the (L)GPL has many versions and permutations of those versions. For (L)GPL software, the convention is:
- (L)GPL - (L)GPLv2 or any later version
- (L)GPL2 - (L)GPL2 only
- (L)GPL3 - (L)GPL3 or any later version
- If after researching the issue no license can be determined,
PKGBUILD.proto
suggests usingunknown
. However, upstream should be contacted about the conditions under which the software is (and is not) available.
groups
The group the package belongs in. For instance, when you install the kdebase
package, it installs all packages that belong in the kde
group.
depends
An array of package names that must be installed before this software can be run. Version restrictions can be specified with comparison operators, e.g. depends=('foobar>=1.8.0')
; if multiple restrictions are needed, the dependency can be repeated for each of them [1], e.g. depends=('foobar>=1.8.0' 'foobar<2.0.0')
. You do not need to list packages that your software depends on if other packages your software depends on already have those packages listed in their dependency. For instance, gtk2
depends on glib2
and glibc
. However, glibc
does not need to be listed as a dependency for gtk2
because it is a dependency for glib2
.
optdepends
An array of package names that are not needed for the software to function but provides additional features. A short description of what each package provides should also be noted. An optdepends
may look like this:
optdepends=( 'cups: printing support' 'sane: scanners support' 'libgphoto2: digital cameras support' 'alsa-lib: sound support' 'giflib: GIF images support' 'libjpeg: JPEG images support' 'libpng: PNG images support' )
makedepends
An array of package names that must be installed to build the software but unnecessary for using the software after installation. You can specify the minimum version dependency of the packages in the same format as the depends
array.
checkdepends
An array of packages this package depends on to run its test suite but are not needed at runtime. Packages in this list follow the same format as depends. These dependencies are only considered when the check() function is present and is to be run by makepkg.
provides
An array of package names that this package provides the features of (or a virtual package such as cron
or sh
). Packages that provide the same things can be installed at the same time unless conflict with each other (see below). If you use this variable, you should add the version (pkgver
and perhaps the pkgrel
) that this package will provide if dependencies may be affected by it. For instance, if you are providing a modified qt package named qt-foobar version 3.3.8 which provides qt then the provides
array should look like provides=('qt=3.3.8')
. Putting provides=('qt')
will cause to fail those dependencies that require a specific version of qt. Do not add pkgname
to your provides array, this is done automatically.
conflicts
An array of package names that may cause problems with this package if installed. Package with this name and all packages which provides
virtual packages with this name will be removed. You can also specify the version properties of the conflicting packages in the same format as the depends
array.
replaces
An array of obsolete package names that are replaced by this package, e.g. replaces=('ethereal')
for the wireshark
package. After syncing with pacman -Sy
, it will immediately replace an installed package upon encountering another package with the matching replaces
in the repositories. If you are providing an alternate version of an already existing package, use the conflicts
variable which is only evaluated when actually installing the conflicting package.
backup
An array of files that can contain user-made changes and should be preserved during upgrade or removal of a package, primarily intended for configuration files in /etc
.
When updating, new version may be saved as file.pacnew
to avoid overwriting a file which already exists and was previously modified by the user. Similarly, when the package is removed, user-modified file will be preserved as file.pacsave
unless the package was removed with pacman -Rn
command.
The file paths in this array should be relative paths (e.g. etc/pacman.conf
) not absolute paths (e.g. /etc/pacman.conf
). See also the Arch Wiki on Pacnew and Pacsave Files.
options
This array allows you to override some of the default behavior of makepkg
, defined in /etc/makepkg.conf
. To set an option, include the option name in the array. To reverse the default behavior, place an !
at the front of the option. The following options may be placed in the array:
- strip - Strips symbols from binaries and libraries. If you frequently use a debugger on programs or libraries, it may be helpful to disable this option.
- docs - Save
/doc
directories. - libtool - Leave libtool (
.la
) files in packages. - staticlibs - Leave static library (.a) files in packages
- emptydirs - Leave empty directories in packages.
- zipman - Compress man and info pages with gzip.
- purge - Remove files specified by the
PURGE_TARGETS
variable from the package. - upx - Compress binary executable files using UPX. Additional options can be passed to UPX by specifying the
UPXFLAGS
variable. - ccache - Allow the use of
ccache
during build. More useful in its negative form!ccache
with select packages that have problems building withccache
. - distcc - Allow the use of
distcc
during build. More useful in its negative form!distcc
with select packages that have problems building withdistcc
. - buildflags - Allow the use of user-specific
buildflags
(CFLAGS, CXXFLAGS, LDFLAGS) during build. More useful in its negative form!buildflags
with select packages that have problems building with custombuildflags
. - makeflags - Allow the use of user-specific
makeflags
during build. More useful in its negative form!makeflags
with select packages that have problems building with custommakeflags
.
install
The name of the .install
script to be included in the package. pacman has the ability to store and execute a package-specific script when it installs, removes or upgrades a package. The script contains the following functions which run at different times:
- pre_install - The script is run right before files are extracted. One argument is passed: new package version.
- post_install - The script is run right after files are extracted. One argument is passed: new package version.
- pre_upgrade - The script is run right before files are extracted. Two arguments are passed in the following order: new package version, old package version.
- post_upgrade - The script is run right after files are extracted. Two arguments are passed in the following order: new package version, old package version.
- pre_remove - The script is run right before files are removed. One argument is passed: old package version.
- post_remove - The script is run right after files are removed. One argument is passed: old package version.
Each function is run chrooted inside the pacman install directory. See this thread.
changelog
The name of the package changelog. To view changelogs for installed packages (that have this file):
pacman -Qc pkgname
source
An array of files which are needed to build the package. It must contain the location of the software source, which in most cases is a full HTTP or FTP URL. The previously set variables pkgname
and pkgver
can be used effectively here (e.g. source=(http://example.com/$pkgname-$pkgver.tar.gz)
)
noextract
An array of files listed under the source
array which should not be extracted from their archive format by makepkg
. This most commonly applies to archives which cannot be handled by /usr/bin/bsdtar
because libarchive
processes all files as streams rather than random access as unzip
does. In these situations, the alternative unarchiving tool (e.g., unzip
, p7zip
, etc.) should be added in the makedepends
array and the first line of the prepare() function should extract the source archive manually; for example:
unzip [источник].zip
Note that while the source
array accepts URLs, noextract
is just the file name portion. So, for example, you would do something like this (simplified from grub2's PKGBUILD):
source=("http://ftp.archlinux.org/other/grub2/grub2_extras_lua_r20.tar.xz") noextract=("grub2_extras_lua_r20.tar.xz")
To extract nothing, you can do something fancy like this (taken from firefox-i18n):
noextract=(${source[@]%%::*})
md5sums
An array of MD5 checksums of the files listed in the source
array. Once all files in the source
array are available, an MD5 hash of each file will be automatically generated and compared with the values of this array in the same order they appear in the source
array. While the order of the source files itself does not matter, it is important that it matches the order of this array since makepkg
cannot guess which checksum belongs to what source file. You can generate this array quickly and easily using the commands updpkgsums
or makepkg -g
in the directory that contains the PKGBUILD
file.
sha1sums
An array of SHA-1 160-bit checksums. This is an alternative to md5sums
described above, but it is also known to have weaknesses, so you should consider using a stronger alternative. To enable use and generation of these checksums, be sure to set up the INTEGRITY_CHECK
option in /etc/makepkg.conf
. See man makepkg.conf
.
sha256sums, sha384sums, sha512sums
An array of SHA-2 checksums with digest sizes 256, 384 and 512 bits respectively. These are alternatives to md5sums
described above and are generally believed to be stronger. To enable use and generation of these checksums, be sure to set up the INTEGRITY_CHECK
option in /etc/makepkg.conf
. See man makepkg.conf
.