docs/README.Ubuntu.md
Rama master · réplica de lectura del repositorio original.

# Debian/Ubuntu build guide
This guide has been tested with Ubuntu 16.04.4 (Xenial) x86_64, 18.04 (Bionic) and 20.04 (Focal). Please read it in full before you proceed to familiarize yourself with the build procedure.
Several other distributions have **[specific build guides](README.md)** and a general **[Linux build guide](README.Linux.md)** is also available.
## Table of Contents
1. **[Document conventions](#1-document-conventions)**
2. **[Get the source code](#2-get-the-source-code)**
3. **[Install the required packages](#3-install-the-required-packages)**
3.1. **[Get build dependencies automagically](#31-get-build-dependencies-automagically)**
3.2. **[Get build dependencies manually](#32-get-build-dependencies-manually)**
3.3. **[Ubuntu <= 18.04](#33-ubuntu--1804)**
4. **[Build Kodi](#4-build-kodi)**
5. **[Build a Debian package](#5-build-a-debian-package)**
## 1. Document conventions
This guide assumes you are using `terminal`, also known as `console`, `command-line` or simply `cli`. Commands need to be run at the terminal, one at a time and in the provided order.
This is a comment that provides context:
```
this is a command
this is another command
and yet another one
```
**Example:** Clone Kodi's current master branch:
```
git clone https://github.com/xbmc/xbmc kodi
```
Commands that contain strings enclosed in angle brackets denote something you need to change to suit your needs.
```
git clone -b <branch-name> https://github.com/xbmc/xbmc kodi
```
**Example:** Clone Kodi's current Krypton branch:
```
git clone -b Krypton https://github.com/xbmc/xbmc kodi
```
Several different strategies are used to draw your attention to certain pieces of information. In order of how critical the information is, these items are marked as a note, tip, or warning. For example:
> [!NOTE]
> Linux is user friendly... It's just very particular about who its friends are.
> [!TIP]
> Algorithm is what developers call code they do not want to explain.
> [!WARNING]
> Developers don't change light bulbs. It's a hardware problem.
**[back to top](#table-of-contents)** | **[back to section top](#1-document-conventions)**
## 2. Get the source code
Make sure `git` is installed:
```
sudo apt install git
```
Change to your `home` directory:
```
cd $HOME
```
Clone Kodi's current master branch:
```
git clone https://github.com/xbmc/xbmc kodi
```
**[back to top](#table-of-contents)**
## 3. Install the required packages
You can install the required packages using one of two methods: automagically or manually. Please use the former whenever possible.
> [!WARNING]
> Oldest supported Ubuntu version is 16.04 (Xenial). It is possible to build on older Ubuntu releases but due to outdated packages it will require considerable fiddling. Sorry, you're on your own if you decide to go down that particular rabbit hole.
### 3.1. Get build dependencies automagically
Add Kodi's *nightly* PPA to grab dependencies:
```
sudo add-apt-repository -s ppa:team-xbmc/xbmc-nightly
```
If you're using Ubuntu 16.04, *build-depends* PPA is also required:
```
sudo add-apt-repository ppa:team-xbmc/xbmc-ppa-build-depends
sudo apt update
```
Super-duper magic command to get the build dependencies:
```
sudo apt build-dep kodi
```
> [!WARNING]
> Do not use `aptitude` for the `build-dep` command. It doesn't resolve everything properly.
If at a later point you decide you do not want Kodi's PPAs on your system, removing them is as easy as:
```
sudo add-apt-repository -r ppa:team-xbmc/xbmc-nightly
sudo add-apt-repository -r ppa:team-xbmc/xbmc-ppa-build-depends
```
> [!NOTE]
> For developers and anyone else who builds frequently it is recommended to install `ccache` to expedite subsequent builds of Kodi.
You can install it with:
```
sudo apt install ccache
```
> [!TIP]
> If you have multiple computers at home, `distcc` will distribute build workloads of C and C++ code across several machines on a network. Team Kodi may not be willing to give support if problems arise using such a build configuration.
You can install it with:
```
sudo apt install distcc
```
### 3.2. Get build dependencies manually
If you get a `package not found` type of message with the below command, remove the offending package(s) from the install list and reissue the command. Take a note of the missing dependencies and, after a successful step completion, **[build the missing dependencies manually](README.Linux.md#31-build-missing-dependencies)**.
> [!NOTE]
> Kodi requires a compiler with C++17 support, i.e. gcc >= 7 or clang >= 5
Install build dependencies manually:
```
sudo apt install autoconf automake autopoint autotools-dev cmake \
curl debhelper default-jre doxygen gawk gcc gdc gettext gperf \
libasound2-dev libass-dev libavahi-client-dev libavahi-common-dev \
libbluetooth-dev libbluray-dev libbz2-dev libcdio-dev \
libcrossguid-dev libcurl4-openssl-dev libcwiid-dev libdbus-1-dev \
libdrm-dev libegl1-mesa-dev libenca-dev libexiv2-dev libflac-dev \
libfmt-dev libfontconfig-dev libfreetype6-dev libfribidi-dev \
libfstrcmp-dev libgcrypt-dev libgif-dev libgl1-mesa-dev \
libgles2-mesa-dev libglu1-mesa-dev libgnutls28-dev libgpg-error-dev \
libgtest-dev libiso9660-dev libjpeg-dev liblcms2-dev libltdl-dev \
liblzo2-dev libmicrohttpd-dev libmysqlclient-dev libnfs-dev \
libogg-dev libpcre2-dev libplist-dev libpng-dev \
libpulse-dev libshairplay-dev libsmbclient-dev libspdlog-dev \
libsqlite3-dev libssl-dev libtag1-dev libtiff5-dev libtinyxml-dev \
libtinyxml2-dev libtool libudev-dev libunistring-dev libva-dev \
libvdpau-dev libvorbis-dev libxmu-dev libxrandr-dev libxslt1-dev \
libxt-dev lsb-release meson nasm ninja-build nlohmann-json3-dev \
python3-dev python3-pil python3-pip swig unzip uuid-dev zip \
zlib1g-dev
```
> [!WARNING]
> Make sure you copy paste the entire line or you might receive an error or miss a few dependencies.
If you're using Ubuntu 16.04, you also need to install:
```
sudo apt install libcec4-dev libfmt3-dev liblircclient-dev
```
If you're using Ubuntu 18.04 and later, you also need to install:
```
sudo apt install libcec-dev libfmt-dev liblirc-dev
```
Flatbuffers (Ubuntu < 20.04, from PPA repository):
```
sudo apt install flatbuffers-dev
```
Flatbuffers (Ubuntu >= 20.04):
```
sudo apt install libflatbuffers-dev
```
Building for Wayland requires some extra packages:
```
sudo apt install libglew-dev libwayland-dev libxkbcommon-dev waylandpp-dev wayland-protocols
```
Similarly, building for GBM also requires some extra packages:
```
sudo apt install libgbm-dev libinput-dev libxkbcommon-dev
```
> [!NOTE]
> The Python bindings need SWIG 4.5.0 or newer, which no Ubuntu release up to 26.04 (Resolute) packages. Install `bison` and configure Kodi with `-DENABLE_INTERNAL_SWIG=ON` to build the pinned version as part of the Kodi build.
Optional packages that you might want to install for extra functionality (generating doxygen documentation, for instance):
```
sudo apt install doxygen libcap-dev libsndio-dev libmariadbd-dev
```
**[back to top](#table-of-contents)**
### 3.3 Ubuntu <= 18.04
Ubuntu 18.04 and lower ship an outdated [Meson](https://mesonbuild.com/) and [nasm](https://nasm.us/) package.
In order to compile Kodi with AV1 support, you have to manually update both Meson and nasm.
> This is a requirement by the [dav1d](https://code.videolan.org/videolan/dav1d) AV1 decoder used in ffmpeg.
#### Meson
```
pip3 install --user meson
```
Make sure `~/.local/bin` is in your PATH.
Verify your Meson version by running `meson -v`. The version displayed should be >= 0.47.0.
#### nasm (x86_64 / amd64)
```
wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/n/nasm/nasm_2.14-1_amd64.deb && sudo apt install ./nasm_2.14-1_amd64.deb
```
Verify your nasm version by running `nasm -v`. The version displayed should be >= 2.14.
## 4. Build Kodi
See the general **[Linux build guide](README.Linux.md)** for reference.
**[back to top](#table-of-contents)**
## 5. Build a Debian package
Kodi's CMake project can produce Debian packages through CPack. It needs `dpkg-dev`, `fakeroot` and `lsb-release` in addition to the build dependencies from **[section 3](#3-install-the-required-packages)**:
```
sudo apt install dpkg-dev fakeroot lsb-release
```
Configure with `-DCPACK_GENERATOR=DEB` and an install prefix of `/usr`, build, then run `cpack` from the build directory:
```
cd $HOME/kodi-build
cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_GENERATOR=DEB
cmake --build . -- -j$(getconf _NPROCESSORS_ONLN)
cpack
```
The packages are written to `packages/` inside the build directory: `kodi` (architecture-independent data), `kodi-bin` (the binary, with its library dependencies computed by `dpkg-shlibdeps`), `kodi-addon-dev`, `kodi-tools-texturepacker` and, when configured with `-DENABLE_EVENTCLIENTS=ON`, the event client packages. Install a runnable Kodi with:
```
sudo apt install ./packages/kodi_*.deb ./packages/kodi-bin_*.deb
```
The package version is `<major>.<minor>~git<timestamp>-<identifier>-<distro codename>` with epoch `2`. The following cache variables adjust it:
| Variable | Effect |
|----------|--------|
| `DEBIAN_PACKAGE_TYPE` | `stable` uses `final` as identifier, `unstable` uses the version tag (for instance `beta2`); anything else uses the git revision |
| `DEBIAN_PACKAGE_VERSION` / `DEBIAN_PACKAGE_REVISION` | Prefix and suffix of the distro part, `0<codename>` by default |
| `DEBIAN_PACKAGE_EPOCH` | Overrides the epoch (`2` by default); `0` produces a version without epoch |
| `CPACK_DEBIAN_PACKAGE_MAINTAINER` | Overrides the maintainer, otherwise taken from `git config user.name` and `user.email` |
| `CPACK_DEBIAN_PACKAGE_ARCHITECTURE` | Overrides the architecture, otherwise `dpkg --print-architecture` for a native build and the target triplet (`arm-linux-gnueabihf` gives `armhf`) for a cross build |
**[back to top](#table-of-contents)**