Software compatible operation method based on linux

By building compatible environment tools and overlayfs technology, the application compatibility problem of dpkg package management tool among different operating system versions is solved, and the application is unaware of the operation on different versions is achieved, which reduces maintenance costs and improves user experience.

CN118963785APending Publication Date: 2024-11-15KYLIN CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411054760.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

The existing dpkg package management tool has dependency conflicts, package conflicts and version compatibility issues when dealing with application compatibility between different operating system versions, resulting in application installation failure or system instability, and the multi-version coexistence and Cross-version compatibility.

Method used

Using Linux-based software compatible operation method, build application-compatible environments through building compatible environment tools, leverage overlayfs and namespace isolation technology to create compatible environments for each application separately, resolve dependency conflicts and provide compatibility solutions for desktop and system services. , realizes the compatible operation of the application on different operating system versions.

Benefits of technology

It realizes the unconscious compatible operation of the application on different operating system versions, reduces the application maintenance cost, solves the dependency conflict of multiple deb application software packages, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963785A_ABST
    Figure CN118963785A_ABST
Patent Text Reader

Abstract

The invention relates to a linux-based software compatible operation method, which relates to the field of computer technology, and comprises a basic environment construction stage, a basic environment installation stage, an application installation preparation stage, an application compatible environment construction stage, an application installation ending stage, an application operation stage, an application stopping stage and an application unloading stage. The application achieves the effects of solving the problem of application adaptation, reducing the application maintenance cost, providing consistent experience for users in different operating system versions, and realizing application cross-operating system version compatible operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a software compatible operation method based on Linux. Background Art

[0002] With the popularization of domestic operating systems, the Kylin operating system version has also undergone multiple version iterations, and V4 / V5 / V10 / V10 SP1 has been released. For existing users, upgrading the operating system is also on the agenda, but due to the underlying version of the operating system, it has become a big problem for the applications in the existing system to be compatible with the latest version of the system. Different version systems have certain differences in the underlying API, basic library version, and system resource management methods.

[0003] At present, desktop operating systems at home and abroad generally use the dpkg (Debian Package) package management tool. Although dpkg has a relatively complete software package ecosystem, it also has some shortcomings. dpkg does not actively resolve dependencies between software packages, which means that when installing a new software package, you must manually ensure that its dependencies have been installed, otherwise it may cause errors or software that cannot run properly. Although APT (Advanced Package Tool) can automatically resolve dependencies between software packages, in some cases, complex dependency chains may still cause problems. Especially when adding third-party software repositories or mixed versions of software packages, dependency resolution may become more complicated and can only be intervened manually. dpkg cannot effectively handle package conflicts. When multiple deb packages try to release files to the same system path, they usually prompt that the installation failed. If forced to overwrite, it may cause the system to be unstable or malfunction. Moreover, dpkg does not support the coexistence of multiple versions. When different applications in the operating system rely on different versions of deb packages, dpkg can only choose one of the versions to install, which often causes another application to produce an exception due to the incorrect version of the deb package it relies on. There is also a common cross-version problem with deb. A deb package on a system cannot be directly installed and run on a higher-version system because its dependent packages have API changes or function changes on the next-generation system. This requires developers to reinvest their efforts in adapting to the new version to solve the compatibility issue.

[0004] In order to solve the dependency or library conflicts of dpkg, Red Hat proposed Flatpak to solve the problem of Linux application distribution and dependency management. Flatpak allows developers to package applications and all their dependencies into a container. This container contains the application's files, libraries, runtime, and necessary dependencies, enabling the application to run on different Linux distributions. However, this solution requires application developers to abandon the original deb ecosystem and the compilation, packaging, and distribution process of dpkg, and re-adapt the flatpak package management system framework based on the source code. This will bring a great burden to developers, and some old deb packages' source code is no longer maintained by many developers. Therefore, it is also difficult to completely replace the dpkg software package with flatpak to solve the system cross-version compatibility problem. Therefore, there is an urgent need for a cross-system version application compatibility technology to solve the problem of application adaptation, reduce application maintenance costs, provide users with a consistent experience on different operating system versions, and realize cross-operating system version compatible operation of applications. Summary of the invention

[0005] In order to solve the above problems, the present invention provides a software compatible running method based on Linux.

