Please first read the official Linglong documentation. This article uses the construction of desktop-entry-editor as an example. The project has relatively simple dependencies and only requires the basic runtime environment provided by default in the official Linglong documentation to be successfully built and run.
Step One: Preliminary Preparations
Execute the following command in the terminal:
sudo apt install linglong-builder --no-install-recommends
Install the ll-builder
tool.
Since the recommended installation has many dependencies, they are skipped in this instance. If needed, simply remove the
--no-install-recommends
parameter from the command.
Step Two: Project Creation
Since the construction of a Linglong format application from source code is required, the ll-builder create
operation can be skipped. There is no need to create Linglong-specific folders; instead, you can directly write the linglong.yaml
file at the top-level directory of the project source code (a complete template file can be used from the official website).
Step Three: Edit the Linglong.yaml File
Take this linglong.yaml
as an example, and fill in the package metadata as needed.
Since the project is relatively simple and only requires a basic Qt and Dtk environment to build, you can use the base
and runtime
shown in the template file.
For more complex build environments, you can refer to the Calculator build process, pull the required dependency code before building the application, and prioritize building the necessary dependencies.
Understanding the "Prefix" for Installation Locations
In the way we are familiar with, generally, executable files need to be placed in the /usr/bin
directory so that they can be found when executed in the terminal. .desktop
files provide the entry point for launching, and to see the application icon in the launcher, they are generally placed in the /usr/share/applications
directory; and image files are placed in the specific icon theme and size classification folders under the /usr/share/icons
directory. Here, /usr
is the "prefix" for the installation location of all files.
According to the GNU Coding Standards, the default value for the "prefix" is generally /usr/local
; and when building a deb format software package, the /usr
prefix is usually used.
When the Linglong container starts, the container content files
folder is mounted to the /opt/apps/${appid}
directory, so it can be approximated that the "prefix" is /opt/apps/${appid}/files
. By the same token, the actual location of the executable file is /opt/apps/${appid}/files/bin/executable_name
, so the command
startup instruction part in the linglong.yaml
also needs to be filled out in this way, rather than the common /usr/bin/executable_name
.
Inspect and Modify the Source Code of the Project
Having understood the concept of the "prefix," you should check the installation location prefix of the project's source code. In a qmake project, the default installation location prefix is generally the /opt/$${TARGET}
directory, where the executable files are placed in the /opt/$${TARGET}/bin
directory. Here, you may need to modify the .pro
file, changing the prefix to /opt/apps/${appid}/files
to ensure the correct file location after the Linglong container starts.
Alternatively, as shown in the construction of the "Calculator," pass the installation location prefix from the outside through qmake parameters and parse
${PREFIX}
in the.pro
file to control the file installation location.
Step Four: Build the Application
Open a terminal in the top-level directory of the project source code (the same level as the linglong.yaml directory) and execute the ll-builder build
command.
During the initial build, it is necessary to download the specified
base
andruntime
, which may take a considerable amount of time and requires patient waiting.
Step Five: Test and Run the Application
Open a terminal in the top-level directory of the project source code (the same level as the linglong.yaml file) and execute the command ll-builder run --exec executable_program_name
to test the launch of the application within the Linglong container environment.
If the project source code is correct. You can check if the executable file has been generated in the
linglong/output/runtime/files/bin
directory under the top-level directory of the project.If the application fails to launch, refer to the documentation for debugging within the container.
Step Six: Export the Layer File
Open a terminal in the top-level directory of the project source code (the same level as the linglong.yaml file) and execute the ll-builder export
command to generate the files ${appid}_${version}_${arch}_develop.layer
and ${appid}_${version}_${arch}runtime.layer
in the directory.
Step Seven: Test Installation of the Layer File
Open a terminal in the top-level directory of the project source code (the same level as the linglong.yaml file), type ll-cli install
, and after a space, drag the runtime.layer
file from the folder into the terminal and press Enter to execute, which will install the layer file into the local Linglong environment.
After the installation is successful, you should be able to see the application in the launcher and test it by starting and using it.
If the application cannot be found in the launcher, please check whether the file installation location in the project source code is correct. You can check if a
.desktop
file has been generated in thelinglong/output/runtime/entries/share/applications
directory under the top-level directory of the project.If there is a failure to start, you can view the corresponding
.desktop
file and copy the content of the Exec field to execute in the terminal to observe the startup output log. If there is a prompt that the Linglong corresponding version of thebase
orruntime
environment is missing, you will need to manually executell-cli install environment_name/version_number
to install and troubleshoot (e.g.,ll-cli install org.deepin.Runtime/23.0.1
).
With this, the process of building a Linglong format application from source code has been completed.
The example project in this article uses qmake for building, has simple dependencies, and supports setting the file installation location by passing in ${PREFIX}
from the outside during the build. It is very simple to build it as a Linglong format application. If the project uses cmake or other tools for building, similarly, you need to modify the installation prefix within the project or pass parameters in the build section of linglong.yaml
to set it. Otherwise, even if the build is successful, there may be various issues such as the executable file not being found within the container, or no icons appearing in the launcher after installation.
About [PM Direct]
[PM Direct] is a new feature launched by the deepin community in May 2024. In this column, we will invite product managers from various products to share and exchange interesting and useful deepin or Linux-related applications with everyone. The product managers will also engage in discussions and Q&A sessions with all users on the deepin forum.
Today's article comes from the deepin Community Store Product Manager, who is also a forum user of the deepin community known as [忘记、过去]. We hope everyone will continue to follow the deepin forum's feature column [PM Direct].
Appendix:
1)Linglong Official Documentation:https://linglong.dev/guide/ll-builder/introduction.html
2) deepin Previous Versions (Including deepin V15): https://distrowatch.com/table.php?distribution=deepin
Content source: deepin community
Reprinted with attribution