Source package building and packaging method, device, and storage medium

By creating an isolated environment in the Linux system memory and using compilation and packaging tools, combined with multi-task parallel processing in the container, the problem of low source code package construction and packaging speed is solved, and efficiency and work efficiency are improved.

WO2024174756A1PCT designated stage expired Publication Date: 2024-08-29ZTE CORP

Patent Information

Application Number
PCT/CN2024/071203
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-22
Filing Date
2024-01-08
Publication Date
2024-08-29

AI Technical Summary

Technical Problem

In the existing technology, the source code package construction and packaging rate is low, which causes the environment preparation and compilation process to take too long when debugging or fault verification of open source components, and cannot meet the need for rapid feedback, especially when hardware resources are limited.

Method used

By creating an isolated environment in the memory of the Linux system, we use compilation tools and packaging tools to compile and package source code packages, including preset configuration files and cached intermediate data to improve efficiency, and perform multi-task parallel processing in containers.

Benefits of technology

It significantly improves the speed and efficiency of source code package construction and packaging, reduces the time consumption in the compilation and packaging process, supports multiple users to build and package at the same time, and improves work efficiency and product delivery capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024071203_29082024_PF_FP_ABST
    Figure CN2024071203_29082024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of application development, and discloses a source package building and packaging method, a device, and a storage medium. The method of the present application comprises: acquiring a first source package to be compiled; invoking a compiling tool on the basis of a dependent package required for compilation and installed in an isolation environment, and compiling the first source package by means of the compiling tool to obtain a target binary package of the first source package, wherein the isolation environment is created in advance on the basis of a preset first configuration file and is mounted in a memory of a Linux system; and invoking a packaging tool, and packaging the target binary package of the first source package into a Linux software package by means of the packaging tool.
Need to check novelty before this filing date? Find Prior Art

Description

Source code package construction and packaging method, equipment and storage medium

[0001] Related applications

[0002] This application claims priority to Chinese patent application No. 202310151940.X filed on February 22, 2023, the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of application development technology, and in particular to a source code package construction and packaging method, device, and storage medium. Background Art

[0004] When some open source components require frequent debugging or fault verification, and the code size of the component is large, the environment preparation, compilation process, and packaging before compiling the source code package of the component will take a long time, which cannot meet the needs of rapid feedback.

[0005] Therefore, there is a problem in the related art that the source code package construction and packaging rate is low.

[0006] Summary of the Invention

[0007] The main purpose of this application is to provide a source code package construction and packaging method, device and storage medium, aiming to solve the technical problem of low source code package construction and packaging rate.

[0008] To achieve the above objectives, the present application provides a source code package construction and packaging method, the source code package construction and packaging method comprising the following steps:

[0009] Obtain the first source code package to be compiled;

[0010] Based on dependency packages required for compilation that have been installed in the isolation environment, calling a compilation tool, and compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, wherein the isolation environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system;

[0011] A packaging tool is called to package the target binary package of the first source code package into a Linux software package through the packaging tool.

[0012] The present application also provides a source code package construction and packaging device, which includes: a memory, a processor, and a source code package construction and packaging program stored in the memory and executable on the processor, wherein the source code package construction and packaging program is configured to implement the steps of the source code package construction and packaging method as described in any one of the above items.

[0013] The present application also provides a storage medium, on which a source code package construction and packaging program is stored. When the source code package construction and packaging program is executed by a processor, the steps of the source code package construction and packaging method as described in any one of the above items are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] FIG1 is a flow chart of a first embodiment of a method for constructing and packaging a source code package according to the present application;

[0015] FIG2 is a logical architecture diagram of a source code package construction and packaging method according to a first embodiment of the present application;

[0016] FIG3 is a schematic diagram of a first scenario of a method for constructing and packaging a source code package according to a second embodiment of the present application;

[0017] FIG4 is a schematic diagram of a second scenario of the source code package construction and packaging method according to the third embodiment of the present application;

[0018] FIG5 is a schematic diagram of a third scenario of the source code package construction and packaging method according to the fourth embodiment of the present application;

[0019] FIG6 is a schematic diagram of the structure of a source code package construction and packaging device for the hardware operating environment involved in the embodiment of the present application.