[0006] In the first aspect, the present application provides a software compatible operation method based on Linux, which adopts the following technical solution: A software compatible operation method based on Linux, comprising: Step S1, basic environment construction phase: obtaining a construction configuration file, and a basic environment construction tool constructs a basic environment based on the construction configuration file; Step S2, basic environment installation phase: installing the constructed basic environment through the basic environment installation tool, and recording the configuration information of the basic environment into the basic environment layer configuration file; Step S3, application installation preparation stage: the application installation tool supporting the compatible environment uploads the path of the deb application software package and the name of the basic environment, and determines the basic environment information and builds the application layer based on the name of the basic environment and the basic environment layer configuration file. The application installation tool determines the software package information of the deb application software package based on the path of the deb application software package, and generates an application layer configuration file based on the software package information; Step S4, application compatible environment construction stage: the compatible environment construction tool constructs a new rootfs of the application compatible environment based on the application layer configuration file, and establishes an init process in the application compatible environment through the compatible environment construction tool, executes the installation operation of the deb application software package through the init process, and sends the installation result to the compatible environment installation tool; Step S5, application installation end stage: when the compatible environment installation tool receives the installation result, it processes the installation result, synchronizes the installation result to the application layer configuration file, and prompts the user of the installation result of the deb application software package; Step S6, application running stage: the compatible environment running tool obtains the corresponding basic environment layer directory and application directory in the application layer configuration file according to the name of the deb application software package, reactivates the application compatible environment and starts the init process in the application compatible environment, and creates a child process in the application compatible environment through the init process to execute the deb application software package in the application compatible environment; Step S7, application stop phase: when the init process receives the application stop information, it stops the subprocess of the corresponding application; Step S8, application uninstallation phase: when the init process receives the application uninstallation information, it terminates the process of the application to be uninstalled, and determines the application layer directory of the application to be uninstalled from the application layer configuration file and deletes it.

[0007] In another possible implementation manner, the basic environment construction tool constructs the basic environment based on the construction configuration file, including: The basic environment building tool generates an image of the corresponding minimum system according to the configuration information recorded in the building configuration file, releases the image to a building directory, and chroots to the minimum system; Complete the installation of the software packages in the basic environment and the configuration of the basic environment according to the software packages and software package version information recorded in the build configuration file.

[0008] In another possible implementation, the basic environment construction tool constructs the basic environment based on the construction configuration file, and then further includes: Compress the basic environment into a SquashFS binary file.

[0009] In another possible implementation, the installation operation of the deb application software package is performed through the init process, including: The compatible environment tool sends messages to the init process via socket communication; After receiving the message, the init process executes the installation command of the deb application software package within the application compatible environment.

[0010] In another possible implementation, the method further includes: The int process monitors the files released by the deb application software package. If the released files include desktop files, system icon files, and system service files, the int process adds application compatible environment startup parameters to the desktop files, system icon files, and system service files.

[0011] In another possible implementation manner, the user is prompted with the installation result of the deb application software package, and then the following is further included: The init process is automatically terminated, and the namespace corresponding to the init process is recycled.

[0012] In another possible implementation, the application layer directory of the application to be uninstalled is determined from the application layer configuration file and deleted, and then the following steps are further included: Synchronously update the application layer configuration file.

[0013] In summary, this application includes the following beneficial technical effects: This application builds a basic environment, and builds an application compatible environment for the application based on the basic environment and the deb application software package that needs to be run, so that the application can run in the application compatible environment without the need for application re-adaptation, thereby achieving the effect of being compatible with the deb application software package.

[0014] Moreover, the present application adopts a single application compatible environment structure, that is, an application compatible environment is created separately for each application. Since the application compatible environment is established based on the namespace, when multiple applications are in the same namespace, the rootfs, device resources, and network resources that can be accessed are the same, which may cause dependency conflicts among multiple deb application software packages. The single application compatible environment structure is used for namespace isolation, thereby effectively solving the dependency conflict problem among multiple deb application software packages. The present application also provides a compatibility solution for desktop files, icons, and system services, so that users can run applications in the compatible environment without noticing after installation, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a structural diagram of an application compatible environment in an embodiment of the present application.

[0016] Figure 2 It is a flowchart of a software compatible operation method based on Linux in an embodiment of the present application.

[0017] Figure 3 This is an example diagram of a directory structure corresponding to an application compatible environment in an embodiment of the present application.

[0018] Figure 4This is an example diagram of the relationship between a compatible environment running tool nickname and each compatible environment init process in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The present application is further described in detail below in conjunction with the accompanying drawings.

[0020] After reading this specification, those skilled in the art may make non-creative modifications to this embodiment as needed, but such modifications are protected by patent law as long as they are within the scope of the claims of this application.

[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0022] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.

