tooling.rst 4.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
.. _tooling:

=======
Tooling
=======

The repod project provides scripts, that can be used to manipulate data, which
is related to the repositories it can manage.

10
.. _repod-file:
11

12
13
repod-file
----------
14

15
16
The ``repod-file`` script can be used to inspect and transform data related to
:ref:`package`, :ref:`sync database` and :ref:`management repository` files.
17
18
19

.. note::

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
   Refer to ``repod-file --help`` for further information on subcommands,
   options and parameters.

.. _inspect_package_files:

Inspecting Package files
^^^^^^^^^^^^^^^^^^^^^^^^

:ref:`package` files can be inspected to review the metadata contained in them.

To get the entire metadata collected by repod, use:

.. code:: sh

  repod-file package inspect <package> <signature>

.. note::

  The signature file is optional, but if present should be added to the call to
  ``repod-file`` as it provides the additional ``pgpsig`` data for the output.

The output of ``repod-file package inspect`` can be modified by using the
``-p``/ ``--pretty`` option (for pretty printing the JSON output).

To only display subsets of the data, refer to the following flags:

* ``-B``/ ``--buildinfo`` (for :ref:`buildinfo`)
* ``-M``/ ``--mtree`` (for :ref:`mtree`)
* ``-P``/ ``--pkginfo`` (for :ref:`pkginfo`).

.. _package_to_management_repo:

Import Package metadata to management repository
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The metadata retrieved from :ref:`package` files and their :ref:`package
signature` can be transformed to their respective :ref:`management repository`
representation. For this to produce meaningful and complete output, all
packages (and their signatures) of a given ``pkgbase`` (see |package
splitting|) need to be consumed at once.

.. code:: sh

  repod-file package import <package> <signature> <repo>

.. note::

  All packages must either be provided with or without their accompanying
  signatures. If signatures are present the packages and signatures are to be
  provided in tuples of two (the first is always the package, the second always
  the signature). The last parameter is always considered as the output
  directory.

The output of the above command may be displayed using the ``-d``/
``--dry-run`` flag (nothing is written to the output directory in this case).
To pretty print the JSON output use the ``-p``/ ``--pretty`` flag.

.. _syncdb_to_management_repo:

Transform repository sync databases to management repository
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:ref:`sync database` files can be transformed to representations used in the
context of a :ref:`management repository`.

.. note::

  :ref:`files sync database` files are required to create :ref:`management
  repository` files, that contain information on files contained in the
  respective packages they represent! This data is not contained in the
  :ref:`default sync database` files!
91
92

For testing purposes, the system's |pacman| sync databases in
93
94
``/var/lib/pacman/sync/`` can be used (this assumes a system that makes use of
pacman as package manager).
95

96
97
To transform :ref:`default sync database` files and output them to a temporary
directory, you can use the following:
98
99
100
101
102

.. code:: sh

  DEFAULT_JSON_OUTPUT="$(mktemp -d)"
  echo "$DEFAULT_JSON_OUTPUT"
103
  repod-file syncdb export /var/lib/pacman/sync/core.db "$DEFAULT_JSON_OUTPUT"
104
105
106
107
108
109
110
111

To be able to use :ref:`files sync database` files, make sure to update them
first.

.. code:: sh

  pacman -Fy

112
113
Afterwards you are able to transform the files and output them to a temporary
directory as well:
114
115
116
117
118

.. code:: sh

  FILES_JSON_OUTPUT="$(mktemp -d)"
  echo "$FILES_JSON_OUTPUT"
119
  repod-file syncdb export /var/lib/pacman/sync/core.files "$FILES_JSON_OUTPUT"
120

121
.. _management_repo_to_syncdb:
122

123
124
Transform management repositories to repository sync databases
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125

126
127
128
The JSON files contained in a :ref:`management repository` can be transformed
into a :ref:`sync database` (both :ref:`default sync database` and :ref:`files
sync database` files are created).
129

130
131
After following the examples in :ref:`syncdb_to_management_repo` it is possible
to use the created files and turn them back into :ref:`sync database` files.
132

133
.. code:: sh
134

135
136
137
  SYNC_DB_OUTPUT="$(mktemp -d)"
  echo "$SYNC_DB_OUTPUT"
  repod-file management export "$FILES_JSON_OUTPUT" "$SYNC_DB_OUTPUT/core.db"
138

139
140
141
142
The above creates ``"$SYNC_DB_OUTPUT/core.db"`` as well as
``"$SYNC_DB_OUTPUT/core.files"``.

.. _json_schema_export:
143

144
145
Export JSON schema
^^^^^^^^^^^^^^^^^^
146

147
To export the |JSON schema|, which represents the validation logic of repod, use:
148
149
150

.. code:: sh

151
152
153
  REPOD_SCHEMA="$(mktemp -d)"
  echo "$REPOD_SCHEMA"
  repod-file schema export "$REPOD_SCHEMA"
154
155
156
157

.. |pacman| raw:: html

  <a target="blank" href="https://man.archlinux.org/man/pacman.8">pacman</a>
158
159
160
161
162
163
164
165

.. |JSON schema| raw:: html

  <a target="blank" href="https://en.wikipedia.org/wiki/JSON#Metadata_and_schema">JSON schema</a>

.. |package splitting| raw:: html

  <a target="blank" href="https://man.archlinux.org/man/PKGBUILD.5#PACKAGE_SPLITTING">package splitting</a>