[0020] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0021] It should be understood that the specific embodiments described herein are intended only to explain the present application and are not intended to limit the present application. Although terms such as first, second, and third may be used herein to describe various information, such information should not be limited to these terms. These terms are merely used to distinguish information of the same type from one another. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information.

[0022] The present application embodiment provides a method for constructing and packaging a source code package. Referring to FIG. 1 and FIG. 2 , in this embodiment, the method for constructing and packaging a source code package includes:

[0023] Step S10: Obtain a first source code package to be compiled;

[0024] Step S20: Based on the dependency packages required for compilation installed in the isolated environment, calling a compilation tool, and compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, wherein the isolated environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system;

[0025] Step S30: calling a packaging tool, and packaging the target binary package of the first source code package into a Linux software package through the packaging tool.

[0026] Application scenarios of this application include:

[0027] Scenario 1: When using RPM (Red-Hat Package Manager) to manage and maintain a large number of open source components, managing and maintaining a large number of open source components includes installing, uninstalling, upgrading, and managing software. RPM is required to build and package the open source components into RPM packages so that users can download or install the software packages through RPM, resulting in low management efficiency.

[0028] Scenario 2: For open source components that require frequent changes (for fault repair or verification) and have a large amount of code, if they need to be released as software packages after the changes, the open source components need to be built and packaged. The build process includes preparing the basic compilation environment, installing dependent packages, and the compilation process. If the open source component has a large amount of code or requires frequent changes, the build and packaging process will take too long, reducing distribution efficiency and affecting user usage.

[0029] Scenario 3: On the same server, multiple users need to build and package open source components at the same time. However, hardware resources and basic compilation environments are relatively limited, making it impossible for multiple users to build and package open source components simultaneously, resulting in low work efficiency.

[0030] Scenario 4: When the delivered product consists of multiple packaged open source components and requires fast and stable delivery, due to relatively limited hardware resources and basic compilation environment, multiple build and packaging tasks cannot be performed simultaneously. As a result, multiple packaged open source components cannot be obtained simultaneously, quickly, and stably, resulting in the inability to deliver the product on time and low work efficiency.

[0031] This embodiment aims to: for scenario one, build an isolated environment and mount the isolated environment into the memory of the Linux system to improve the efficiency of compilation in the isolated environment. For scenario two, retain the basic environment of the previous build and build and package it on its basis to improve efficiency. For scenario three, build a mirror container, build and package the source code package in the container, and realize multi-tasking in parallel. For scenario four, customize resource quotas when running in the container to realize multiple build and packaging tasks at the same time and improve work efficiency.

[0032] The specific steps are as follows:

[0033] Step S10: Obtain a first source code package to be compiled;

[0034] As an example, a source package consists of code files.

[0035] As an example, building and packaging includes: building a compilation environment, a compilation process, and a packaging process after compilation.

[0036] As an example, the source code package construction and packaging method can be applied to a source code package construction and packaging device, which runs based on a source code package construction and packaging program.

[0037] As an example, compilation refers to the process of using a compiler / compilation tool to generate a target program (Linux software package) from a source program (source code package) written in a source language. A Linux software package refers to an installation package that users can download and perform simple configuration to run on a Linux system.

[0038] As an example, formats of Linux software packages include rpm format, dpkg format, deb format, etc.

[0039] As an example, the first source code package to be compiled refers to a source code package received by a user that needs to be compiled.

[0040] As an example, obtaining the first source code package to be compiled may be receiving a source code package to be compiled imported by a user, or may be automatically obtaining a source code package to be compiled stored in a database, etc., which is not limited here.

[0041] Step S20: Based on the dependency packages required for compilation installed in the isolated environment, calling a compilation tool, and compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, wherein the isolated environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system;

[0042] As an example, the compilation environment can be constructed by using a mock tool, a yum tool, a dnf tool, etc. The mock tool can be Easymock, jmock, mockito, etc., which is not limited here.

[0043] As an example, for ease of description, the following specifically illustrates an environment construction tool as a mock tool.

[0044] As an example, an isolated environment refers to file system isolation, that is, each process runs in a completely independent root file system.

[0045] As an example, the isolated environment can be created in advance by the user through an environment generation tool based on a preset first configuration file of the mock tool. Specifically, the environment generation tool can be a chroot (change root) tool or a systemd-nspawn tool.