[0023] The following is a further detailed description of the embodiments of the present application in conjunction with the accompanying drawings of the specification. The embodiments of the present application provide a software compatible operation method based on Linux, which uses a compatible environment tool to build an application compatible environment for a deb application software package, so that the deb application software package can run in the application compatible environment, thereby achieving the effect of solving the application adaptation problem, wherein the compatible environment tool is a tool chain that combines multiple tools, including: a basic environment construction tool, a basic environment installation tool, an application installation tool, and a compatible environment construction tool, specifically, Figure 1As shown, the rootfs in the application compatible environment will be implemented through overlay stacking. The application compatible environment specifically includes two parts: the base environment layer (Base Runtime Layer) and the application layer (Apps Runtime Layer). The base environment layer is the storage directory of all base environment data. When mounted, it is used as the lower layer of overlayfs. The application layer is the storage directory of all deb application software package data. It is mounted jointly with the base environment layer. When mounted, it is used as the upper of overlayfs, and all application layer dependent data is stored. In the embodiment of the present application, the deb application software package data in different application compatible environments are isolated from each other, and due to the characteristics of overlayfs, the changes made by the process in the application compatible environment to the base environment layer will only be reflected in the application layer of the application compatible environment, that is, the upper layer of the corresponding overlayfs, and will not damage the data of the base environment layer. And the use of overlay stacking in this application is implemented based on the isolation of Linux Ns mount points, so as to ensure that the mount points of overlayfs in the compatible environment will only be reflected in their respective compatible environments, and will not affect the real host environment.

[0024] Specifically, in the above-mentioned method for running software compatible with Linux, if Figure 2 As shown, the specific process includes: Step S1, basic environment construction phase: obtaining a construction configuration file, and a compatible environment tool constructs a basic environment based on the construction configuration file.

[0025] For the embodiment of the present application, the basic environment is the underlying support of the application compatible environment, and the basic environment construction tool has the function of building the basic environment. In order to meet the basic environment requirements for building different versions of systems, a build configuration file can be imported during construction to configure the basic environment name of the basic environment, the software packages in the basic environment, the software package versions, the domain name resolution in the basic environment and other information as needed. Specifically, when building the basic environment based on the build configuration file, the basic environment construction tool will first generate an image of the corresponding minimum system according to the configuration information recorded in the build configuration file and release the image to a build directory, and then chroot to the minimum system, and complete the installation of the software packages in the basic environment and the basic environment configuration work according to the information in the build configuration file, thereby achieving the effect of being able to flexibly build basic environments for different versions of systems. In the embodiment of the present application, in order to facilitate the verification of the integrity of the basic environment and facilitate the distribution of the basic environment, the basic environment will be compressed into a SquashFS binary file when the basic environment is built.

[0026] Step S2, basic environment installation phase: install the constructed basic environment through the basic environment installation tool, and record the information of the basic environment into the basic environment layer configuration file.

[0027] For the embodiment of the present application, when the basic environment installation operation is performed through the basic environment installation tool, the compatible environment installation tool will decompress the SquashFS binary file of the basic environment and release it to the corresponding location of the file system, such as Figure 3 The base directory shown in the figure then records the basic environment name, version, SquashFS release path and other information of the basic environment into the basic environment layer configuration file. The basic environment layer configuration file will be read by the application installation tool supporting the compatible environment in the subsequent application installation preparation stage and application running stage to obtain the SquashFS release path corresponding to the basic environment layer. The SquashFS release path is used for the lower layer parameters of the overlay stack.

[0028] Step S3, application installation preparation stage: the application installation tool supporting the compatible environment uploads the path of the deb application software package and the name of the basic environment, and determines the basic environment information and builds the application layer based on the name of the basic environment and the basic environment layer configuration file. The application installation tool determines the software package information of the deb application software package based on the path of the deb application software package, and generates an application layer configuration file based on the software package information.

[0029] For the embodiment of the present application, the application installation preparation stage, the application compatible environment construction stage in step S4, and the application installation end stage in step S5 are combined into the application installation stage of the application compatible environment. Specifically, in the embodiment of the present application, the compatible environment has a matching application installation tool. The installation of the application software package can be completed by simply passing in the path of the deb application software package and the name of the basic environment through the application installation tool matching the compatible environment.

[0030] More specifically, after the application installation tool supporting the compatible environment uploads the path of the deb application software package and the name of the basic environment, the application installation tool will find the corresponding basic environment information in the basic environment layer configuration file obtained in step S2 according to the passed-in basic environment name, so as to determine the lower layer parameters of the overlay stack based on the basic environment information in the future, and create an application directory with the same name as the name of the basic environment in the file system as the application layer for building the application compatible environment, and the application directory will be used as the upper layer parameter of the subsequent overlay stack, and then the application installation tool will determine the software package information of the deb application software package based on the path of the deb application software package (the software package information includes the deb application software package name, software package version, application directory, and the name of the basic environment corresponding to the deb application software package and the basic environment layer directory), and record the software package information in the application layer configuration file, thereby establishing a mapping relationship between an application software package and a basic environment, so that the subsequent compatible environment construction tool can directly obtain the application compatible environment information of the corresponding deb application software package by reading the application layer configuration file when executing the application compatible environment construction phase of step S4 and the application running phase of step S5.

