Repositories: Difference between revisions

From Alpine Linux
(Fix confusion of terms branch and repository)
m (fixed sentence)
 
(51 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{TOC right}}
{{TOC right}}


There are three repositories:
A [https://en.wikipedia.org/wiki/Software_repository repository] is a storage location with a collection of Alpine Linux [[Alpine Package Keeper#Packages and Repositories|packages]]. In addition to the three [[#Official repositories|official repositories]], technically, any directory with a collection of *.apk files with a special index file, named {{Path|APKINDEX.tar.gz}} can be considered a repository, albeit a personal repository. [[Alpine Package Keeper|Alpine Package Keeper(apk)]] loads repository definitions from {{Path|/etc/apk/repositories}}, has sub-commands to query repositories and maintain the desired system state as per [[Alpine_Package_Keeper#World|world]].


* '''main''' packages are the software that have direct support and updates from the Alpine core and main team. They also have official special documentation, are always available for all releases and will have substitutions if some are not continued from upstream. Commonly these packages are selected due to their responsibility and stability with respect to upstream availability. Packages from ''community'' or (rarely) ''testing'', that are accepted go to the ''main'' repository.
== Official repositories ==


* '''community''' packages are those made by users in team with the official developers and close to the Alpine package process. They are supported by those user(s) contributions and could end if the user(s) stops; they may also be removed in a future release due to lack of support by upstream authors. Packages from ''testing'' that are accepted go to the ''community'' repository.
There are three official package repositories available in Alpine Linux i.e [[#Main|main]], [[#Community|community]] and [[#Testing|testing]]. These repositories directly correspond to three directories of [[Aports tree|aports]].


* '''testing''' packages are where new packages go. These are made by any contributor to Alpine. Testing has no release linked. The ''testing'' repository is only available on ''edge''. Packages from ''testing'' that are accepted go to the ''community'' repository or (rarely) the ''main'' repository.
=== Main ===


= Managing repositories =
Packages in '''main''' repository are the software that have direct support and updates from the Alpine core team. Alpine Linux tries to limit the amount of packages in ''main'' to only include base system packages, i.e packages which are needed by other packages or are needed to setup a basic system.


To enable a repository, remove the '''#''' in front of the URL along with any blank space.
=== Community ===


Example: Disabled
Packages in '''community''' repository are those made by users in team with the official developers and close to the Alpine package process. They are supported by those user(s) contributions and could end if the user(s) stops; they may also be removed in a future release due to lack of support by upstream authors.  
{{cat|/etc/apk/repositories|#http://dl-cdn.alpinelinux.org/alpine/v3.16/community}}


Example: Enabled
If packages from community repository are used, one needs to [[Upgrading_Alpine#Upgrading_to_latest_release|upgrade to the latest stable release branch]] to continue to have support.
{{cat|/etc/apk/repositories|http://dl-cdn.alpinelinux.org/alpine/v3.16/community}}


To edit the repositories, open the <code>/etc/apk/repositories</code> file in a text editor:
=== Testing ===


{{cmd|# <editor> /etc/apk/repositories}}
The ''testing'' repository is only available on [[#Edge|edge]] branch i.e development branch and this is where new packages go. These are made by any contributor to Alpine Linux. Packages from ''testing'' that are accepted go to the ''community'' repository or (rarely) to the ''main'' repository. Packages in ''testing'' have no support (staging only) and are built only for [[#Edge|edge]] branch.


The default will look something like:
== Release Branches ==


{{cat|/etc/apk/repositories|#/media/cdrom/apks
Each stable release branch of Alpine Linux has its own main and community repositories. [https://alpinelinux.org/releases/ Releases] page has information on all the release branches along with support status. Support entails security patches for the given feature versions.  
http://dl-cdn.alpinelinux.org/alpine/v3.16/main
#http://dl-cdn.alpinelinux.org/alpine/v3.16/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing}}


After making changes to <code>/etc/apk/repositories</code> you should update the package index using:
'''The current stable release branch of Alpine Linux is {{#expr:{{AlpineLatest}}}}'''.
{{cmd|# apk update}}


=== Changing repositories to https ===
== Edge ==
For better security you should probably change the url's from '''http''' to '''https'''. [https://en.wikipedia.org/wiki/HTTPS#Technical]


{{Note|Some Alpine Linux package mirrors may not support '''https'''. If that is the case, you will need to change mirrors or revert back. You can check if your mirror supports '''https''' on https://mirrors.alpinelinux.org }}
''edge'' is the name given to the current [[Aports tree|development tree]] of Alpine Linux.  ''edge'' branch includes all  three [[#Official repositories|official repositories]] and contains the latest build of all available Alpine Linux packages. Those packages are updated on a regular basis. Since ''edge'' is a development branch, many changes are not heavily tested (or tested at all) and packages can and sometimes do break without warning. ''edge'' can be considered as '''rolling release version''' of Alpine Linux.


=== Avoid manually changing the repositories file for a new release ===
[[#Upgrading to edge|Upgrading to Edge]] branch and/or installing packages from [[Repositories#Testing|testing]] repository and submitting '''[https://gitlab.alpinelinux.org/alpine/aports/issues bug reports]''' is one of the best ways to [[Contribute|contribute]] to Alpine Linux. This is a very valuable activity which helps Alpine Linux development, as it ensures that the quality of stable releases is high.


You can avoid having to manually update the version in <code>/etc/apk/repositories</code> for each Alpine Linux release by changing <code>v3.16</code> to <code>latest-stable</code>.
The current installed edge version i.e the build date that is attached to the '''edge''' release may be checked with command:{{Cmd|$ cat /etc/alpine-release}}
{{Warning|Do not use [[#Edge|''edge'' branch]] in production, or if you desire deterministic, repeatable package installation (such as with containerized environments) via [[Alpine Package Keeper#Package pinning|package pinning]] as it is under constant development and instead use a [[#Release Branches|stable release branch]].}}


Example:
== Managing repositories ==
{{cat|/etc/apk/repositories|#/media/cdrom/apks
https://dl-cdn.alpinelinux.org/alpine/latest-stable/main
https://dl-cdn.alpinelinux.org/alpine/latest-stable/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing}}


{{Warning|Changing the repositories to <code>latest-stable</code> may initiate unexpected release upgrades.}}
The package repositories that <code>apk</code> uses to retrieve package files for installation are specified in file {{path|/etc/apk/repositories}}. Each line of {{path|/etc/apk/repositories}} specifies the location of a package repository, one repository per line and optionally a tag. Lines that start with a hash character (#) are ignored.


= Release Branches =
The location may be an <code>http://</code> or <code>https://</code> URL, or the path to a directory on the local filesystem. If you booted from a USB stick ({{Path|/media/sda1}}) or CD-ROM ({{Path|/media/cdrom}}), your repository file probably looks something like this: {{Cat|/etc/apk/repositories|/media/sda1/apks/}}


There are several release branches for Alpine Linux available at the same time. Each May and November we make a release branch from '''edge'''. The '''main''' repository is typically supported for 2 years and the '''community''' repository is supported until next stable release.
{{Tip|During [[Installation]] only the [[#Main|Main]] repository is enabled, so [[#Enabling the community repository|enable the Community repository]], if required.}}


Security fixes beyond that can be made on request when there are patches available.
=== Enabling the community repository ===


== Main ==
[[Alpine setup scripts#setup-apkrepos|setup-apkrepos]] script can be used to enable [[#Community|community]] repository as follows: {{cmd|# setup-apkrepos -c}}


By default only the '''main''' repository is enabled. ''main'' has a support cycle of 2 years. We also try to limit the amount of packages in ''main'' to only include base system packages, in base you can think of packages which are needed by other packages or are needed to setup a basic system. Packages in ''main'' must '''not''' have dependencies in other repositories.
With the above change, the {{path|/etc/apk/repositories}} file will look something like: {{cat|/etc/apk/repositories|#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/main
http://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/community}}


== Community ==
{{Note| For better security you should probably change the url's from '''http''' to '''https'''. Some Alpine Linux package mirrors may not support '''https'''. If that is the case, you will need to change mirrors or revert back. You can check if your mirror supports '''https''' on https://mirrors.alpinelinux.org }}


The '''community''' repository was introduced with Alpine Linux version [https://alpinelinux.org/posts/Alpine-3.3.0-released.html 3.3.0].  ''community'' has a maximum support cycle of 6 months. After that you will need to update to the new release to continue to have support.
=== Tagged repository ===


= Edge =
A tagged repository is prefixed with the <code>@tag</code> specifier, followed by a space and the repository location in the  {{Path|/etc/apk/repositories}} file as follows.{{Cat|/etc/apk/repositories|https://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/main
https://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/community
@personal https:/personal-repo.example.com/alpine-apks/}}


''edge'' is the name given to the current [[Aports tree|development tree]] of Alpine Linux. It consists of an APK repository called ''edge'' and contains the latest build of all available Alpine Linux packages. Those packages are updated on a regular basis.
The optional <code>@tag</code>, when used as shown above indicates that the tagged repository should not be used by default.  


{{Warning|''edge'' is under constant development so be careful using it in production. It is possible that bugs in ''edge'' could cause data loss or could break your system.}}
[[apk]] will by default only use the untagged repositories, but adding a package with a @tag will make apk prefer the tagged repository for the named package, even if a later version of the package is available in another repository. It allows pulling in dependencies for the tagged package from the tagged repository (though it prefers to use untagged repositories to satisfy dependencies if possible).  


End users should not use ''edge'' as their main day-to-day workstation or as a productive system. Because ''edge'' is a development branch, many changes are not heavily tested (or tested at all) and packages in ''edge'' can and sometimes do break without warning.
For eg: {{ic|apk add busybox@personal}} enables selection of {{ic|busybox}} from a tagged repository @personal. The above command allows installation of {{ic|busybox}} and it's dependencies from the tagged repository @personal. Since tagged repositories are not prioritized, if a version of {{ic|busybox's}} dependency from an untagged repository is a better fit, it will be used.


However, testing ''edge'' is a very valuable activity which helps the Alpine Linux development to ensure that the quality of the stable releases is high. Testing ''edge'' is a great way to contribute to the Alpine Linux development.
=== Upgrading to edge ===


== Upgrading to edge ==
Follow the instructions for [[Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge|Upgrading to Edge]].


{{:Include:Upgrading to Edge}}
When using edge branch, [[Repositories#Testing|testing]] repository can be added as a [[Repositories#Tagged repository|tagged repository]]. Remember that,  packages in [[Repositories#Testing|testing]] repository have no support.


== Testing ==
{{Warning|Do not enable Main/Community repositories from both [[Repositories#Release Branches|'''stable''' release branch]]  and [[Repositories#Edge|'''edge''']] at the same time. This can break your system. Either use edge '''or''' stable. If you mix stable and edge repositories, you're on your own.}}


The '''testing''' repository was introduced with Alpine Linux ''edge'' development. No support (staging only) and only built for ''edge''. If it stays here long enough it gets moved to unmaintained/purged (gets cleaned up every 6 months).
=== Using testing repository ===


Before a package can move from ''testing'' to ''main'' or ''community'', the following requirements must be met:
Unlike [[#Edge|edge]] branch, installing packages from testing repository in a '''stable''' [[#Release Branches|release branch]] is not recommended and not guaranteed to work. However, if you need a package which is available only in the [[#Testing|testing]] repository, add '''testing''' repository as a [[#Tagged repository|tagged repository]] by editing the {{path|/etc/apk/repositories}} file as follows:{{Cat|/etc/apk/repositories|https://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/main
https://dl-cdn.alpinelinux.org/alpine/v{{#expr:{{AlpineLatest}}}}/community
@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing}}


# Package must work correctly, including the init.d script (if provided) and default configuration.
Before installing a package from testing repository, [[Alpine_Package_Keeper#Check_Dependencies|check for dependencies]]. Installing a package from testing repository that depends on libraries in main or community often won't work due to potential version mismatch. Alpine does not officially support mixing branches this way, as mixing packages from stable and edge repositories can break your system.  
# Packaging must be done correctly, with files installed in the right places, e.g. configs are in <code>/etc/</code> and not in <code>/usr/etc</code>.
# Package dependencies are handled correctly. Abuild can (and should) autodetect shared libs, for example '''sqlite-libs''' provides '''so:libsqlite3.so.0'''. Any package linked to '''sqlite''' should have an automatically (by abuild) added <code>depend=so:libsqlite3.so.0</code> and the user should not have to manually add a <code>depend="sqlite-libs"</code> in the APKBUILD.
# There is a maintainer who claims responsibility for the maintenance of the package and can help fix things if they break in the future.


=== Using the testing repository on stable branches ===
In the example command {{ic|# apk add wireguard-go@testing}}, the tag <code>@testing</code> allows [[apk]] to pull the necessary package(s) from testing repository without potentially messing up your installation (too badly).


{{Warning|'''Only do this if you're 100% sure what you're doing!''' Installing packages from edge that link to something in ''main'' or ''community'' usually will not work. Alpine does not officially support mixing branches this way.}}
== See also ==
 
Edit the file <code>/etc/apk/repositories</code> and add (or uncomment) a line that points to the "testing" directory, while also [[Package_management#Repository_pinning|tagging]] the repository, for example:
 
{{Cat|/etc/apk/repositories|
https://dl-cdn.alpinelinux.org/alpine/v3.16/main
https://dl-cdn.alpinelinux.org/alpine/v3.16/community
@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing
}}
 
In that case, the tag is <code>@testing</code>, which allows you to pull packages from that repository without potentially messing up your install (too badly):
 
$ apk add wireguard-go@testing
 
= See also =


* [[Alpine_Package_Keeper|Alpine Package Keeper]]
* [[Alpine_Package_Keeper#World| Alpine Linux '''world''' ]]
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-repositories.5.scd Manual for apk-repositories(5)]
* [[Alpine Linux in a chroot]]
* [[Alpine Linux in a chroot]]
* [http://bugs.alpinelinux.org/ Report Bugs]
* [https://bugs.alpinelinux.org/ Report Bugs]


[[Category:Development]]
[[Category:Development]]
[[Category:Package Manager]]
[[Category:Package Manager]]

Latest revision as of 05:16, 27 October 2025

A repository is a storage location with a collection of Alpine Linux packages. In addition to the three official repositories, technically, any directory with a collection of *.apk files with a special index file, named APKINDEX.tar.gz can be considered a repository, albeit a personal repository. Alpine Package Keeper(apk) loads repository definitions from /etc/apk/repositories, has sub-commands to query repositories and maintain the desired system state as per world.

Official repositories

There are three official package repositories available in Alpine Linux i.e main, community and testing. These repositories directly correspond to three directories of aports.

Main

Packages in main repository are the software that have direct support and updates from the Alpine core team. Alpine Linux tries to limit the amount of packages in main to only include base system packages, i.e packages which are needed by other packages or are needed to setup a basic system.

Community

Packages in community repository are those made by users in team with the official developers and close to the Alpine package process. They are supported by those user(s) contributions and could end if the user(s) stops; they may also be removed in a future release due to lack of support by upstream authors.

If packages from community repository are used, one needs to upgrade to the latest stable release branch to continue to have support.

Testing

The testing repository is only available on edge branch i.e development branch and this is where new packages go. These are made by any contributor to Alpine Linux. Packages from testing that are accepted go to the community repository or (rarely) to the main repository. Packages in testing have no support (staging only) and are built only for edge branch.

Release Branches

Each stable release branch of Alpine Linux has its own main and community repositories. Releases page has information on all the release branches along with support status. Support entails security patches for the given feature versions.

The current stable release branch of Alpine Linux is 3.22.

Edge

edge is the name given to the current development tree of Alpine Linux. edge branch includes all three official repositories and contains the latest build of all available Alpine Linux packages. Those packages are updated on a regular basis. Since edge is a development branch, many changes are not heavily tested (or tested at all) and packages can and sometimes do break without warning. edge can be considered as rolling release version of Alpine Linux.

Upgrading to Edge branch and/or installing packages from testing repository and submitting bug reports is one of the best ways to contribute to Alpine Linux. This is a very valuable activity which helps Alpine Linux development, as it ensures that the quality of stable releases is high.

The current installed edge version i.e the build date that is attached to the edge release may be checked with command:

$ cat /etc/alpine-release

Warning: Do not use edge branch in production, or if you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning as it is under constant development and instead use a stable release branch.


Managing repositories

The package repositories that apk uses to retrieve package files for installation are specified in file /etc/apk/repositories. Each line of /etc/apk/repositories specifies the location of a package repository, one repository per line and optionally a tag. Lines that start with a hash character (#) are ignored.

The location may be an http:// or https:// URL, or the path to a directory on the local filesystem. If you booted from a USB stick (/media/sda1) or CD-ROM (/media/cdrom), your repository file probably looks something like this:

Contents of /etc/apk/repositories

/media/sda1/apks/
Tip: During Installation only the Main repository is enabled, so enable the Community repository, if required.

Enabling the community repository

setup-apkrepos script can be used to enable community repository as follows:

# setup-apkrepos -c

With the above change, the /etc/apk/repositories file will look something like:

Contents of /etc/apk/repositories

#/media/cdrom/apks http://dl-cdn.alpinelinux.org/alpine/v3.22/main http://dl-cdn.alpinelinux.org/alpine/v3.22/community
Note: For better security you should probably change the url's from http to https. Some Alpine Linux package mirrors may not support https. If that is the case, you will need to change mirrors or revert back. You can check if your mirror supports https on https://mirrors.alpinelinux.org

Tagged repository

A tagged repository is prefixed with the @tag specifier, followed by a space and the repository location in the /etc/apk/repositories file as follows.

Contents of /etc/apk/repositories

https://dl-cdn.alpinelinux.org/alpine/v3.22/main https://dl-cdn.alpinelinux.org/alpine/v3.22/community @personal https:/personal-repo.example.com/alpine-apks/

The optional @tag, when used as shown above indicates that the tagged repository should not be used by default.

apk will by default only use the untagged repositories, but adding a package with a @tag will make apk prefer the tagged repository for the named package, even if a later version of the package is available in another repository. It allows pulling in dependencies for the tagged package from the tagged repository (though it prefers to use untagged repositories to satisfy dependencies if possible).

For eg: apk add busybox@personal enables selection of busybox from a tagged repository @personal. The above command allows installation of busybox and it's dependencies from the tagged repository @personal. Since tagged repositories are not prioritized, if a version of busybox's dependency from an untagged repository is a better fit, it will be used.

Upgrading to edge

Follow the instructions for Upgrading to Edge.

When using edge branch, testing repository can be added as a tagged repository. Remember that, packages in testing repository have no support.

Warning: Do not enable Main/Community repositories from both stable release branch and edge at the same time. This can break your system. Either use edge or stable. If you mix stable and edge repositories, you're on your own.


Using testing repository

Unlike edge branch, installing packages from testing repository in a stable release branch is not recommended and not guaranteed to work. However, if you need a package which is available only in the testing repository, add testing repository as a tagged repository by editing the /etc/apk/repositories file as follows:

Contents of /etc/apk/repositories

https://dl-cdn.alpinelinux.org/alpine/v3.22/main https://dl-cdn.alpinelinux.org/alpine/v3.22/community @testing https://dl-cdn.alpinelinux.org/alpine/edge/testing

Before installing a package from testing repository, check for dependencies. Installing a package from testing repository that depends on libraries in main or community often won't work due to potential version mismatch. Alpine does not officially support mixing branches this way, as mixing packages from stable and edge repositories can break your system.

In the example command # apk add wireguard-go@testing, the tag @testing allows apk to pull the necessary package(s) from testing repository without potentially messing up your installation (too badly).

See also