Toggle menu
Manjaro
Export translations
personal-extra
Toggle personal menu
Personal tools
English
Create account
Log in
Toggle search
Search
Random page
Export translations
Views
Language statistics
Message group statistics
Export
Actions
Namespaces
Translate
Variants
Tools
Printable version
Settings
Group
"What should I be aware of if I'm not on an LTS kernel?"
About Manjaro
Add a Storage Partition & Modify your System to Suit
Aliases in .bashrc
ALSA
Alternative way to install ManjaroISO
Amlogic TV boxes
Arch User Repository
Audio Players
Avidemux - Cutting out sections of video
Awesome Community Edition
Basic Submission Rules
Basic Tips for conky
BIOS and UEFI
Block Lists for Deluge & qBittorrent
Bmpanel2
Btrfs
Budgie
Build Manjaro ISOs with buildiso
Buildiso with AUR packages: Using buildpkg
Burn an ISO File
Change to a Different Download Server
CheatSheet
Check a Downloaded ISO Image For Errors
ClamAV
Configure Graphics Cards
Configure NVIDIA (non-free) settings and load them on Startup
Contributing
Create Manjaro Packages
Deepin
Desktop Environments and Window Managers
Developer Tools
Did X.server recognise your monitor correctly?
Display Managers / Login Screens
Displaymanager / Loginmanager
DMenu
Dolphin
Downgrading packages
Download Manjaro
Enable Touchpad Horizontal and Vertical Scrolling
Encfs
File Systems
Firejail
Firewalls
Firewalls and Security
Flatpak
Forum Rules
Fstab
Fstab - Use SystemD automount
GNOME
Graphical Software Managers
GRUB/Restore the GRUB Bootloader
How to mount Windows (NTFS) filesystem due to hibernation
How-to verify GPG key of official .ISO images
Important hidden .dot files in your home partition
Improve Font Rendering
Install Desktop Environments
Install Display Managers
Installation Guides
Installation with Manjaro Architect
Internet Browsers
KDE
Kernel Fails to Load (pata acpi error)
Keyboard and Mouse Sharing
Keyboard Shortcuts
Kvantum
Limit the size of .log files & the journal
Linux Security
List of Qt Applications
Locale
LXDM Configuration
LXQt
LXQt with kwin
Main Page
Make GRUB menu & boot-up/down fonts bigger
Makepkg
Manjaro
Manjaro FAQ
Manjaro Forums
Manjaro Hardware Detection
Manjaro Hardware Detection Overview
Manjaro IRC
Manjaro Kernels
Manjaro Mirrors
Manjaro Online
Manjaro Packaging Standards
Manjaro Polkit Rules
Manjaro Settings Manager
Manjaro-ARM
Manjaro-tools
Manjaro:A Different Kind of Beast
ManjaroISO
Mounting disk images
Mozilla Firefox
Mplayer
Networking
Octopi
Openbox
Pacman
Pacman Overview
Pacman troubleshooting
Pacman-mirrors
Page Translation
Pamac
Partitioning Overview and Existing Partition Tables
PCmanFM-Qt
PKGBUILD
Plymouth
Power Management
Preserve Manjaro Bootloader
Printing
Proper ~/.xinitrc File
Reactivating the Backlight
Repositories and Servers
Set all Java apps to use GTK+ font & theme settings
Set all Qt app's to use GTK+ font & theme settings
Setup Kmail & Davmail to connect to an Exchange server
Sharing files with Python
Snap
Software Applications
Some basics of MBR v/s GPT and BIOS v/s UEFI
Spotify
Swap
Switching Branches
Sync dynamic IP with openDNS service via ddclient
System Maintenance
Systemd-boot
TeamViewer
The Rolling Release Development Model
UEFI - Install Guide
Undervolt intel CPU
Using autofs (automount) with NFS
Using Compton for a tear-free experience in Xfce
Using Manjaro for Beginners
Using Manjaro for Windows users
Using Samba in your File Manager
Various screen tearing fixes
VCS PKGBUILD Guidelines
Viewing and editing configuration files
Virt-manager
VirtualBox
Vivaldi Browser
VMware
Wacom Tablet And Pen
Western Digital Green - Drive Fix - Linux
Wiki tweak page
Worker - An Introduction
Workflow states
Language
aa - Afar
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
ak - Akan
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
ban-bali - ᬩᬲᬩᬮᬶ
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bcl - Central Bikol
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Min Dong Chinese
ce - Chechen
ceb - Cebuano
ch - Chamorro
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cr - Cree
crh - Crimean Turkish
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - español (formal)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
ff - Fulah
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gag - Gagauz
gan - Gan Chinese
gan-hans - Gan (Simplified)
gan-hant - Gan (Traditional)
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
grc - Ancient Greek
gsw - Swiss German
gu - Gujarati
guc - Wayuu
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
ht - Haitian Creole
hu - Hungarian
hu-formal - magyar (formal)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
id - Indonesian
ie - Interlingue
ig - Igbo
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kcg - Tyap
kg - Kongo
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mad - Madurese
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Maori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mni - Manipuri
mnw - Mon
mo - Moldovan
mr - Marathi
mrh - Mara
mrj - Western Mari
ms - Malay
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Min Nan Chinese
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
nia - Nias
niu - Niuean
nl - Dutch
nl-informal - Nederlands (informeel)
nn - Norwegian Nynorsk
no - Norwegian
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nys - Nyungar
oc - Occitan
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rm - Romansh
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rw - Kinyarwanda
sa - Sanskrit
sah - Sakha
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy - Shawiya
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - себертатар
su - Sundanese
sv - Swedish
sw - Swahili
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tly-cyrl - толыши
tn - Tswana
to - Tongan
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
war - Waray
wo - Wolof
wuu - Wu Chinese
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yue - Cantonese
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
qqq - Message documentation
Format
Export for off-line translation
Export in native format
Fetch
{{DISPLAYTITLE:Manjaro Paketleri Oluşturma}}<languages/> __TOC__ =Manjaro paketleri oluşturma yönergeleri= This article aims to assist users creating their own packages using Manjaro optimized devtools, also for submission in Manjaro binary repositories. It covers creation of a [[PKGBUILD]], a package build description file sourced by {{ic|makepkg}} to create a binary package from source. If already in possession of a {{ic|PKGBUILD}} (see [[makepkg]]). For instructions regarding existing rules and ways to improve package quality see [[Manjaro Packaging Standards]]. == Overview == Packages in Manjaro Linux are built using the [[makepkg]] utility and the information stored in a [[PKGBUILD]] file. When {{ic|makepkg}} is run, it searches for a {{ic|PKGBUILD}} in the current directory and follows the instructions therein to either compile or otherwise acquire the required files to be packaged within a package file ({{ic|pkgname.pkg.tar.xz}}). The resulting package contains binary files and installation instructions; readily installed with [[pacman]]. An Manjaro package is no more than a tar archive, or 'tarball', compressed using xz, which contains the following files generated by makepkg: * The binary files to install. * {{ic|.PKGINFO}}: contains all the metadata needed by pacman to deal with packages, dependencies, etc. * {{ic|.MTREE}}: contains hashes and timestamps of the files, which are included in the local database so that pacman can verify the integrity of the package. * {{ic|.INSTALL}}: an optional file used to execute commands after the install/upgrade/remove stage. (This file is present only if specified in the {{ic|PKGBUILD}}.) * {{ic|.Changelog}}: an optional file kept by the package maintainer documenting the changes of the package. (It is not present in all packages.) == Preparation == ===Prerequisite software=== First ensure that the necessary tools are installed. The package group '''base-devel''' should be sufficient; it includes '''make''' and additional tools needed for compiling from source. # pacman -S base-devel One of the key tools for building packages is [[makepkg]] (provided by [[pacman]]) which does the following: #Checks if package dependencies are installed. #Downloads the source file(s) from the specified server(s). #Unpacks the source file(s). #Compiles the software and installs it under a fakeroot environment. #Strips symbols from binaries and libraries. #Generates the package meta file which is included with each package. #Compresses the fakeroot environment into a package file. #Stores the package file in the configured destination directory, which is the present working directory by default. === Download and test the installation === Download the source tarball of the software you want to package, extract it, and follow the author's steps to install the program. Make a note of all commands and/or steps needed to compile and install it. You will be repeating those same commands in the ''PKGBUILD'' file. Most software authors stick to the 3-step build cycle: ./configure make make install This is a good time to make sure the program is working correctly. == Creating a PKGBUILD == When you run {{ic|makepkg}}, it will look for a {{ic|PKGBUILD}} file in the present working directory. If a {{ic|PKGBUILD}} file is found it will download the software's source code and compile it according to the instructions specified in the {{ic|PKGBUILD}} file. The instructions must be fully interpretable by the [[Wikipedia:Bash_(Unix_shell)|Bash]] shell. After successful completion, the resulting binaries and metadata of the package (package version and dependencies,) are packed in a {{ic|pkgname.pkg.tar.xz}} package file that can be installed with {{ic|pacman -U ''<package file>''}}. To begin with a new package, you should first create an empty working directory, (preferably {{ic|~/abs/'''pkgname'''}}), change into that directory, and create a {{ic|PKGBUILD}} file. You can either copy the prototype PKGBUILD {{ic|/usr/share/pacman/PKGBUILD.proto}} to your working directory or copy a {{ic|PKGBUILD}} from a similar package. The latter may be useful if you only need to change a few options. === Defining PKGBUILD variables === Example PKGBUILDs are located in {{Ic|/usr/share/pacman/}}. An explanation of possible {{ic|PKGBUILD}} variables can be found in the [[PKGBUILD]] article. ''makepkg'' defines three variables that you should use as part of the build and install process: ; {{ic|startdir}}: This contains the absolute path to the directory where the {{ic|PKGBUILD}} file is located. This variable used to be used in combination with {{ic|/src}} or {{ic|/pkg}} postfixes, but the use of {{ic|srcdir}} and {{ic|pkgdir}} variables is the modern method. {{ic|$startdir/src}} is '''not''' guaranteed to be the same as {{ic|$srcdir}}, and likewise for {{ic|$pkgdir}}. Use of this variable is deprecated and strongly discouraged. ; {{ic|srcdir}}: This points to the directory where ''makepkg'' extracts or copies all source files. ; {{ic|pkgdir}}: This points to the directory where ''makepkg'' bundles the installed package, which becomes the root directory of your built package. All of them contain ''absolute'' paths, which means, you don't have to worry about your working directory if you use these variables properly. {{Note|''makepkg'', and thus the {{ic|build()}} and {{ic|package()}} functions, are intended to be non-interactive. Interactive utilities or scripts called in those functions may break ''makepkg'', particularly if it is invoked with build-logging enabled ({{ic|-l}}). (See [https://bugs.archlinux.org/task/13214 FS13214].)}} {{Note|Apart from the current package Maintainer, there may be previous maintainers listed above as Contributors.}} === PKGBUILD Functions === There are 5 functions, listed here in the order they are executed if all of them exist. If one does not exist, it is simply skipped. {{Note|This does not apply to the {{ic|package()}} function, as it is required in every PKGBUILD}} ==== The {{ic|pkgver()}} function ==== Beginning with pacman 4.1, you can update the pkgver variable during a makepkg. {{ic|pkgver()}} is run right after the sources are fetched and extracted. This is particularly useful if you are [[VCS PKGBUILD Guidelines|making git/svn/hg/etc. packages]], where the build process may remain the same, but the source could be updated every day, even every hour. The old way of doing this was to put the date into the pkgver field which, if the software was not updated, makepkg would still rebuild it thinking the version had changed. Some useful commands for this are {{ic|git describe}}, {{ic|hg identify -ni}}, etc. Please test these before submitting a PKGBUILD, as a failure in the {{ic|pkgver()}} function can stop a build in its tracks. {{Note|pkgver cannot contain spaces or hyphens ({{ic|-}}). Using sed to correct this is common.}} ==== The {{ic|prepare()}} function ==== Pacman 4.1 introduces the {{ic|prepare()}} function. In this function, commands that are used to prepare sources for building are run, such as patching. This function is run before the build function and after package extraction. If extraction is skipped ({{ic|makepkg -e}}), then {{ic|prepare()}} is not run. {{Note| (From {{ic|man PKGBUILD}}) The function is run in {{ic|bash -e}} mode, meaning any command that exits with a non-zero status will cause the function to exit.}} ==== The {{ic|build()}} function ==== Now you need to implement the {{ic|build()}} function in the {{ic|PKGBUILD}} file. This function uses common shell commands in [[Wikipedia:Bash_(Unix_shell)|Bash]] syntax to automatically compile software and create a {{ic|pkg}} directory to install the software to. This allows ''makepkg'' to package files without having to sift through your filesystem. The first step in the {{ic|build()}} function is to change into the directory created by uncompressing the source tarball. ''makepkg'' will change the current directory to {{ic|srcdir}} before executing the {{ic|build()}}, thus in most common cases the first command will look like this: cd "$pkgname-$pkgver" The {{ic|/usr/share/pacman/PKGBUILD.proto}} file suggests doing cd "$srcdir/$pkgname-$pkgver" instead. Again, as {{ic|$srcdir}} is an absolute path, this does not make any difference. Now, you need to list the same commands you used when you manually compiled the software. The {{ic|build()}} function in essence automates everything you did by hand and compiles the software in the fakeroot build environment. If the software you are packaging uses a configure script, it is good practice to use {{ic|1=--prefix=/usr}} when building packages for pacman. A lot of software installs files relative to the {{ic|/usr/local}} directory, which should only be done if you are manually building from source. All Arch Linux packages should use the {{ic|/usr}} directory. As seen in the {{ic|/usr/share/pacman/PKGBUILD.proto}} file, the next two lines often look like this: ./configure --prefix=/usr make {{Note|If your software does not need to build anything, DO NOT use the {{ic|build()}} function. The {{ic|build()}} function is not required, but the {{ic|package()}} function is.}} ==== The {{ic|check()}} function ==== Place for calls to {{Ic|make check}} and similar testing routines. It is highly recommended to have {{ic|check()}} as it helps to make sure software has been built correctly and works fine with its dependencies. Users who don't need it (and occasionally maintainers who can not fix a package for this to pass) can disable it using {{Ic|!check}} in PKGBUILD/makepkg options or call {{ic|makepkg}} with {{ic|--nocheck}} flag. ==== The {{ic|package()}} function ==== The final step is to put the compiled files in a directory where ''makepkg'' can retrieve them to create a package. This by default is the {{ic|pkg}} directory—a simple fakeroot environment. The {{ic|pkg}} directory replicates the hierarchy of the root file system of the software's installation paths. If you have to manually place files under the root of your filesystem, you should install them in the {{ic|pkg}} directory under the same directory structure. For example, if you want to install a file to {{ic|/usr/bin}}, it should instead be placed under {{ic|$pkgdir/usr/bin}}. Very few install procedures require the user to copy dozens of files manually. Instead, for most software, calling {{ic|make install}} will do so. The final line should look like the following in order to correctly install the software in the {{ic|pkg}} directory: make DESTDIR="$pkgdir/" install {{Note|It is sometimes the case where {{ic|DESTDIR}} is not used in the {{ic|Makefile}}; you may need to use {{ic|prefix}} instead. If the package is built with ''autoconf''/''automake'', use {{ic|DESTDIR}}; this is what is [https://www.gnu.org/software/automake/manual/automake.html#Install documented] in the manuals. If {{ic|DESTDIR}} does not work, try building with {{ic|1=make prefix="$pkgdir/usr/" install}}. If that does not work, you will have to look further into the install commands that are executed by "{{ic|make <...> install}}".}} In some odd cases, the software expects to be run from a single directory. In such cases, it is wise to simply copy these to {{ic|$pkgdir/opt}}. More often than not, the installation process of the software will create any sub-directories below the {{ic|pkg}} directory. If it does not, however, ''makepkg'' will generate a lot of errors and you will need to manually create sub-directories by adding the appropriate {{ic|mkdir -p}} commands in the {{ic|build()}} function before the installation procedure is run. In old packages, there was no {{ic|package()}} function. So, files were put into the ''pkg'' directory at the end of the {{ic|build()}} function. If {{ic|package()}} is not present, {{ic|build()}} runs via ''fakeroot''. In new packages, {{ic|package()}} is required and runs via ''fakeroot'' instead, and {{ic|build()}} runs without any special privileges. {{ic|makepkg --repackage}} runs only the {{ic|package()}} function, so it creates a {{ic|*.pkg.*}} file without compiling the package. This may save time e.g. if you just have changed the {{ic|depends}} variable of the package. {{Note|The {{ic|package()}} function is the only required function in a PKGBUILD. If you must only copy files into their respective directories to install a program, do not put it in the {{ic|build()}} function, put that in the {{ic|package()}} function.}} == Testing the PKGBUILD and package == As you are writing the {{ic|build()}} function, you will want to test your changes frequently to ensure there are no bugs. You can do this using the {{ic|makepkg}} command in the directory containing the {{ic|PKGBUILD}} file. With a properly formatted {{ic|PKGBUILD}}, makepkg will create a package; with a broken or unfinished {{ic|PKGBUILD}}, it will raise an error. If makepkg finishes successfully, it will place a file named {{ic|pkgname-pkgver.pkg.tar.xz}} in your working directory. This package can be installed with the {{ic|pacman -U}} command. However, just because a package file was built does not imply that it is fully functional. It might conceivably contain only the directory and no files whatsoever if, for example, a prefix was specified improperly. You can use pacman's query functions to display a list of files contained in the package and the dependencies it requires with {{ic|pacman -Qlp [package file]}} and {{ic|pacman -Qip [package file]}} respectively. If the package looks sane, then you are done! However, if you plan on releasing the {{ic|PKGBUILD}} file, it is imperative that you check and double-check the contents of the {{ic|depends}} array. Also ensure that the package binaries actually ''run'' flawlessly! It is annoying to release a package that contains all necessary files, but crashes because of some obscure configuration option that does not quite work well with the rest of the system. If you are only going to compile packages for your own system, though, you do not need to worry too much about this quality assurance step, as you are the only person suffering from mistakes, after all. === Checking package sanity === After testing package functionality check it for errors using [[namcap]]: $ namcap PKGBUILD $ namcap ''<package file name>''.pkg.tar.xz Namcap will: # Check PKGBUILD contents for common errors and package file hierarchy for unnecessary/misplaced files # Scan all ELF files in package using {{ic|ldd}}, automatically reporting which packages with required shared libraries are missing from {{Ic|depends}} and which can be omitted as transitive dependencies # Heuristically search for missing and redundant dependencies and much more. Get into the habit of checking your packages with namcap to avoid having to fix the simplest mistakes after package submission. == Submitting packages to the AUR == Please read [https://wiki.archlinux.org/index.php/AUR_User_Guidelines#Submitting_packages AUR User Guidelines#Submitting packages] for a detailed description of the submission process. == Summary == #Download the source tarball of the software you want to package. #Try compiling the package and installing it into an arbitrary directory. #Copy over the prototype {{ic|/usr/share/pacman/PKGBUILD.proto}} and rename it to {{ic|PKGBUILD}} in a temporary working directory -- preferably {{ic|~/abs/}}. #Edit the {{ic|PKGBUILD}} according to the needs of your package. #Run {{ic|makepkg}} and see whether the resulting package is built correctly. #If not, repeat the last two steps. === Warnings === * Before you can automate the package building process, you should have done it manually at least once unless you know ''exactly'' what you are doing ''in advance'', in which case you would not be reading this in the first place. Unfortunately, although a good bunch of program authors stick to the 3-step build cycle of "{{ic|./configure}}; {{ic|make}}; {{ic|make install}}", this is not always the case, and things can get real ugly if you have to apply patches to make everything work at all. Rule of thumb: If you cannot get the program to compile from the source tarball, and make it install itself to a defined, temporary subdirectory, you do not even need to try packaging it. There is not any magic pixie dust in {{ic|makepkg}} that makes source problems go away. * In a few cases, the packages are not even available as source and you have to use something like {{ic|sh installer.run}} to get it to work. You will have to do quite a bit of research (read READMEs, INSTALL instructions, man pages, perhaps ebuilds from Gentoo or other package installers, possibly even the MAKEFILEs or source code) to get it working. In some really bad cases, you have to edit the source files to get it to work at all. However, {{ic|makepkg}} needs to be completely autonomous, with no user input. Therefore if you need to edit the makefiles, you may have to bundle a custom patch with the {{ic|PKGBUILD}} and install it from inside the {{ic|prepare()}} function, or you might have to issue some {{ic|sed}} commands from inside the {{ic|prepare()}} function. ==Create a patch file== Example for individual file $ diff -Naur filename.ext.old filename.ext > filename-patchname.diff # PKGBUILD cd "${srcdir}/${pkgname}-${pkgver}" patch -uN filename.ext ../filename-patchname.diff || return 1 Example for multiple files $ diff -Naur package-ver.old package-ver > package-patchname.diff # PKGBUILD cd "${srcdir}/${pkgname}-${pkgver}" patch -uNp1 -i ../${pkgname}-patchname.diff || return 1 [[Category:Contents Page{{#translation:}}]] [[Category:Development{{#translation:}}]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
OK