[0031] Step S4, application compatible environment construction phase: the compatible environment construction tool constructs a new rootfs of the application compatible environment based on the application layer configuration file, and establishes an init process in the application compatible environment through the compatible environment construction tool, executes the installation operation of the deb application software package through the init process, and sends the installation result to the compatible environment installation tool.

[0032] For the embodiment of the present application, the compatible environment construction tool will be automatically executed during the application compatible environment construction phase. The application directory created in step S3 is an empty directory. The compatible environment construction tool will find the basic environment layer directory and application directory corresponding to the deb application software package in the application layer configuration file, and based on the kernel Linux Namespace mechanism, pass CLONE_NEWNS and CLONE_NEWUSER through the clone system to complete the mount point isolation and user namespace isolation, obtain the compatible environment sub-namespace, and use the basic environment layer directory and application layer directory extracted from the application layer configuration file as overlay stacking parameters to complete the rootfs mount of the compatible environment (such as Figure 1As shown), the application compatibility environment construction operation is completed. After that, the compatible environment construction tool will pull up an init process inside the built application compatible environment. The init process inside the application compatible environment is an executable file that matches the compatible environment construction tool. As the first process running in the application compatible environment, it is responsible for receiving messages sent by the compatible environment tool and controlling the status of the running process in the application compatible environment, thereby achieving the effect of full life cycle control of the running process in the subsequent application compatible environment.

[0033] Specifically, the installation operation of the deb application software package is performed through the init process, including: The application installation tool sends a message to the init process through socket communication. After receiving the message, the init process executes the installation command of the deb application software package in the application compatible environment, thereby completing the operation of installing the deb application software package in the application compatible environment. Furthermore, the installation files of the deb application software package are released to the application directory corresponding to the application layer for the real host machine, such as Figure 3 The corresponding application directory under the app shown.

[0034] Furthermore, in an embodiment of the present application, the init process will send some information and installation results of the deb application package installation process to the compatible environment installation tool through socket communication.

[0035] Furthermore, in the embodiment of the present application, when creating an application compatible environment, the / home, / usr / share, / etc / systemd, / usr / lib / systemd, / etc / xdg / autostart of the real environment will be mounted to the / tmp / kare directory in the compatible environment through bind mount, and when the init process in the compatible environment executes the installation of the deb software package, it will actively monitor the files released by deb. If it is monitored that the software package involves desktop files, system icons, and system services, the init process will actively copy the files released by deb to the compatible environment to the binding directory corresponding to / tmp / kare, and the init process will modify the Exec field of the desktop and service files, and add the compatible environment startup parameters. It is guaranteed that the compatible environment application can be started directly by double-clicking the desktop application icon in the real environment.

[0036] Step S5, application installation end stage: when the compatible environment installation tool receives the installation result, it processes the installation result, synchronizes the installation result to the application layer configuration file, and prompts the user of the installation result of the deb application software package.

[0037] For the embodiment of the present application, when the compatible environment installation tool receives the installation result sent by the init process, it will perform message processing on the installation result, synchronize the installation result to the application layer configuration file, and prompt the user of the installation status of the deb application software package.

[0038] Furthermore, after the installation process is completed, the init process will be automatically terminated, and the namespace corresponding to the init process will also be recycled by the kernel.

[0039] Step S6, application running stage: the compatible environment running tool obtains the corresponding basic environment layer directory and application directory in the application layer configuration file according to the name of the deb application software package, reactivates the application compatible environment and starts the init process in the application compatible environment, and creates a child process in the application compatible environment through the init process to execute the deb application software package in the application compatible environment.

[0040] Step S7, application stop phase: when the init process receives the application stop information, it stops the subprocess of the corresponding application.

[0041] For the embodiment of the present application, during the application stop phase, it is only necessary to notify the init process in the application compatible environment. When the init process receives the information that the application is stopped, it will stop the sub-process of the corresponding application, thereby achieving the effect of stopping the application.

[0042] Furthermore, when all child processes corresponding to the init process are stopped, the init process will also stop itself and recycle the compatible environment sub-namespace. The relationship between the compatible environment running tool process and each compatible environment init process is as follows: Figure 4 As shown, Figure 4 From the root to the leaf nodes, they are: init is the init of the host environment, kare-wrap is the tool process running in the compatible environment, kare-init is the init in the compatible environment, and appX (app1, app2, app3) is the process in the compatible environment.

