aboutsummaryrefslogtreecommitdiff
path: root/src/docs/Packaging-System.html
blob: 3c4538a8a2d10d26cbcf47e744a14823a407f724 (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2020 Cem Keylan

Licensed under Gnu Free Documentation License. -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Packaging System (Carbs Linux User Manual)</title>

<meta name="description" content="Packaging System (Carbs Linux User Manual)">
<meta name="keywords" content="Packaging System (Carbs Linux User Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Package-Manager.html" rel="up" title="Package Manager">
<link href="Rsync-Repositories.html" rel="next" title="Rsync Repositories">
<link href="cpt_002dbuild.html" rel="prev" title="cpt-build">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<span id="Packaging-System"></span><div class="header">
<p>
Next: <a href="Rsync-Repositories.html" accesskey="n" rel="next">Rsync Repositories</a>, Previous: <a href="Usage.html" accesskey="p" rel="prev">Usage</a>, Up: <a href="Package-Manager.html" accesskey="u" rel="up">Package Manager</a> &nbsp; </p>
</div>
<hr>
<span id="Packaging-System-1"></span><h3 class="section">2.2 Packaging System</h3>

<p>A package is formed of several files, these are:
</p><ul>
<li> <samp>build</samp>
</li><li> <samp>sources</samp>
</li><li> <samp>checksums</samp>
</li><li> <samp>version</samp>
</li><li> <samp>depends</samp>
</li><li> <samp>post-install</samp>
</li><li> <samp>message</samp>
</li><li> <samp>test</samp>
</li></ul>

<p>Any other file can be added to the package directory at the discretion of the
package maintainer. Everything in the package directory will also be added to the
package database that is located on &rsquo;/var/db/cpt/installed&rsquo;. These can be
patches, configuration files, etc.
</p>
<span id="build"></span><h4 class="subsection">2.2.1 <samp>build</samp></h4>

<p>Typically <samp>build</samp> files are shell scripts that run commands to prepare the source
code to be installed on the target system. Even though we will be assuming that
the <samp>build</samp> file is a POSIX shell script (for portability&rsquo;s sake), <samp>build</samp>
files can be any executable program from binary programs to <code>perl</code> scripts.
</p>
<p>The contents of a build script do not need to follow a certain rule for the
package manager, except for the fact that the user needs the permission to
execute the file.
</p>
<p>An important advice is to append an &rsquo;-e&rsquo; to the shebang (#!/bin/sh -e) so that
the build script exits on compilation error.
</p>
<p>Build is run with three arguments (<code>$#</code>)
</p>
<ol>
<li> Location of the package directory (DESTDIR)
</li><li> Package version
</li><li> System architecture
</li></ol>

<span id="sources"></span><h4 class="subsection">2.2.2 <samp>sources</samp></h4>

<p><samp>sources</samp> file is a list of files and sources that will be put to the build
directory during the build process. Those can be remote sources (such as tarballs),
git repositories, and files that reside on the package directory.
</p>
<p>The syntax is pretty simple for the <samp>soures</samp> file; <tt>src dest</tt>. The
<code>dest</code> parameter is optional. It is the directory that the source will be
placed in. Here is the <samp>sources</samp> file for the <code>gst-plugins</code> package:
</p>
<div class="example">
<pre class="example">https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.16.2.tar.xz good
https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-1.16.2.tar.xz   bad
https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-1.16.2.tar.xz ugly
https://gstreamer.freedesktop.org/src/gst-libav/gst-libav-1.16.2.tar.xz               libav
</pre></div>

<p>This file is read from the package manager as space seperated. Files that begin
with a &rsquo;#&rsquo; comment are ignored. The first value points to the location of the
source.
</p>
<p>If it starts with a protcol url, (such as ftp:// http:// https://) it will be
downloaded with <code>curl</code>.
</p>
<p>If the source is a git repository, it shall be prefixed with a <tt>git+</tt> git(1) will
be used to do a shallow clone of the repository. If the commit is suffixed by a
history pointer, git will checkout the relevant revision. So,
</p>
<dl compact="compact">
<dt>&lsquo;<code>git+git://example.com/pub/repo#v1.2.3</code>&rsquo;</dt>
<dd><p>will checkout the tag named &rsquo;v1.2.3&rsquo;
</p></dd>
<dt>&lsquo;<code>git+git://example.com/pub/repo#development</code>&rsquo;</dt>
<dd><p>will checkout the branch named &rsquo;development&rsquo;
</p></dd>
<dt>&lsquo;<code>git+git://example.com/pub/repo#1a314s87</code>&rsquo;</dt>
<dd><p>will checkout the commit named &rsquo;1a314s87&rsquo;
</p></dd>
</dl>

<p>Other files are assumed to be residing in the package directory. They should be
added with their paths relative to the package directory.
</p>

<span id="checksums"></span><h4 class="subsection">2.2.3 <samp>checksums</samp></h4>

<p>checksums file is generated by the <samp>cpt c pkg command</samp>. It is generated
according to the order of the sources file. That&rsquo;s why you shouldn&rsquo;t be editing
it manually. The checksums file is created with the digests of the files using
the sha256 algorithm.
</p>
<span id="version"></span><h4 class="subsection">2.2.4 <samp>version</samp></h4>

<p>The version file includes the version of the software and the release number of
of the package on a space seperated format. The contents of the file should look
like below.
</p>
<div class="example">
<pre class="example">1.3.2 1
</pre></div>

<p>The version should always match to the number of the upstream release. For
drastic changes that require a rebuild Those can be,
</p>
<ul>
<li> update of libraries that forces the package to be relinked
</li><li> change in the build scripts that affect the output of the package
</li></ul>

<p>When a version bump occurs, the release should be reset to 1.
</p>
<span id="depends"></span><h4 class="subsection">2.2.5 <samp>depends</samp></h4>

<p>This is a list of dependencies that must be installed before a package build. You
can append &ldquo;make&rdquo; after a dependency to mark a package is only required during
the build process of a package. Packages marked as a make dependency can be
removed after the build. There are also &ldquo;test&rdquo; dependencies. These dependencies
are only installed if either the <code>CPT_TEST</code> is set to 1, or the build is run
with the <samp>-t</samp> or <samp>--test</samp> options. So, a package package could have
the following <samp>depends</samp> file:
</p>
<div class="example">
<pre class="example">linux-headers make
python        test
zlib
</pre></div>

<span id="post_002dinstall"></span><h4 class="subsection">2.2.6 <samp>post-install</samp></h4>

<p><samp>post-install</samp> files have the same requirements as the build script. They
will be run after the package is installed as root (or as the user if the user
has write permissions on <code>CPT_ROOT</code>).
</p>
<span id="message"></span><h4 class="subsection">2.2.7 <samp>message</samp></h4>

<p>This plaintext file will be outputted with <code>cat</code> after every package is
installed.
</p>
<span id="test"></span><h4 class="subsection">2.2.8 <samp>test</samp></h4>

<p>Test files are mainly for the repository maintainer to test the packages, and
will only run if the user has the <code>CPT_TEST</code> variable set, or the build is
run with the <samp>-t</samp> or <samp>--test</samp> options. This script is run on the
build directory. It is run right after the build script is finished.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Rsync-Repositories.html" accesskey="n" rel="next">Rsync Repositories</a>, Previous: <a href="Usage.html" accesskey="p" rel="prev">Usage</a>, Up: <a href="Package-Manager.html" accesskey="u" rel="up">Package Manager</a> &nbsp; </p>
</div>



</body>
</html>