summaryrefslogtreecommitdiff
path: root/docs/_rst_legacy/contributing/rst-upstream-packages.rst
blob: c740b19072d69d0136065a0857e79059bbcd6ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
:lastproofread: 2026-01-30

.. _upstream_packages:

#################
Upstream Packages
#################

Many base system packages are pulled straight from Debian's ``main`` and
``contrib`` repositories, but there are exceptions. If you only want to build
a fresh ISO image, you can skip
this section. This information may be useful for a deeper dive into VyOS.


.. stop_vyoslinter

System packages that are not directly pulled from Debian are built through a 
separate build system, ``build.py`` in the `vyos-build <https://github.com/vyos/vyos-build/tree/current/scripts/package-build>`__ repository.

.. start_vyoslinter


Overview
========

Previously, VyOS used Jenkins for building upstream packages. With the move away 
from Jenkins, the build system was replaced with a Python-based solution using 
``build.py`` and ``package.toml`` configuration files.

Each package directory contains:

- A ``package.toml`` configuration file that defines how the package is built.
- A symlink to the common ``build.py`` script in the build system.


Building Packages
=================

To build a package, navigate to the package directory and execute the 
build script:

.. code-block:: console

   cd package-build/<package-name>
   ./build.py

The script will:

1. Check out the source code from the configured repository.
2. Apply any patches defined in the configuration.
3. Execute pre-build hooks (if configured).
4. Build the package using the specified build command.
5. Generate both binary (``.deb``) packages and source tarballs.


Package Configuration (package.toml)
====================================

Each package directory contains a ``package.toml`` file that defines the build 
parameters. The key configuration fields are:

**name**
   The package name (e.g., ``frr``)

**commit_id**
   The specific commit, tag, or branch to check out from the source repository
   (e.g., ``stable/10.5``)

**scm_url**
   The Git URL of the upstream source repository
   (e.g., ``https://github.com/FRRouting/frr.git``)

.. stop_vyoslinter
**build_cmd**
   The command to execute for building the package. This replaces what was 
   previously defined in the Jenkins ``Jenkinsfile``.

   Default if not specified: ``dpkg-buildpackage -uc -us -tc -F --source-option=--tar-ignore=.git --source-option=--tar-ignore=.github``

   Example with custom build command:

   .. code-block:: toml

      build_cmd = "sudo dpkg -i ../*.deb; dpkg-buildpackage -us -uc -tc -b -Ppkg.frr.rtrlib,pkg.frr.lua"
.. start_vyoslinter

**pre_build_hook** (Optional)
   A shell command or script that executes after the repository is checked out 
   and before the build process begins. This allows you to perform preparatory 
   tasks such as:

   - Creating directories
   - Copying files
   - Running custom setup scripts
   - Installing dependencies

   Single command example:

   .. code-block:: toml

      pre_build_hook = "echo 'Preparing build environment'"

   Multi-line commands example:

   .. code-block:: toml

      pre_build_hook = """
        mkdir -p ../hello/vyos
        mkdir -p ../vyos
        cp example.txt ../vyos
      """

   Combined commands and scripts:

   .. code-block:: toml

      pre_build_hook = "ls -l; ./script.sh"

**apply_patches** (Optional)
   Boolean flag to control whether patches should be applied. Defaults to
   ``True``.

   .. code-block:: toml

      apply_patches = false

**prepare_package** (Optional)
   Boolean flag to enable package preparation. When set to ``True``, the 
   ``install_data`` configuration is used.

**install_data** (Optional)
   Data used for package preparation when ``prepare_package`` is enabled.


Example package.toml file
===========================

Here's an example configuration for the FRRouting (FRR) package:

.. code-block:: toml

   name = "frr"
   commit_id = "stable/10.5"
   scm_url = "https://github.com/FRRouting/frr.git"
   build_cmd = "sudo dpkg -i ../*.deb; dpkg-buildpackage -us -uc -tc -b -Ppkg.frr.rtrlib,pkg.frr.lua"


Build Output
============

After running ``./build.py``, the following artifacts are generated in the 
package directory:

- ``.deb`` files - Binary Debian packages ready for installation
- ``.tar.gz`` files - Source tarballs of the checked-out repositories
- Additional build artifacts as produced by the Debian build system

The build script also creates build dependency packages (`*build-deps*.deb`), 
which are automatically cleaned up after the build completes.