[0046] As an example, the isolated environment may be a chroot environment or a container image.

[0047] As an example, the user uses the environment generation tool to generate an isolated working directory in advance, and based on the preset first configuration file of the mock tool, the isolated working directory is mounted to the memory of the Linux system. That is, the isolated environment is created. When the source code package construction and packaging program is run, it will run in the isolated working directory in the memory of the Linux system, and will not affect other programs running in memory. Moreover, compared with the original source code package construction and packaging program running on disk, running it in memory can improve IO access speed, increase the running speed of the source code package construction and packaging program, and improve the efficiency of source code package construction and packaging.

[0048] As an example, the preset first configuration file of the mock tool may include the user's setting (open (enable) or close (disable)) of the plug-in tmpfs (temporary file system, a memory-based file system) built into the mock tool plug-in.

[0049] In one embodiment, the isolated working directory can be mounted to the memory file system tmpfs by enabling the built-in plug-in tmpfs of the mock tool. Specifically, the method of enabling the plug-in tmpfs is to set the attribute tmpfs_enable of the tmpfs plug-in in the preset first configuration file of the mock tool to True.

[0050] As an example, by setting the properties of the built-in plug-in tmpfs of the mock tool plug-in, memory settings such as memory usage size (memory usage upper and lower limits) can also be performed to avoid excessive memory usage of the Linux system and affecting the operation of other applications.

[0051] As an example, the dependency package is the dependency package required for the compilation process that is pre-installed in the isolated environment after the isolated environment is created (when the mock tool runs the compilation tool and the packaging tool, the required dependency components are required to avoid the compilation and packaging from failing due to the lack of dependency packages).

[0052] In one embodiment, the component list of the chroot environment in the preset first configuration file may be read, and the installation of the dependent packages required for compilation may be completed through a warehouse management tool.

[0053] As an example, after the basic environment (isolated environment and dependent packages) required for compilation are prepared (loaded), the first source code package can be compiled.

[0054] As an example, the compilation tool may be VS Code, Source Insight, etc., which is not limited here.

[0055] As an example, the compilation tool can be called through the mock command, and the compilation task can be started through the rpmbuild command. The compilation task specifies that the first source code package to be compiled is compiled based on the preset first configuration file to obtain a target binary package of the first source code package converted into binary format.

[0056] Step S30: calling a packaging tool, and packaging the target binary package of the first source code package into a Linux software package through the packaging tool.

[0057] As an example, the source code package construction packaging device calls a compilation tool. After the compilation tool compiles the first source code package into a target binary package, the target binary package needs to be packaged to facilitate user download and installation.

[0058] As an example, the source code package building and packaging device calls a packaging tool to package the target binary package of the first source code package into a Linux software package. Because the Linux software package has been compiled before it is released, the user's installation of the Linux software package is accelerated, and the probability of error during the installation process is greatly reduced, making it easier for users to use.

[0059] In this embodiment, a first source code package to be compiled is obtained; based on the dependency packages required for compilation that have been installed in the isolation environment, a compilation tool is called, and the first source code package is compiled by the compilation tool to obtain a target binary package of the first source code package, wherein the isolation environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system; a packaging tool is called, and the target binary package of the first source code package is packaged into a Linux software package by the packaging tool. Since the isolation environment is mounted into the memory of the Linux system, building and packaging in the isolation environment will increase the IO (Input / Output) access speed of the packaging environment, thereby speeding up the construction and packaging of the source code package.

[0060] Based on the above embodiment, another embodiment of the present application is provided. In this embodiment, referring to FIG. 3 , the target binary includes multiple single binary packages. Before the step of compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, the method further includes:

[0061] Step S40: determining target single binary packages that do not need to be compiled in the first source code package based on the preset construction parameters in the preset first configuration file, so that the compilation tool does not compile the target single binary packages that do not need to be compiled.

[0062] As an example, the preset first configuration file of the mock tool may further include preset construction parameters.

[0063] As an example, the preset building parameters are pre-set in a preset first configuration file, and specifically, can be implemented through the option --rpmbuild-opts of the mock tool.

[0064] As an example, during the compilation process, the compilation tool does not compile the target single binary package that does not need to be compiled in the first source code package determined based on the preset construction parameters, so as to save the compilation process and speed up the compilation speed.

