2024-05-05 18:21:10 +00:00
|
|
|
On this page, you will learn how you can create your first
|
2024-08-13 22:30:42 +00:00
|
|
|
MatterLinux package for the official pools.
|
2024-02-23 16:54:04 +00:00
|
|
|
|
|
|
|
## Pre-requirements
|
|
|
|
- You should have an up-to-date MatterLinux installation
|
|
|
|
- You should have general understanding of software packaging
|
|
|
|
- You should have general understanding of building/compiling software
|
|
|
|
- You should know the basics of bash scripting
|
|
|
|
- You should know the basics of git version control system
|
|
|
|
|
|
|
|
## Getting started
|
2024-08-13 22:30:42 +00:00
|
|
|
If you want to add your package to the official pools, then please
|
|
|
|
check the [official pool guidelines](/wiki/pool_guides). Make sure
|
2024-02-23 16:54:04 +00:00
|
|
|
that your package follows the guidelines or your pull request maybe
|
|
|
|
rejected.
|
|
|
|
|
|
|
|
Also create an account on Gitea server and configure your editor
|
|
|
|
as specified in the [contribution guide](/wiki/contribute).
|
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
## Selecting a pool
|
|
|
|
If you want to add a new package to the official pools, you should
|
|
|
|
first choose the pool you want to add the package to. If you are
|
2024-02-23 16:54:04 +00:00
|
|
|
packaging a software that is fundamental to the OS, such as a kernel,
|
2024-08-13 22:30:42 +00:00
|
|
|
or a C library, you should add your package to the `base` pool.
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
If the software is mainly targeted for server use, you should add the package
|
|
|
|
to the `server` pool.
|
|
|
|
|
|
|
|
If none of these is the case then you should add the package to the `desktop`
|
|
|
|
pool.
|
|
|
|
|
|
|
|
## Fork the pool
|
|
|
|
After selecting the pool, fork it on Gitea and clone it to MatterLinux
|
2024-02-23 16:54:04 +00:00
|
|
|
system:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
$ git clone <git repo url>
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
## Install requirements
|
|
|
|
To build and create packages, you should install the `build-essential` package from the
|
|
|
|
`base` pool. This package will provide you with all the scripts and the tools required.
|
2024-02-23 16:54:04 +00:00
|
|
|
|
|
|
|
## Create the package template
|
2024-08-13 22:30:42 +00:00
|
|
|
Change directory into the `src` folder of the pool you cloned, and use the `mp-new`
|
|
|
|
command (a script from `mp-build`) to create an empty package script:
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
$ cd src
|
2024-08-13 22:30:42 +00:00
|
|
|
$ mp-new <name of the package>_<version of the package>
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Package name should be **full lowercase**, it should not contain any non-English characters,
|
|
|
|
and it should not contain underscore (`_`). If there is an underscore in the package name, replace
|
|
|
|
it with `-`. Package name also **should NOT contain a version number**.
|
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
Version name ideally should contain a version number separated with dots. However this may heavily
|
|
|
|
change based on how the upstream actually versions the software. Version should also be updated
|
|
|
|
after every modification. If the modification does not change the upstream version, then you should
|
|
|
|
suffix the version with `m<number of changes>`, for example `1.2m1`, `8.7.3m7` etc. Version name should
|
|
|
|
also not contain underscores (`_`), you should replace them with `-`.
|
|
|
|
|
|
|
|
For this example we will be packaging the `LXTerminal` (version `0.4.0`) from LXDE:
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
$ cd src
|
2024-08-13 22:30:42 +00:00
|
|
|
$ mp-new lxterminal_0.4.0
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Modify the package script
|
|
|
|
`mp-temp` will create a directory for the new package, which will contain a `pkg.sh` script.
|
|
|
|
This script is called the **package script**. Open this script with the configured editor:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
# general info
|
2024-02-23 16:54:04 +00:00
|
|
|
NAME="lxterminal"
|
|
|
|
DESC=""
|
2024-08-13 22:30:42 +00:00
|
|
|
VERSION="0.4.0"
|
|
|
|
|
|
|
|
# required files
|
2024-02-23 16:54:04 +00:00
|
|
|
FILES=()
|
|
|
|
HASHES=()
|
2024-08-13 22:30:42 +00:00
|
|
|
|
|
|
|
# install and build depends
|
2024-02-23 16:54:04 +00:00
|
|
|
DEPENDS=()
|
2024-08-13 22:30:42 +00:00
|
|
|
BUILD=()
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
PACKAGE() {
|
|
|
|
tar xf "${NAME}-${VERSION}.tar.gz"
|
|
|
|
cd "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
cd .. && rm -r "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Description
|
|
|
|
First of all you should add a description. Description should be short (less than 200 characters), and
|
|
|
|
it should explain details about the package. Ideally, description should not contain words such as "*contains*"
|
2024-08-13 22:30:42 +00:00
|
|
|
and "*includes*". Here are some **bad examples**:
|
2024-02-23 16:54:04 +00:00
|
|
|
- *LXTerminal package contains a VTE-based terminal emulator*
|
|
|
|
- *LXTerminal includes the LXDE terminal emulator*
|
|
|
|
|
|
|
|
And here are some **good examples**:
|
|
|
|
- *VTE-based terminal emulator for LXDE*
|
|
|
|
- *LXDE terminal emulator*
|
|
|
|
|
|
|
|
### Version
|
2024-08-13 22:30:42 +00:00
|
|
|
You should package a stable version of the software, do not package the latest git commit or
|
|
|
|
something like that. **Package an official released version.**. For this example we will be
|
2024-02-23 16:54:04 +00:00
|
|
|
packaging the version `0.4.0`.
|
|
|
|
|
|
|
|
### Files
|
|
|
|
List of files needed for this package, you can specify `HTTP(S)` or `FTP(s)` URLs. Or you can
|
|
|
|
specify simply just filenames to pull the packages from the local source directory.
|
|
|
|
|
|
|
|
If possible, you should replace the version number in the URL with the `VERSION` variable.
|
|
|
|
|
|
|
|
### Hashes
|
|
|
|
Specify hashes for the files you specified, you can use the `NOHASH` as the hash to disable
|
|
|
|
hash verification for a specific file.
|
|
|
|
|
|
|
|
### Depends
|
2024-08-13 22:30:42 +00:00
|
|
|
Run-time dependencies for the package, **do not** specify the make or the build dependencies that are only used
|
|
|
|
for compiling the software.
|
|
|
|
|
|
|
|
### Build
|
|
|
|
Build-time dependencies for the package, **dot not** specify any run-time dependencies again if they are also needed
|
|
|
|
for the build process. Also **do not** specify any package that is part of `build-essential`.
|
2024-02-23 16:54:04 +00:00
|
|
|
|
|
|
|
With the addition of the details above, here is how our example package script looks like:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
# general info
|
2024-02-23 16:54:04 +00:00
|
|
|
NAME="lxterminal"
|
2024-08-13 22:30:42 +00:00
|
|
|
DESC="Commands for manipulating POSIX Access Control Lists"
|
2024-02-23 16:54:04 +00:00
|
|
|
VERSION="0.4.0"
|
2024-08-13 22:30:42 +00:00
|
|
|
|
|
|
|
# required files
|
2024-02-23 16:54:04 +00:00
|
|
|
FILES=("https://downloads.sourceforge.net/lxde/lxterminal-$VERSION.tar.xz")
|
|
|
|
HASHES=("7938dbd50e3826c11f4735a742b278d3")
|
2024-08-13 22:30:42 +00:00
|
|
|
|
|
|
|
# install and build depends
|
2024-02-23 16:54:04 +00:00
|
|
|
DEPENDS=("vte")
|
2024-08-13 22:30:42 +00:00
|
|
|
BUILD=()
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
PACKAGE() {
|
|
|
|
tar xf "${NAME}-${VERSION}.tar.gz"
|
|
|
|
cd "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
cd .. && rm -r "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
### Package function
|
|
|
|
The package function contains the instructions for building the package itself. When building the package, `mp-build`
|
|
|
|
will download all the files and remove them after the build, so you do not have to deal with that.
|
|
|
|
|
|
|
|
To make your life simpler, `mp-new` creates a boilerplate `PACKAGE()` function template. Now will modify it
|
|
|
|
to make it work our package.
|
2024-02-23 16:54:04 +00:00
|
|
|
|
|
|
|
First, we should do is to extract the downloaded file, and change directory into the newly extracted folder:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
tar xf "${NAME}-${VERSION}.tar.gz"
|
|
|
|
cd "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
Then we can change directory into the pool source directory and run the build and install instructions:
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
./configure --enable-man --prefix=/usr
|
|
|
|
make && make install
|
|
|
|
```
|
|
|
|
With this configuration, `make install` will try to install the package to the actual system, however
|
|
|
|
we want to install the package to the package build directory, so we will use the `DESTDIR` flag for that:
|
|
|
|
```
|
|
|
|
./configure --enable-man --prefix=/usr
|
2024-08-13 22:30:42 +00:00
|
|
|
make
|
|
|
|
make DESTDIR="${ROOTDIR}" install
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
`$ROOTDIR` is a custom variable that is set during the package build. During the build it will point to the
|
|
|
|
package build directory.
|
|
|
|
|
|
|
|
After building and installing the package, we can change directory back up, and remove the extracted folder:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
cd .. && rm -r "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
So the final script should look like this:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
# general info
|
2024-02-23 16:54:04 +00:00
|
|
|
NAME="lxterminal"
|
2024-08-13 22:30:42 +00:00
|
|
|
DESC="Commands for manipulating POSIX Access Control Lists"
|
2024-02-23 16:54:04 +00:00
|
|
|
VERSION="0.4.0"
|
2024-08-13 22:30:42 +00:00
|
|
|
|
|
|
|
# required files
|
2024-02-23 16:54:04 +00:00
|
|
|
FILES=("https://downloads.sourceforge.net/lxde/lxterminal-$VERSION.tar.xz")
|
|
|
|
HASHES=("7938dbd50e3826c11f4735a742b278d3")
|
2024-08-13 22:30:42 +00:00
|
|
|
|
|
|
|
# install and build depends
|
2024-02-23 16:54:04 +00:00
|
|
|
DEPENDS=("vte")
|
2024-08-13 22:30:42 +00:00
|
|
|
BUILD=()
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
PACKAGE() {
|
|
|
|
tar xf "${NAME}-${VERSION}.tar.xz"
|
|
|
|
cd "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
|
|
|
|
./configure --enable-man --prefix=/usr
|
2024-08-13 22:30:42 +00:00
|
|
|
make
|
|
|
|
make DESTDIR="${ROOTDIR}" install
|
2024-02-23 16:54:04 +00:00
|
|
|
|
2024-08-13 22:30:42 +00:00
|
|
|
cd .. && rm -r "${NAME}-${VERSION}"
|
2024-02-23 16:54:04 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Formatting the package script
|
|
|
|
When you are done, format the package script following these rules:
|
|
|
|
- If you have multiple files, put each one of them to a new line, same for the hashes.
|
|
|
|
- If you have more than 5 depends, split them into new lines, grouping 3 depends together.
|
|
|
|
- If you have long commands in the build function, split them to new lines using a backslash (`\`)
|
2024-08-13 22:30:42 +00:00
|
|
|
- Prevent using `&&` unless it's absolutely necessary, it usually ends up messing the error checking
|
2024-02-23 16:54:04 +00:00
|
|
|
- Split unrelated instructions with a newline
|
|
|
|
|
|
|
|
## Building the package
|
|
|
|
To build the newly created package, run the following in the `src` directory:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
$ mp-build --no-sign <package name>
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
This will install all the required dependencies, and only build the specified package.
|
|
|
|
|
|
|
|
## Testing the package
|
2024-08-13 22:30:42 +00:00
|
|
|
When the package is built, check out the newly created root directory inside the package directory
|
|
|
|
to make sure that everything is placed where it should be:
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
$ tree <pacakge_name>/root
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Staging and commit your changes
|
2024-08-13 22:30:42 +00:00
|
|
|
After making sure that the package is working as intended, go back to the root of the pool source directory,
|
2024-02-23 16:54:04 +00:00
|
|
|
and use `git add .` to stage all the changes. Then use `git commit -m <message>` to commit them. For the
|
|
|
|
commit message, follow the guidelines on the [contribution page](/wiki/contribute). For our example, the following
|
|
|
|
message should be fine:
|
|
|
|
```
|
2024-08-13 22:30:42 +00:00
|
|
|
$ git commit -m "new: add lxterminal package"
|
2024-02-23 16:54:04 +00:00
|
|
|
```
|
|
|
|
Then push your changes:
|
|
|
|
```
|
|
|
|
$ git push -u origin main
|
|
|
|
```
|
|
|
|
|
|
|
|
## Creating a pull request
|
|
|
|
Back on the Gitea, create a pull request to the official repository. Provide information about
|
|
|
|
the package you added, and explain why you think its important to include this package.
|