https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Dhole&feedformat=atomAlpine Linux - User contributions [en]2024-03-28T22:42:29ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Include:Newapkbuild&diff=15241Include:Newapkbuild2018-04-23T08:15:47Z<p>Dhole: Update options</p>
<hr />
<div>{{Cmd|newapkbuild ''packagename''}}<br />
<br />
'''newapkbuild options'''<br />
<br />
* '''-n''' Set package name to NAME<br />
* '''-d''' Set package description (pkgdesc) to DESC<br />
* '''-l''' Set package license to LICENSE<br />
* '''-u''' Set package URL<br />
* '''-a''' Create autotools package (use ./configure ...)<br />
* '''-C''' Create CMake pakckage (Assume cmake/ is there)<br />
* '''-m''' Create meson package (Assume meson.build is there)<br />
* '''-p''' Create perl package (Assume Makefile.PL is there)<br />
* '''-y''' Create python package (Assume setup.py is there)<br />
* '''-s''' Use sourceforge source URL<br />
* '''-c''' Copy a sample init.d, conf.d, and install script to new directory<br />
* '''-f''' Force even if directory already exist<br />
* '''-h''' Show this help<br />
<br />
[[Category:Development]]</div>Dholehttps://wiki.alpinelinux.org/w/index.php?title=Creating_an_Alpine_package&diff=15240Creating an Alpine package2018-04-23T08:04:57Z<p>Dhole: typo + use gender neutral pronoun</p>
<hr />
<div>== Requirements ==<br />
<br />
To build a package for Alpine Linux you need an Alpine Linux installation. Check the [[Installation]] page to see all available installation options.<br />
<br />
== Setup your system and account ==<br />
{{:Include:Setup_your_system_and_account_for_building_packages}}<br />
<br />
== Getting some help ==<br />
<br />
It might be wise to start by checking what the [[Abuild|abuild]] program can/cannot do.<br />
<br />
{{Cmd|abuild -h}}<br />
<br />
For real help, you can also go on Freenode's #alpine-devel on IRC.<br />
<br />
== Creating an APKBUILD file ==<br />
<br />
=== Use a template APKBUILD ===<br />
<br />
To create the actual APKBUILD file {{Pkg|newapkbuild}} can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file to the given directory, and fill some variables if those are provided. Please check the [[Package_policies| package policies]] page about naming details.<br />
<br />
If you doubt to which repository your package belongs to you can safely use '''testing'''. Building package in your aports/testing directory is not mandatory but this way the package is already at the right place.<br />
<br />
{{:Include:Newapkbuild}}<br />
<br />
{{Note|On older Alpine systems, abuild -c -n ''packagename'' was the way to create APKBUILD files. The 'packagename' was a parameter to the -n option so order of -c and -n matters. }}<br />
<br />
[[Abuild_and_Helpers#apkbuild-cpan|apkbuild-cpan]] simplifies the creation of perl packages from CPAN and [[Abuild_and_Helpers#apkbuild-pypi|apkbuild-pypi]] ease the generation of APKBUILD files for python packages from PyPi. <br />
<br />
If you are creating a daemon package which needs initd scripts you can add the -c making it: <br />
<br />
{{Cmd|newapkbuild -c ''packagename''}}<br />
<br />
This will copy the sample initd and confd files to the build directory.<BR><br />
A third file sample.install file will be copied as well (we will discuss this later on).<br />
<br />
=== Modify your APKBUILD ===<br />
Edit APKBUILD and fill in the needed info (especially pkgname, pkgver, pkgdesc, url, license, depends and source). <br />
<br />
If you are going to use any of the variables for directories like $pkgdir, always make sure they are double quoted like: <br />
<br />
"$pkgdir"/somedir<br />
<br />
This will prevent issues with spaces/special characters in the future. <br />
<br />
{{Note|If you like syntax highlighting we suggest you to install vim. We have setup vim to recognize the APKBUILD file as a bash scripts so its easier to read them.}}<br />
<br />
=== APKBUILD variables/functions ===<br />
<br />
==== source ====<br />
<br />
The source variable is not only used to list the remote source files to fetch, it is also used to list the local files that abuild will need in order to build the apk. Examples of such local files include: init.d files, conf.d files, install files (see [[Creating an Alpine package#install|install variable]]), patches, and all other necessary files.<br />
<br />
Here are few things to note:<br />
<br />
* When you are finished adding local and/or remote files to ''source'', you can execute the following command to add their checksums to the APKBUILD file:<br />
: {{cmd|abuild checksum}}<br />
: {{Note|When later updating the content of ''source'', or updating a file that is listed in ''source'', you must also update their checksums again with the same command.}}<br />
<br />
* When the remote file is hosted at SourceForge, it's best to specify the special mirrors link used by SourceForge:<br />
: <pre>http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz</pre><br />
: (or similar depending on the package).<br />
<br />
* When the remote filename is not specified in the URI (ie, does not end in '/software-1.0.tar.gz'), such as:<br />
: <pre>http://oss.example.org/?get=software&ver=1.0</pre><br />
: You must prepend '${pkgname}-${pkgver}.tar.gz::' to the protocol, like so:<br />
: <pre>source="${pkgname}-${pkgver}.tar.gz::http://oss.example.org/?get=software&ver=1.0"</pre><br />
: This causes the file to be saved as ''software-1.0.tar.gz'' where abuild can use it, instead of ''?get=software&ver=1.0'', where abuild cannot use it.<br />
<br />
* Some projects didn't provide a release tarball. Beware that some git services (gitweg, cgit, …?) doesn’t provide ''stable'' tarballs, so when you point source to an tarball like <tt>http://repo.or.cz/w/gitstats.git/snapshot/ad7efbb9399e60cee6cb217c6b47e604174a8093.tar.gz</tt>, then you will run into issues because the checksum changes when downloading on the build system. This is not a problem on GitHub, GitLab and other decent services provides, they provide ''stable'' tarballs.<br />
<br />
* abuild currently supports the following protocols for remote file retrieval:<br />
** http<br />
** https<br />
** ftp<br />
<br />
<!--: {{Note|If the you want to download from https, you need GNU wget installed on your system.}}--><br />
<br />
* abuild currently supports the following archive types/archive file extensions:<br />
** .tar<br />
** .tar.gz / .tgz<br />
** .tar.bz2<br />
** .tar.lz (only in Alpine >=3.7)<br />
** .tar.lzma<br />
** .tar.xz<br />
** .zip<br />
<br />
==== depends &amp; makedepends ====<br />
<br />
Depends are the actual running dependencies that a package would need when it is running. Makedepends are only needed when you are building a package. If you set a package, in depends you do not need to add it to makedepends as well. The best way to find out what the depends and makedepends of a package are is to [http://en.wikipedia.org/wiki/Rtfm RTFM]. <br />
<br />
No kidding, lots of important information can be found it the package INSTALL and README file (or the likes). Another good way is the run <code>./configure --help</code> from the source directory to see which options are needed for configure to finish without errors. If you do not yet have a source directory you can create one with the command: <br />
<br />
{{Cmd|abuild unpack}}<br />
<br />
Running <code>configure</code> will also show you how you can disable a specific option for this package. A good example is for instance "--disable-nls" which will disable native language support and thus does not depend on gettext (libiconv, glib, ...). <br />
<br />
Alpine likes to keep things small, so we try to disable as much as possible without losing too many features. The exact disable/enable options are decided the package builder but please try to follow Alpine's design concept as much as possible.<br />
<br />
An easy way of quickly finding out the build info for a package is to check Arch Linux (Alpine package management and build scripts are similar) or Gentoo Linux ebuilds (previous versions of Alpine were based on Gentoo).<br />
<br />
* [https://gitweb.gentoo.org/repo/gentoo.git/tree/ Gentoo Ebuilds] <br />
* [http://www.archlinux.org/packages/search/ Arch Linux packages] [https://aur.archlinux.org/ Arch Linux User Repository]<br />
<br />
After the package is successfully compiled and created we should make sure it didn't link to any package that is not present in the <code>$depends</code> variable. We do this by using <code>scanelf</code>. If scanelf is not yet installed on your system you can do that by installing {{Pkg|pax-utils}}.<br />
<br />
{{Cmd|scanelf -nR pkg}}<br />
<br />
An example output of {{Pkg|libcurl}} would be: <br />
<br />
ET_DYN libssl.so.0.9.8,libcrypto.so.0.9.8,libz.so.1,libc.so.0,ld-uClibc.so.0 pkg/usr/lib/libcurl.so.4.1.1<br />
<br />
You can see the needed files and should be able to find out which file belongs to which package.<br />
<br />
==== license ====<br />
<br />
The '''license''' tag must reflect the license of the source code. Please check the source tarball for COPYING, LICENSE, or other files with names that indicates that it contains licensing information. Beside the license file most developer include headers in the source code files with licensing details.<br />
<br />
If the license is on the [https://spdx.org/licenses/ SPDX License List] or [https://spdx.org/licenses/exceptions-index.html SPDX License Exceptions], use the identifier specified by SPDX.<br />
<br />
If a package has a special/custom license or is not listed as [https://opensource.org/licenses/alphabetical OSI approved] we need to provide it with the release. Because we want to save space and don't like to have licenses all over our system we have decided to include the license in the doc subpackage. Please follow the following guidelines to add a proper license. Locate the license file inside the source package. Add the doc subpackage to the $subpackages variable as follows: <br />
<br />
subpackages="$pkgname-doc"<br />
<br />
Add a similar line to the following to your package() function, depending on the license description file: <br />
<br />
install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING<br />
<br />
If you follow these steps then abuild will automatically add the license to the package-doc apk for you.<br />
<br />
{{Warning|It is not acceptable to package software with "unknown" license! If you can't find the license of the source code, please contact the author and ask them to specify the license. }}<br />
<br />
==== arch ====<br />
<br />
The package architecture(s) to build for. This can be one of: ''x86, x86_64, all,'' or ''noarch'', where ''all'' means all architectures, and ''noarch'' means it's architecture-independent (ie, a pure-python package).<br />
{{Tip|To determine if your APKBUILD can use ''noarch'', build the package for your architecture and then run "scanelf -R pkg" from the directory that the APKBUILD resides in, in order to scan for ELF files in the ''./pkg'' directory. If you do NOT get output from this, then ''noarch'' can be used.}}<br />
<br />
==== url ====<br />
<br />
Website address for the program. This is usefully later on when either finding documentation or other information about the package.<br />
<br />
==== pkgdesc ====<br />
<br />
A brief, one line, description of what the package does. Useful for the package management system. It should start with a capital letter and does '''not''' end with a period.<br />
<br />
Here is an example from apk_info for the OpenSSH client package:<br />
<br />
pkgdesc="Port of OpenBSD's free SSH release - client"<br />
<br />
==== pkgver ====<br />
<br />
Provide the release number of the package you are building.<br />
<br />
==== pkgrel ====<br />
<br />
The $pkgrel versioning is made so if you change something to your APKBUILD file without changing the actual $pkgver you can increment pkgrel so apk tools will detect it as an update. For instance if you forget to add a dependency you can add it afterward and you can +1 pkgver so apk finds this update and add the missing dependency. When there's an upstream version changes, we reset the pkgrel to 0.<br />
<br />
==== pkgname ====<br />
<br />
The base name of the package you are creating. For Freeswitch 1.0.6, you would use "freeswitch"<br />
<br />
==== install ====<br />
<br />
There are 6 different kinds of install scripts. Each script is called with the $pkgname.''<action>'' where ''<action>'' is one of the following:<br />
<br />
<dl><br />
<dt>$pkgname.pre-install<br />
<dd>This script is executed before package is installed. Typical use is when package needs a group and a user to be created. For example:<br />
<pre><br />
#!/bin/sh<br />
<br />
addgroup -S clamav 2>/dev/null<br />
adduser -S -D -H -s /bin/false -G clamav -g clamav clamav 2>/dev/null<br />
<br />
exit 0<br />
</pre><br />
Note the ''exit 0'' at the end. If the script exits with failure (if the user already exist), the package will not be installed and <code>apk add</code> will exit with failure.<br />
<br />
<dt>$pkgname.post-install<br />
<dd>This script is executed after package is installed. Can be used to generate font cache and similar.<br />
<br />
<dt>$pkgname.pre-upgrade<br />
<dd>Same as pre-install but is executed before upgrading/downgrading/reinstalling an already installed package. Note that exiting with failure will not cause apk to exit with failure, but will mark the package as broken.<br />
<br />
<dt>$pkgname.post-upgrade<br />
<dd>Same as post-install but is executed after upgrading/downgrading/reinstalling an already installed package. <br />
<br />
<dt>$pkgname.pre-deinstall<br />
<dd>This script is executed before uninstalling a package. If script exits with failure apk will not uninstall the package.<br />
<br />
<dt>$pkgname.post-deinstall<br />
<dd>This script is executed after a package have been uninstalled. Can be used to update font caches and restore busybox links. For example:<br />
<pre><br />
#!/bin/sh<br />
busybox --install -s<br />
</pre><br />
<br />
</dl><br />
<br />
If the package have an pre-install and post-install script the APKBUILD should have the ''install'' variable defined:<br />
<pre><br />
...<br />
install="$pkgname.pre-install $pkgname.post-install"<br />
<br />
...<br />
</pre><br />
<br />
==== subpackages ====<br />
<br />
$subpackages are made to split up the normal "make install" into separate packages. The most common subpackages we use are doc and dev. Because we like to keep our target system small we move documentation and development files (only needed when building packages) into separate packages. To use the specific program a user only need to install the base apk without package-doc or package-dev, but if he wants to read the manual he will need to install package-doc. <br />
<br />
The easiest way to find out if you need to use -dev and -doc is to first build the package without these options set and wait until the build finishes. When its finished you should have a pkg directory which is the fake root directory. Inside this directory you will see the structure as how it would be installed in / on the target system. <br />
<br />
To see if you need the -dev package you can run the following cmd: <br />
<br />
{{Cmd|find pkg/usr/ -name '*.[acho]' -o -name '*.la'}}<br />
<br />
If this returns any files you need to include the -dev package. <br />
<br />
<br> To see if you need the -doc package you can run the following cmd: <br />
<br />
{{Cmd|find pkg/usr/share -name doc -o -name man -o -name info -o -name html -o -name sgml -o -name licenses}}<br />
<br />
If this returns any directories you need to include the -doc package. <br />
<br />
===== Custom subpackages =====<br />
<br />
Some software additionally has non-essential files that do not qualify as either documentation or development content. These files should be placed in their own, specialized subpackage(s). Some packages include large test suites which are only needed in specific circumstances or binaries which have depends which we prefer not to install. To handle those we create our own package/function. In the APKBUILD below the build() function we create another function: <br />
<br />
test() {<br />
mkdir -p "$subpkgdir"/usr<br />
mv "$pkgdir"/usr/package-test "$subpkgdir"/usr/<br />
}<br />
<br />
<br />
We also need to add the package info to $subpackages variable: <br />
<br />
subpackages="$pkgname-doc $pkgname-dev $pkgname-test"<br />
<br />
After we finish building the package you should see another apk called packagename-test.apk which includes the files which we moved to the $subpkgdir dir. <br />
<br />
The above mentioned variables can also be used in our custom function. If we want for instance to build the test() function with perl support we would add: <br />
<br />
depends="perl"<br />
makedepends="perl-dev"<br />
<br />
If we would install the base package it would not install perl, but if we install the package-test package it would.<br />
<br />
==== Patches ====<br />
<br />
Please make sure you always submit human readable patches. Way's to create them are: <br />
<br />
directory compare: <br />
<br />
{{Cmd|diff -urp original_directory new_directory &gt; filename.patch}}<br />
<br />
file compare: <br />
<br />
{{Cmd|diff -up original.file new.file &gt; filename.patch}}<br />
<br />
If a patch contains a completely new file but not *.rej or *.orig file, you need to add -N option to diff, but you may need to add exclusions with <code>--exclude PATTERN</code> so that you do not inadvertently add files. You may need to manually delete unwanted files inside the patch file.<br />
<br />
Because multiple patches can patch the same file, we could create offset for the next patch. To make sure we always patch in a specified way we should number the patches as followed: <br />
<br />
10-patch1.patch 20-patch2.patch 30-patch3.patch<br />
<br />
This way we are always sure patch 1 is first and if we want to add additional patches between them we can use 11,12,21,22...<br />
<br />
Add names of the patch files to the ''source'' variable. If you haven't declared custom ''prepare'' function, then it's all what you need to do. Otherwise call ''default_prepare'' in your ''prepare'' function, for example:<br />
<br />
prepare() {<br />
default_prepare<br />
<br />
# do your stuff<br />
}<br />
<br />
Note: Some older packages contain for loop in the ''prepare'' function to apply patches. This is not needed anymore, patches are handled by ''default_prepare''.<br />
<br />
In Alpine >=3.4 you can define patch_args to supply the patch level. It only works if all the patches have the same patch level. If there are a lot of patches from different sources, there is a good chance that you may need to edit it and it is discussed below.<br />
<br />
To automatically patch the package without problems (available only in Alpine >=3.4) if it uses a different patch level (-pX) with the default -p1, you need to modify the patch carefully. First you may need a text editor that will not automatically convert to between Windows and Unix new lines (or disable that feature) so it preserves the old code. The next thing you need is to modify the paths on +++ --- lines in the .patch file. You can begin the path with a/ and b/ like below. Next, you need to adjust the paths so the relative base path is from inside $builddir. Anything to the left of $builddir including $builddir itself needs to be truncated from the path. So if $builddir is /home/USER/aports/community/chromium/src/chromium-65, you need to erase it on those +++ and --- lines. Inside chromium-65 folder is where you can see the src folder that has 3rdparty as a descendant. If a patch originally have a deeper patch level, you may need to fill in the missing portion to the path. Use <code>find . -name "Assertions.cpp"</code> cmd for example to find the full path to the file relative to the base.<br />
<br />
{{Cat|example.patch|<nowiki><br />
Author: John Doe <johndoe@mail.com><br />
URL: http://.....<br />
Summary: Fixes musl compatibility<br />
----<br />
--- a/src/3rdparty/chromium/third_party/WebKit/Source/wtf/Assertions.cpp.orig<br />
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/wtf/Assertions.cpp<br />
@@ -142,7 +142,7 @@<br />
};<br />
<br />
FrameToNameScope::FrameToNameScope(void* addr) : m_name(0), m_cxaDemangled(0) {<br />
-#if OS(MACOSX) || (OS(LINUX) && !defined(__UCLIBC__))<br />
+#if OS(MACOSX) || (OS(LINUX) && defined(__GLIBC__))<br />
Dl_info info;<br />
if (!dladdr(addr, &info) || !info.dli_sname)<br />
return;<br />
</nowiki>}}<br />
<br />
Portions of the patch may be outdated, removed completely as in the source code file completely removed, or moved or renamed files. You need to delete that section of the patch or find where that section of code changed and re-diff it.<br />
<br />
It is good etiquette to give credit at the top and the location of where you originally found them with notes.<br />
<br />
Excluding patches with global variable resembling patch_opts is not available on Alpine. To exclude patches you need to create your own custom prepare().<br />
<br />
If you have a monolithic patch where there are a bunch of patches in one big patch, you could use filterdiff which is available in the patchutils package.<br />
<br />
Just do something like:<br />
<br />
<pre><br />
makedepends="patchutils"<br />
<br />
prepare() {<br />
...<br />
cd "$builddir"<br />
filterdiff -x '*drivers/video/logo*' "$srcdir"/original.patch > "$builddir"/modified.patch<br />
patch -p1 -i "$builddir"/modified.patch<br />
}<br />
</pre><br />
<br />
You need to put the wildcard pattern in single quotes for it to work.<br />
<br />
==== Configure options ====<br />
<br />
Alpine has some default configure options we set by default. We use /usr for prefix to make sure everything is installed with /usr in front of it. If you notice that anything is installed in the wrong directory please run {{Cmd|./configure --help}} and see if you can set the correct location. <br />
<br />
We are not covering the depend switches here we have discussed this already in the depend section.<br />
<br />
<br />
==== Make options ====<br />
<br />
If you notice weird problems when compiling or installing the package with make/make install you could try to disable [http://www.gnu.org/software/make/manual/make.html#Parallel parallel] building/installing. A normal make line would be: <br />
<br />
make<br />
<br />
To disable parallel we use: <br />
<br />
make -j1<br />
<br />
We can use the same for make install. <br />
<br />
Because we do not want to install the package in our build environment but we want to install it in a fake root directory we need to tell 'make install' to use another destination directory instead of '/'. We do this by setting a variable when we execute make install as followed: <br />
<br />
make DESTDIR="$pkgdir" install<br />
<br />
Please note that some Makefiles do not support this variable and will always install software in '/'. To make sure you do not mess up your build system NEVER run your build system as root but always use a custom user and sudo when needed. If by accident the Makefile does not support DESTDIR variable it will fail to install in our build system system directories.<br />
<br />
==== builddir ====<br />
If you used <tt>newapkbuild</tt> to create your APKBUILD file, you must specify the path to your unpacked sources. Inside the sections during the prepare/build/install process ''builddir'' is used. Most of the time a combination of ''$srcdir'' and ''$pkgname-$pkgver'' will work. When not, check the /src directory or the source tarball for the right string. Especially when you are working with automatically generated tarballs (like from github and gitorious), this needs to be adjusted.<br />
<br />
builddir="$srcdir"/$pkgname-$pkgver<br />
<br />
==== Additional files ====<br />
<br />
If you want/need to install additional files not mentioned above you can use the following cmd (this is an example of a conf file): <br />
<br />
install -Dm644 doc/$pkgname.conf "$pkgdir"/etc/$pkgname.conf<br />
<br />
== Build the package ==<br />
<br />
If you did not already create the checksums as mentioned above you can do so now: <br />
<br />
{{Cmd|cd $pkgname<br />
abuild checksum}}<br />
<br />
It's about time we build our package. Because a build system should never have all the package installed to prevent linking to packages we don't want it to link we use a abuild recursively with the '''-r''' switch. It will install all dependency's from your repository and builds it, afterwards it will uninstall all those depending packages again. You could also use the '''-R''' switch which would build your package including the dependency packages. <br />
<br />
{{Cmd|abuild -r}}<br />
<br />
== Testing the package locally ==<br />
<br />
When it completes, your package will be found in a subfolder of ''~/packages''. You may want to test it on your machine but only if the package is not a critical system package like musl or apk-tools package. To avoid borking your system (as in making it impossible to use <code>apk add</code> or to restore back the system and the compiler toolchain) for a critical system package, you should test on a chroot first before using it live.<br />
<br />
To install the package, you could:<br />
{{Cmd|sudo apk add /home/<USER>/packages/testing/x86_64/$pkgname-$pkgver.apk}}<br />
<br />
Or, modify your /etc/apk/repositories so that it points to your local ARCH/APKINDEX.tar.gz. Change USER to your login name.<br />
<br />
{{Cat|/etc/apk/repositories|<br />
/home/USER/packages/testing/<br />
/home/USER/packages/community/<br />
/home/USER/packages/main/<br />
/media/sdc/apks<br />
#http://dl-2.alpinelinux.org/alpine/v3.7/main<br />
#http://dl-2.alpinelinux.org/alpine/v3.7/community<br />
http://dl-2.alpinelinux.org/alpine/edge/main<br />
http://dl-2.alpinelinux.org/alpine/edge/community<br />
http://dl-2.alpinelinux.org/alpine/edge/testing<br />
}}<br />
<br />
== Code review ==<br />
<br />
To successfully have your package pass through code reviewers (as of Feb 18, 2018 are nmeum and jirutka on GitHub) and possible increased acceptance, the following conventions need to be followed:<br />
<br />
# Custom global variables should be prefixed with underscore (_).<br />
# Remove unnecessary new lines.<br />
# Compact code as in merged commands, removed unused variables, removal of functions that do the same thing that are automatically handled by abuild.<br />
# Versioning is done properly. For details see [[APKBUILD_Reference#pkgver]].<br />
# Licensing is done properly. Remove unnecessary copying of licensing that is already OSI approved.<br />
# Naming conventions rules for unofficial variables as in _gitrev is preferred over commit.<br />
# Indent with tabs not spaces.<br />
# Removal of explicit return 1. (They are still found the old APKBUILD files if you are learning but are now strongly discouraged.)<br />
# Disabling check() requires either (1) a comment (#) stating next to options="!check" that there is no test suite/unit tests or (2) functioning working check() function.<br />
# Explicit call to subpackages="$pkgname-doc" must be used instead of explicit gzip man page compression.<br />
# Ideally, lines should be no more than 80 columns wide<br />
<br />
For more information see [[Development using git:Quality assurance]] and [[Package_policies]].<br />
<br />
== Commit your work ==<br />
<br />
After you successfully build your package and properly followed the conventions and requirements in the code review section, you can submit your APKBUILD to Alpine's git repository. <br />
<br />
Update your git repo, before adding new files: <br />
<br />
{{Cmd|cd $aportsdir<br />
git pull}}<br />
<br />
This should pull all the changes made by others into you local git repo.<br />
<br />
When you think you are ready you can add your files to git: <br />
<br />
NOTE: when using our github repo, you can create PR's for each package. Please squash all commits into a single one per PR.<br />
<br />
{{Cmd|cd $aportsdir<br />
git add testing/$pkgdir (include any other files needed for the build; $pkgname.install...)<br />
git commit}}<br />
<br />
Use the following commit message template for new aports (without the comments):<br />
<br />
{{Cat|template|testing/$pkgname: new aport # this will be the subject line<br />
# a blank line<br />
$url # project homepage<br />
$pkgdesc # one line description}}<br />
<br />
Or you could add the following and <code>chmod +x ports/.git/hooks/prepare-commit-msg</code> to automatically generate commit message which the default aports/.githooks/ does not:<br />
<br />
{{Cat|aports/.git/hooks/prepare-commit-msg|<nowiki>#!/bin/sh<br />
case "$2,$3" in<br />
,|template,)<br />
if git diff-index --diff-filter=A --name-only --cached HEAD \<br />
| grep -q '/APKBUILD$'; then<br />
meta() { git diff --staged | grep "^+$1" | sed 's/.*="\?//;s/"$//';}<br />
printf 'testing/%s: new aport\n\n%s\n%s\n' "$(meta pkgname)" \<br />
"$(meta url)" "$(meta pkgdesc)" "$(cat $1)" > "$1"<br />
else<br />
printf '%s\n\n%s' `git diff-index --name-only --cached HEAD \<br />
| sed -n 's/\/APKBUILD$//p;q'` "$(cat $1)" > "$1"<br />
fi;;<br />
esac</nowiki>}}<br />
<br />
Now your changes are only available locally in your repository.<br />
<br />
Because you do not have push rights to the Alpine aports repository you need to create a pull request to [https://github.com/alpinelinux/aports/ Alpine's mirror on GitHub] (read instructions [https://github.com/alpinelinux/aports/blob/master/.github/CONTRIBUTING.md here]).<br />
<br />
Alternatively you can also create a diff (patch) of the changes you made and send this patch to the <br />
[http://lists.alpinelinux.org/alpine-aports/ alpine-aports mailinglist].<br />
<br />
To create a diff patch:<br />
<br />
{{Cmd|git format-patch HEAD^}}<br />
<br />
or if you have sprunge, you can create a link to your patch for convenience<br />
<br />
{{Cmd|git format-patch HEAD^ --stdout <nowiki>|</nowiki> sprunge}}<br />
<br />
== Travis CI and automated testing ==<br />
<br />
Travis CI, as in continuous integration automated testing, isn't always required, but 99% of the time it is strongly encouraged to pass with a green checkmark. Passing Travis CI ensures that your package works on another machine and builds the image starting from nothing. One reason why your package fails to build on the remote server is that you may inadvertently add a package dependency as in creating multiple packages at the same time or forgot to remove a dependency and forgot to mark it as a makedepends.<br />
<br />
When you submit your APKBUILD as a pull request, the Travis CI server will construct the build environment from [https://github.com/alpinelinux/aports/blob/master/.travis/install-alpine#L28 main] [https://github.com/alpinelinux/aports/blob/master/.travis/common.sh#L5 Edge] apks.<br />
<br />
The environment is just like a boot into command line so it is minimal. Don't assume that you boot into X.<br />
<br />
The server/configuration cannot do testing/check() testing on hardware accelerated OpenGL apps.<br />
<br />
== Send a patch ==<br />
<br />
[[Creating_patches#Only_the_last_commit_with_.27git_send-email.27|git send-email]] will do that for you.<br />
<br />
== GitHub Tagging ==<br />
<br />
If you see your pull requested labeled on GitHub this is what they mean:<br />
<br />
*A-add - The pull requester wanted to add this brand new package.<br />
*A-upgrade - The pull requester wanted to update the package.<br />
*A-improve - The pull requester wanted to improve an existing package.<br />
*A-fix - The pull requester wanted to fix a bug with the existing package.<br />
*S-changes-requested - An admin wants you to add or remove a subpackage or fix something as in messy code.<br />
*S-needs-review - An admin needs someone to do a code review on your package.<br />
*S-broken - The package fails to build locally on the code reviewer machine.<br />
*ci-malfunction - Travis CI doesn't work with this package as in exceeded time.<br />
<br />
== See Also ==<br />
* [[APKBUILD Reference]]<br />
* [[APKBUILD examples]]<br />
* [[Development using git]]<br />
* [[Development using git:Quality assurance]]<br />
<br />
[[Category:Development]]</div>Dholehttps://wiki.alpinelinux.org/w/index.php?title=Include:Setup_your_system_and_account_for_building_packages&diff=15239Include:Setup your system and account for building packages2018-04-23T08:03:39Z<p>Dhole: fix typo</p>
<hr />
<div>The {{Pkg|alpine-sdk}} is a metapackage that pulls in the most essential packages used to build new packages. Install those packages now: <br />
<br />
{{Cmd|apk add alpine-sdk}}<br />
<br />
This would be a good time to create a normal user account for you to work in. (You weren't going to develop as root now, were you!) To create the user:<br />
<br />
{{Cmd|adduser <yourusername>}}<br />
<br />
To make life easier later, it's a good idea to add this user to {{Path|/etc/sudoers}}. Append the line<br />
<br />
<yourusername> ALL=(ALL) ALL<br />
<br />
using the command:<br />
<br />
{{Cmd|visudo}}<br />
<br />
Now logout of the root account, and login as <yourusername>. From here on everything can be done in a normal user account, and operations that require superuser privileges can be done with sudo.<br />
<br />
The [[Aports_tree|aports tree]] is in git so before we clone the it, let's configure git.<br />
<br />
{{Cmd|git config --global user.name "Your Full Name"<br />
git config --global user.email "your@email.address"}}<br />
<br />
Read carefully [[Development using git]] to grasp basic Git operations and how to configure for sending email patches.<br />
<br />
Now we can clone the [[Aports_tree|aports tree]]. <br />
<br />
NOTE: You can also clone aports from our github https://github.com/alpinelinux/aports<br />
<br />
{{Cmd|git clone git://git.alpinelinux.org/aports}}<br />
<br />
Before we start creating or modifying [[APKBUILD_Reference|APKBUILD]] files, we need to setup abuild for our system and user. Edit the file {{Path|abuild.conf}} to your requirements:<br />
<br />
{{Cmd|sudo vi /etc/abuild.conf}}<br />
<br />
Most of the defaults can be left alone, unless you are developing for a custom platform, in which case the comments in the file should guide you. The one field to edit is PACKAGER, so that you can get credit (or blame) for packages you create.<br />
<br />
To use 'abuild -r' command to install dependency packages automatically.<br />
{{Cmd|sudo addgroup <yourusername> abuild}}<br />
<br />
We also need to prepare the location where the build process caches files when they are downloaded. By default this is {{Path|/var/cache/distfiles/}}. To create this directory and ensure that it is writeable, enter the following commands:<br />
<br />
{{Cmd|sudo mkdir -p /var/cache/distfiles<br />
sudo chmod a+w /var/cache/distfiles}}<br />
<br />
As an alternative to the second command, you can add yourself to the abuild group:<br />
<br />
{{Cmd|sudo chgrp abuild /var/cache/distfiles<br />
sudo chmod g+w /var/cache/distfiles}}<br />
<br />
{{Note|Remember to logout and login again for the group change to have effect.}}<br />
<br />
The last step is to configure the security keys with the [[Abuild-keygen|abuild-keygen]] script for [[Abuild|abuild]] with the command:<br />
<br />
{{Cmd|abuild-keygen -a -i}}<br />
<br />
[[Category:Development]]</div>Dholehttps://wiki.alpinelinux.org/w/index.php?title=Include:Apkbuild-pypi&diff=15238Include:Apkbuild-pypi2018-04-21T03:53:13Z<p>Dhole: fix typo</p>
<hr />
<div>The [http://pypi.python.org/pypi Python Package Index] (PyPi) is a repository of software and libraries for the Python programming language. <tt>apkbuild-pypi</tt> helps with the creation of APKBUILD for python package hosted at PyPI.<br />
<br />
{{Cmd|apkbuild-pypi [create <package> <nowiki>| check | recreate | update | upgrade</nowiki>}}<br />
<br />
[[Category:Development]] [[Category:Python]]</div>Dholehttps://wiki.alpinelinux.org/w/index.php?title=Include:Abump&diff=15237Include:Abump2018-04-21T03:50:33Z<p>Dhole: fix typo</p>
<hr />
<div>The tool <tt>abump</tt> is an utility to bump pkgver in APKBUILD files if the package gets an update to a newer upstream release.<br />
<br />
{{Cmd|<nowiki>abump [-hR]</nowiki>}}<br />
<br />
'''abump options'''<br />
<br />
* '''-h''' Show this help<br />
* '''-R''' Run abuild with -R for recursive building<br />
* '''-k''' Keep existing packages<br />
<br />
[[Category:Development]]</div>Dhole