[0065] As an example, the compilation process involves compiling multiple source code files within a source code package into multiple single binary packages. Each single binary package includes binary files, regular files, and header files compiled from the source code files. Skipping single binary packages that don't need to be compiled can reduce the compilation workload and speed up compilation. Specifically, single binary packages that don't need to be compiled include document class packages and third-party interface packages.

[0066] In this embodiment, the preset construction parameters are custom parameters in the preset first configuration file, or macro definition switches built into the compilation tool.

[0067] As an example, a spec file can be used to define which single binary packages do not need to be compiled in the custom parameters of the preset first configuration file. Alternatively, a macro definition switch built into the compilation tool can be used to set the default value of 1 when the target macro is undefined. If the corresponding macro definition exists in the preset build parameters and the macro definition is 0, the compilation of the current single binary package is skipped. In one embodiment, the macro switch can be with_debuginfo or undef_DEBUG, etc.

[0068] In this embodiment, after the step of compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, the method further includes:

[0069] Step S50: Based on the preset first configuration file, determine to cache the intermediate data generated by the compilation tool during the compilation of the first source code package, so that when the compilation tool compiles the same source code file again, it can compile based on the intermediate data corresponding to the same source code file.

[0070] As an example, the preset first configuration file of the mock tool may also include the user's settings for the ccache (compiler cache) plug-in built into the mock tool plug-in, which can cache the intermediate data of the previous compilation and use the cached information in the same part of the compiled content, reducing the number of preprocessed and compiled source code files to speed up the compilation speed.

[0071] In one embodiment, the setting of the built-in plug-in ccache of the mock tool plug-in may be to enable the built-in plug-in ccache of the mock tool in a preset first configuration file. If the yum tool is used, the plug-in yum_cache is enabled in the configuration file of the yum tool.

[0072] As an example, during the compilation process, when the compilation tool compiles the same source code file again, the compilation is performed based on the intermediate data corresponding to the same source code file, which can avoid repeated parsing when the same source code file is compiled again.

[0073] In this embodiment, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the method further includes:

[0074] Step S60: determining whether to retain the isolation environment, the dependent package, and the intermediate data cache settings based on the preset mock parameters in the preset first configuration file;

[0075] As an example, the preset first configuration file of the mock tool may further include preset mock parameters, where the preset mock parameters are pre-set in the preset first configuration file.

[0076] As an example, you can add the no-clean parameter or the --no-cleanup-after parameter to the preset mock parameters to preserve the basic environment of the isolation environment, dependency packages, and intermediate data cache settings.

[0077] Step S70: If retained, when the preset first configuration file is called again, the steps of creating the isolated environment and installing the dependent package in the isolated environment are not performed, and the step of caching the intermediate data is performed.

[0078] As an example, when the preset first configuration file is called again to build and package the source code package, based on the mock parameter settings for retaining the isolation environment, dependency packages, and intermediate data cache settings in the preset first configuration file, the steps of creating the isolation environment and installing the dependency packages in the isolation environment are not performed, and the intermediate data cache step is performed. This avoids the time consumption caused by rebuilding the isolation environment, reinstalling the dependency packages, and resetting the intermediate data cache settings when the preset first configuration file is called again to build and package the source code file, thereby improving the efficiency of building the basic environment when building and packaging the source code package again.

[0079] In this embodiment, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the method further includes:

[0080] Step S80: Based on the preset first configuration file, maintain the mounting state of the isolated environment.

[0081] As an example, the preset first configuration file of the mock tool may further include the user's settings for the properties of the plug-in tmpfs built into the mock tool plug-in.

[0082] As an example, the keep-mounted attribute of tmpfs can be set. After enabling keep-mounted of tmpfs, the isolated working directory can still be mounted to the memory file system tmpfs after the isolation environment construction task is completed. That is to say, the isolated working directory is still mounted to the memory of the Linux system to maintain the mount status of the isolation environment.

[0083] As an example, when the preset first configuration file is called again to build and package the source code package, the retained isolation environment is still in a mounted state, or the rebuilt isolation environment is in a mounted state, etc., without the need for reconfiguration, which can improve the efficiency of building and packaging again.