[0043] Step S8, application uninstallation phase: when the init process receives the application uninstallation information, it terminates the process of the application to be uninstalled, and determines the application layer directory of the application to be uninstalled from the application layer configuration file and deletes it.

[0044] For the embodiment of the present application, due to the isolation characteristics of the application compatible environment rootfs and the overlayfs file system function, the files generated by the installation and operation of the application compatible environment in the host machine are stored in a separate directory. The application compatible environment is stored in a directory in the host machine such as Figure 3As shown in the figure, the base directory stores the number of basic environment layers, and the name of the deb application installation package is installed in the app directory to store the application layer data. When you need to uninstall an application, you only need to notify the init process to end all processes corresponding to the application, and determine the application layer directory corresponding to the application from the application layer configuration file and delete it to complete the operation of uninstalling the application.

[0045] Furthermore, in the embodiment of the present application, after the application is uninstalled, the application layer configuration file needs to be updated synchronously.

[0046] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A software compatible operation method based on Linux, characterized in that: include: Step S1, basic environment construction phase: obtaining a construction configuration file, and a basic environment construction tool constructs a basic environment based on the construction configuration file; Step S2, basic environment installation phase: installing the constructed basic environment through the basic environment installation tool, and recording the configuration information of the basic environment into the basic environment layer configuration file; Step S3, application installation preparation stage: the application installation tool supporting the compatible environment uploads the path of the deb application software package and the name of the basic environment, and determines the basic environment information and builds the application layer based on the name of the basic environment and the basic environment layer configuration file. The application installation tool determines the software package information of the deb application software package based on the path of the deb application software package, and generates an application layer configuration file based on the software package information; Step S4, application compatible environment construction stage: the compatible environment construction tool constructs a new rootfs of the application compatible environment based on the application layer configuration file, and establishes an init process in the application compatible environment through the compatible environment construction tool, executes the installation operation of the deb application software package through the init process, and sends the installation result to the compatible environment installation tool; Step S5, application installation end stage: when the compatible environment installation tool receives the installation result, it processes the installation result, synchronizes the installation result to the application layer configuration file, and prompts the user of the installation result of the deb application software package; Step S6, application running stage: the compatible environment running tool obtains the corresponding basic environment layer directory and application directory in the application layer configuration file according to the name of the deb application software package, reactivates the application compatible environment and starts the init process in the application compatible environment, and creates a child process in the application compatible environment through the init process to execute the deb application software package in the application compatible environment; Step S7, application stop phase: when the init process receives the application stop information, it stops the subprocess of the corresponding application; Step S8, application uninstallation phase: when the init process receives the application uninstallation information, it terminates the process of the application to be uninstalled, and determines the application layer directory of the application to be uninstalled from the application layer configuration file and deletes it.

2. A Linux-based software compatible operation method according to claim 1, characterized in that: The basic environment construction tool constructs a basic environment based on the construction configuration file, including: The basic environment building tool generates an image of the corresponding minimum system according to the configuration information recorded in the building configuration file, releases the image to a building directory, and chroots to the minimum system; Complete the installation of the software packages in the basic environment and the configuration of the basic environment according to the software packages and software package version information recorded in the build configuration file.

3. The method for running software compatible with Linux according to claim 1, characterized in that: The basic environment construction tool constructs the basic environment based on the construction configuration file, and then further includes: Compress the basic environment into a SquashFS binary file.

4. The method for running software compatible with Linux according to claim 1, characterized in that: The installation of the deb application software package is performed through the init process, including: The compatible environment construction tool sends messages to the init process through socket communication; After receiving the message, the init process executes the installation command of the deb application software package within the application compatible environment.

5. A Linux-based software compatible operation method according to claim 4, characterized in that: The method further comprises: The int process monitors the files released by the deb application software package. If the released files include desktop files, system icon files, and system service files, the int process adds application compatible environment startup parameters to the desktop files, system icon files, and system service files.

6. The method for running software compatible with Linux according to claim 1, characterized in that: The user is prompted with the installation result of the deb application software package, and then: The init process is automatically terminated, and the namespace corresponding to the init process is recycled.

7. The method for running software compatible with Linux according to claim 1, characterized in that: Determine the application layer directory of the application to be uninstalled from the application layer configuration file and delete it, followed by: Synchronously update the application layer configuration file.

Citation Information

Cited By

  • Method of updating root file system under open-sourced operating system

    TWI938014B