lpm-builder is a dynamic module for lod package manager that allows users to create LOD packages by packing software using a set of template files. This documentation explains how to use the lpm-builder module and provides details on the supported build template files.
git clone https://github.com/lodosgroup/lpm-modules.git
cd lpm-modules/lpm-builder
make build
To use the module you need to add the dynamic library to the database with the following lpm command(requires root privileges):
lpm --module --add builder {path to liblpm_builder.so}
# check if it's added
lpm --module --list
The stage0
directory contains scripts that run on the builder module level. The following files should be included in the stage0
directory:
init
: This file is used to download and verify the necessary environments and files before the building phase.build
: This file is used to build the program.install_files
: This file is used to install the program files into the lod package with the same paths that lpm should install them on the system.post_install_files
: This file is optional and is used for any additional work that needs to be done after installing the files into the lod package.
The stage1 directory is optional and contains scripts that run on the lpm core level. The following files can be included in the stage1 directory:
pre_install
: This file is an optional step that can be used if additional work needs to be done before installing the package.post_install
: This file is an optional step that can be used if additional work needs to be done after installing the package.pre_delete
: This file is an optional step that can be used if additional work needs to be done before deleting the package.post_delete
: This file is an optional step that can be used if additional work needs to be done after deleting the package.pre_downgrade
: This file is an optional step that can be used if additional work needs to be done before downgrading the package.post_downgrade
: This file is an optional step that can be used if additional work needs to be done after downgrading the package.pre_upgrade
: This file is an optional step that can be used if additional work needs to be done before upgrading the package.post_upgrade
: This file is an optional step that can be used if additional work needs to be done after upgrading the package.
JSON
file that contains almost all the informations about the package.
name
: The name of the package.description
: A description of what the package does.maintainer
: Contact information for the maintainer of the package.source_repository
(optional): The URL of the source code repository for the package.homepage
(optional): The URL of the package's homepage.arch
: The architecture of the package.kind
: The type of package.file_checksum_algo
: The algorithm used to compute the checksum of the package files.tags
: A list of tags or keywords that describe the package.version
: An object that contains version information for the package.license
(optional): The license under which the package is distributed.mandatory_dependencies.runtime
(optional): A list of the package's mandatory dependencies for runtime.mandatory_dependencies.build
(optional): A list of the package's mandatory dependencies for building it.suggested_dependencies.runtime
(optional): A list of the package's suggested dependencies for runtime.suggested_dependencies.build
(optional): A list of the package's suggested dependencies for building it.
The lpm-builder module provides the following built-in functions that can be used in stage0
scripts:
validate_checksum(file_path, sha256_checksum)
: This function takes two arguments: the path of the file to validate, and the SHA256 checksum of the file. It validates the checksum of the file and throws an error if it doesn't match the provided checksum.install_to_package(source_file_path, dest_path)
: This function puts files into the lod package. It takes two arguments: the path of the source file to be added to the package, and the path where lpm should install the file when the package is installed.copy_to_package(source_dir_path, dest_path)
: This function puts copies directory into the lod package. It takes two arguments: the path of the source directory to be added to the package, and the path where lpm should install the directory when the package is installed.
In this example, we will demonstrate how to build a package for the sbs(simple background setter) tool.
Begin by preparing the necessary files for building sbs.
mkdir sbs_build_template
cd sbs_build_template
mkdir stage0
touch stage0/init
touch stage0/build
touch stage0/install_files
touch template
Copy the following content into stage0/init
curl -L https://github.com/ozkanonur/sbs/archive/refs/tags/v1.0.0.tar.gz > sbs.tar.gz
validate_checksum "sbs.tar.gz" "aa4da5b2315046fc2059599b19c530f08bb870e63ed17111a55991b1ae911367"
tar -xvzf sbs.tar.gz --strip 1 -C $SRC
Copy the following content into stage0/build
make sbs
Copy the following content into stage0/install_files
install_to_package sbs /usr/bin/sbs
Copy the following content into template
{
"name": "sbs",
"description": "Simple background setter",
"maintainer": "Lpm Core Maintainer <[email protected]>",
"source_repository": "https://github.com/ozkanonur/sbs",
"homepage": "https://github.com/ozkanonur/sbs",
"arch": "amd64",
"kind": "util",
"file_checksum_algo": "sha256",
"tags": [
"x11",
"background-setter"
],
"version": {
"readable_format": "1.0.0",
"major": 1,
"minor": 0,
"patch": 0
},
"license": "MIT",
"mandatory_dependencies": {
"build": [],
"runtime": []
},
"suggested_dependencies": {
"build": [],
"runtime": []
}
}
Now, you can run the following command to generate the sbs.lod
package along with its repository index (a patch for the LPM repository database):
lpm --module builder --build .