[0084] In this embodiment, in terms of the compilation object, a single binary package that does not need to be compiled is skipped by setting a default or custom macro switch in the preset first configuration file, thereby reducing the compilation task. In terms of the compilation process, the cache plug-in ccache built into the mock tool is enabled, and the intermediate data generated during the compilation process is cached by ccache. When the same source code file is compiled again, it is compiled based on the intermediate data corresponding to the same source code file, which can avoid repeated parsing when the same source code file is compiled again. In terms of the compilation environment, the isolation environment, dependency package and intermediate data cache settings are retained to avoid the time consumption caused by re-calling the preset first configuration file to build and package the source code file, and re-building the isolation environment, re-installing the dependency package, and re-setting the intermediate data cache settings, thereby improving the efficiency of the basic environment construction when the source code package is built and packaged again.

[0085] Based on the above embodiment, another embodiment of the present application is provided. In this embodiment, referring to FIG. 4 , after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the method further includes:

[0086] Step S90: Obtain a second source code package to be compiled;

[0087] As an example, obtaining the second source code package to be compiled refers to obtaining the second, third, or nth source code package after the first source code package is built and packaged.

[0088] Step S100: In the reserved isolation environment in which the dependent package is installed, based on the preset build parameters in the called preset second configuration file, determining a target single binary package that does not need to be compiled in the second source code;

[0089] As an example, the isolated environment with the dependency package installed is the basic environment (isolated environment, the dependency package, and the intermediate data cache settings) retained after the first source code package is built and packaged based on the preset mock parameters in the preset first configuration file. When the second source code package is compiled again,

[0090] As an example, the invoked preset second configuration file may retain the preset first configuration file configured when building and packaging the first source code package. The preset build parameters in the preset second configuration file may also be the preset build parameters configured when building and packaging the first source code package. In other words, based on the preset build parameters in the preset first configuration file, a target single binary package that does not need to be compiled in the second source code package can be determined.

[0091] Step S110: calling a compilation tool to compile the single binary package in the second source code package except the target single binary package by the compilation tool to obtain the target binary package of the second source code package;

[0092] As an example, a compilation tool is called to compile a single binary package other than the target single binary package in the second source code package through the compilation tool to obtain the target binary package of the second source code package; thereby reducing the compilation task on the compilation object and improving the compilation speed.

[0093] Step S120: calling a packaging tool, and packaging the target binary package of the second source code package into a Linux software package through the packaging tool.

[0094] As an example, a packaging tool is called to package the target binary package of the second source code package into a Linux software package through the packaging tool, so that a single-task construction solution can be quickly completed.

[0095] In this embodiment, by calling the basic environment retained from the previous build and packaging task to build and package a new source code package, the process of environment construction and file configuration is saved, and the efficiency of single-task re-build and packaging is improved. This greatly shortens the build and packaging time of large Linux open source components such as the kernel, reducing the time cost of developers' requirements development or troubleshooting.

[0096] Based on the above embodiment, another embodiment of the present application is provided. In this embodiment, considering that the memory size consumed by the chroot environment generated by the mock tool can be controlled by the characteristic parameters of the plug-in tmpfs, the CPU resources consumed during construction and packaging cannot be flexibly controlled, a stuck scenario may occur when multiple mock tools are running simultaneously, resulting in the inability to effectively support multiple users calling the mock tool to build and package the source code package at the same time. If the cgroups supported by the kernel are used to control CPU resources, it is necessary to create a control directory, mount the cgroups (control groups, a function of the Linux kernel for limiting, controlling and separating the resources (such as CPU, memory, disk input and output, etc.) of a process group) file system, fill in the target process number in the tasks file and configure it, etc., which will make the multi-tasking implementation process more complicated and inconvenient to achieve flexible control of batch tasks. In addition, the mock tool relies on the configuration file and the corresponding component warehouse source address in the file to generate the chroot environment. Before calling, the host needs to install the mock tool and adjust the configuration file in advance. The same mock configuration file can only run one chroot build environment at the same time, and the steps of setting up and distributing the build environment are relatively cumbersome.

[0097] In this embodiment, referring to FIG3 and FIG5 , after the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, the method further includes:

[0098] Step S130: Obtain the third source code package to be compiled;

[0099] As an example, obtaining the second source code package to be compiled refers to obtaining the nth source code package or multiple source code packages obtained simultaneously after the construction and packaging of the first source code package is completed.

[0100] Step S140: calling a compilation tool in a preset container, and compiling the third source code package by the compilation tool to obtain a target binary package of the third source code package;

[0101] In this embodiment, the preset container is generated by cleaning up non-essential files in the isolated environment according to a preset cleaning method after the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, compressing the cleaned isolated environment into a container image, and importing the container image into the container engine.

[0102] As an example, the container engine may be Docker, Kata Containers, etc., which is not limited here.

[0103] As an example, the non-essential files include document packages, localized language packages, and localized files, and the cleaning method of the preset cleaning method is based on the principle that the cleaning does not affect the secondary construction and packaging of the source code package.

[0104] As an example, a specific packaging method may be to compress and archive the cleaned isolation environment into a container image using a tar package tool, and then import the container image into a container engine to generate a container when in use.

[0105] As an example, a compilation tool is called in a preset container, and the third source code package is compiled by the compilation tool to obtain a target binary package of the third source code package. That is to say, multiple containers can be generated at the same time for users to use, realizing multi-tasking parallelism and improving work efficiency.

[0106] Step S150: calling a packaging tool, and packaging the target binary package of the third source code package into a Linux software package through the packaging tool.

[0107] As an example, after the compilation is completed, a packaging tool is called to package the target binary package of the third source code package into a Linux software package through the packaging tool, thereby completing multi-task simultaneous construction and packaging.

[0108] In this embodiment, before the step of compiling the third source code package using the compilation tool to obtain a target binary package of the third source code package, the method further includes:

[0109] Step S160: Based on the called preset third configuration file, determine the resource quota of the container during operation, wherein the resource quota at least includes the memory usage and CPU resource usage of the container during operation.

[0110] As an example, the resource quota of a container runtime includes the memory usage, CPU resource usage, and container host name settings during the container's operation.

[0111] As an example, you can use the docker run --memory command to set a memory quota (upper limit) to avoid uncontrollable memory and OOM (Out of Memory) when multiple containers are running simultaneously. You can also use the docker run --cpu-shares command to set a CPU quota to avoid CPU resource exhaustion and freezing when multiple containers are executing build and packaging tasks simultaneously. You can also use the --hostname command to adjust the container host name to automatically distinguish multiple build and packaging tasks.

[0112] In this embodiment, a container image is generated using a preserved isolated environment and dependency packages, making it easier for enterprises to use container orchestration tools to batch build and package source code packages, reducing the time cost of building and packaging, and significantly improving the product delivery efficiency of operating system-related companies.

[0113] Refer to Figure 6, which is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.

[0114] As shown in FIG6 , the source code package construction and packaging device may include: a processor 1001 , a memory 1005 , and a communication bus 1002 . The communication bus 1002 is used to implement connection and communication between the processor 1001 and the memory 1005 .

[0115] In one embodiment, the source code package construction and packaging device may further include a user interface, a network interface, a camera, an RF (Radio Frequency) circuit, a sensor, a WiFi module, and the like. The user interface may include a display screen and an input submodule such as a keyboard. The user interface may also include a standard wired interface and a wireless interface. The network interface may include a standard wired interface and a wireless interface (such as a WiFi interface).

[0116] Those skilled in the art will understand that the source code package building and packaging device structure shown in Figure 6 does not constitute a limitation on the source code package building and packaging device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0117] As shown in FIG6 , the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, and a source code package construction and packaging program. The operating system is a program that manages and controls the hardware and software resources of the source code package construction and packaging device, and supports the operation of the source code package construction and packaging program and other software and / or programs. The network communication module is used to enable communication between the various components within the memory 1005, as well as communication with other hardware and software in the source code package construction and packaging system.

[0118] In the source code package construction and packaging device shown in FIG6 , the processor 1001 is configured to execute the source code package construction and packaging program stored in the memory 1005 to implement the steps of any one of the above-mentioned source code package construction and packaging methods.

[0119] The specific implementation of the source code package construction and packaging device of the present application is basically the same as the various embodiments of the source code package construction and packaging method described above, and will not be repeated here.

[0120] The present application also provides a source code package construction and packaging device, the device comprising:

[0121] A first acquisition module, used to acquire a first source code package to be compiled;

[0122] a first compilation module, configured to call a compilation tool based on dependency packages required for compilation installed in the isolation environment, and compile the first source code package using the compilation tool to obtain a target binary package of the first source code package, wherein the isolation environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system;

[0123] The first packaging module is used to call a packaging tool to package the target binary package of the first source code package into a Linux software package through the packaging tool.

[0124] In a possible implementation of the present application, the target binary includes multiple single binary packages. Before the step of compiling the first source code package using the compilation tool to obtain the target binary package of the first source code package, the apparatus further includes:

[0125] The first determining module is configured to determine a target single binary package in the first source code package that does not need to be compiled based on the preset construction parameters in the preset first configuration file, so that the compilation tool does not compile the target single binary package that does not need to be compiled.

[0126] In a possible implementation of the present application, after the step of compiling the first source code package using the compilation tool to obtain a target binary package of the first source code package, the apparatus further includes:

[0127] The second determination module is used to determine, based on the preset first configuration file, to cache the intermediate data generated by the compilation tool in the process of compiling the first source code package, so that when the compilation tool compiles the same source code file again, it can compile based on the intermediate data corresponding to the same source code file.

[0128] In a possible implementation manner of the present application, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the apparatus further includes:

[0129] A third determination module is used to determine whether to retain the isolation environment, the dependent package, and the intermediate data cache setting based on the preset mock parameters in the preset first configuration file;

[0130] The retention module is used to, if retained, not execute the steps of creating the isolation environment and installing the dependent package in the isolation environment when the preset first configuration file is called again, and execute the step of caching the intermediate data.

[0131] In a possible implementation manner of the present application, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the apparatus further includes:

[0132] A second acquisition module is used to obtain a second source code package to be compiled;

[0133] a fourth determining module, configured to determine, in the retained isolation environment in which the dependent package is installed, a target single binary package in the second source code that does not need to be compiled based on preset build parameters in the called preset second configuration file;

[0134] a second compiling module, configured to call a compiling tool and compile, by means of the compiling tool, a single binary package other than the target single binary package in the second source code package to obtain a target binary package of the second source code package;

[0135] The second packaging module is used to call a packaging tool to package the target binary package of the second source code package into a Linux software package through the packaging tool.

[0136] In a possible implementation manner of the present application, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the apparatus further includes:

[0137] A third acquisition module is used to obtain a third source code package to be compiled;

[0138] A third compilation module is configured to call a compilation tool in a preset container, compile the third source code package using the compilation tool, and obtain a target binary package of the third source code package, wherein the preset container is generated by cleaning up non-essential files in the isolated environment according to a preset cleaning method after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, compressing the cleaned isolated environment into a container image, and importing the container image into a container engine;

[0139] The third packaging module is used to call a packaging tool to package the target binary package of the third source code package into a Linux software package through the packaging tool.

[0140] In a possible implementation of the present application, before the step of compiling the third source code package using the compilation tool to obtain a target binary package of the third source code package, the apparatus further includes:

[0141] The fifth determination module is used to determine the resource quota of the container during operation based on the called preset third configuration file, wherein the resource quota includes at least the memory usage and CPU resource usage of the container during operation.

[0142] In a possible implementation manner of the present application, the preset construction parameters are custom parameters in the preset first configuration file, or macro definition switches built into the compilation tool.

[0143] In a possible implementation manner of the present application, after the step of packaging the target binary package of the first source code package into a Linux software package using the packaging tool, the apparatus further includes:

[0144] A maintaining module is used to maintain the mounting state of the isolated environment based on the preset first configuration file.

[0145] The specific implementation of the source code package construction and packaging device of the present application is basically the same as the various embodiments of the source code package construction and packaging method described above, and will not be repeated here.

[0146] The present application also provides a storage medium, on which a source code package construction and packaging program is stored. When the source code package construction and packaging program is executed by a processor, the steps of the source code package construction and packaging method as described in any one of the above items are implemented.

[0147] The specific implementation of the storage medium of this application is basically the same as the various embodiments of the above-mentioned source code package construction and packaging method, and will not be repeated here.

[0148] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.

[0149] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0150] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0151] The above are merely optional embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A source code package construction and packaging method, wherein: The source code package construction and packaging method comprises the following steps: Get the first source code package to be compiled; Based on the dependency packages required for compilation installed in the isolation environment, calling a compilation tool, compiling the first source code package through the compilation tool, and obtaining a target binary package of the first source code package, wherein the isolation environment is pre-created based on a preset first configuration file and mounted into the memory of the Linux system; A packaging tool is called to package the target binary package of the first source code package into a Linux software package through the packaging tool.

2. The source code package construction and packaging method according to claim 1, wherein: The target binary includes a plurality of single binary packages. Before the step of compiling the first source code package by the compilation tool to obtain a target binary package of the first source code package, the method further includes: Based on the preset construction parameters in the preset first configuration file, a target single binary package that does not need to be compiled in the first source code package is determined, so that the compilation tool does not compile the target single binary package that does not need to be compiled.

3. The source code package construction and packaging method according to claim 2, wherein: After the step of compiling the first source code package by the compilation tool to obtain a target binary package of the first source code package, the method further includes: Based on the preset first configuration file, determine to cache the intermediate data generated by the compilation tool in the process of compiling the first source code package, so that when the compilation tool compiles the same source code file again, it can compile based on the intermediate data corresponding to the same source code file.

4. The source code package construction and packaging method according to claim 3, wherein: After the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, the method further includes: Based on the preset mock parameters in the preset first configuration file, determining whether to retain the isolation environment, the dependent package, and the intermediate data cache setting; If retained, when the preset first configuration file is called again, the steps of creating the isolation environment and installing the dependent package in the isolation environment are not performed, and the step of caching the intermediate data is performed.

5. The source code package construction and packaging method according to claim 4, wherein: After the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, the method further includes: Get the second source code package to be compiled; In the reserved isolation environment in which the dependent package is installed, based on the preset construction parameters in the called preset second configuration file, determining a target single binary package that does not need to be compiled in the second source code; Invoking a compilation tool, and using the compilation tool to compile a single binary package other than a target single binary package in the second source code package to obtain a target binary package of the second source code package; A packaging tool is called to package the target binary package of the second source code package into a Linux software package through the packaging tool.

6. The source code package construction and packaging method according to claim 4, wherein: After the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, the method further includes: Get the third source package to be compiled; Invoking a compilation tool in a preset container, and compiling the third source code package by using the compilation tool to obtain a target binary package of the third source code package; The preset container is generated by cleaning up unnecessary files in the isolated environment in a preset cleaning manner after the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, compressing the cleaned isolated environment into a container image, and importing the container image into a container engine; A packaging tool is called, and the target binary package of the third source code package is packaged into a Linux software package by the packaging tool.

7. The source code package construction and packaging method according to claim 6, wherein: Before the step of compiling the third source code package by the compilation tool to obtain a target binary package of the third source code package, the method further includes: Based on the called preset third configuration file, a resource quota of the container when it is running is determined, wherein the resource quota at least includes the memory occupancy and CPU resource occupancy of the container during the running process.

8. The source code package construction and packaging method according to claim 2, wherein: The preset construction parameters are custom parameters in the preset first configuration file, or macro definition switches built into the compilation tool.

9. The source code package construction and packaging method according to claim 1, after the step of packaging the target binary package of the first source code package into a Linux software package by the packaging tool, the method further comprises: Based on the preset first configuration file, the mounting state of the isolation environment is maintained.

10. A source code package building and packaging device, wherein: The device comprises: a memory, a processor, and a source code package building and packaging program stored in the memory and executable on the processor, wherein the source code package building and packaging program is configured to implement the steps of the source code package building and packaging method according to any one of claims 1 to 9.

11. A storage medium, wherein: The storage medium stores a source code package construction and packaging program, and when the source code package construction and packaging program is executed by the processor, the steps of the source code package construction and packaging method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Linux software package manufacturing method capable of being used in various systems

    CN103440156A

  • Software source code compiling method and device

    CN106293861A

  • Construction method of isolated compiling environment and device thereof, equipment and storage medium

    CN114047925A

  • System and method for building software package for embedded system

    US20070011494A1

Cited By

  • On-line compiling and packaging method based on Buildroot

    CN119025157A

  • Software package construction method and device, computer equipment, readable storage medium and program product

    CN120335821A