RPM package generation method and device, electronic equipment and storage medium
By compiling and installing the target dependency package in the container, the low efficiency problem of the existing RPM package generation method is solved, and efficient and low-cost RPM package generation is achieved.
Patent Information
- Application Number
- CN202510628477.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-09-23
AI Technical Summary
The existing RPM package generation method is inefficient and requires processing the dependency issues of static libraries and dynamic libraries separately for each RPM package and system architecture, resulting in low generation efficiency and high cost.
By obtaining the target input, generating the target compilation file and starting the target container, compiling and installing the target dependency package in the container, and mapping the pre-configured compilation library file to the container, the target RPM package is generated.
It improves the success rate and efficiency of RPM package generation, reduces developers' time and energy consumption, and reduces the cost of generating RPM packages.
Smart Images

Figure CN120687095A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, and storage medium for generating an RPM package. Background Art
[0002] Each existing system mirror repository maintains its own set of RPM packages. However, mirror repositories that lack certain RPM packages require compilation to generate these missing RPM packages. These missing RPM packages often have dependent libraries, and the compilation process involves interoperability issues between static and dynamic libraries. To address these dependency issues, developers must restructure the compilation system, addressing static and dynamic library dependencies separately for each RPM package and system architecture. Consequently, existing RPM package generation methods suffer from inefficiencies. Summary of the Invention
[0003] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a method, device, electronic device and storage medium for generating an RPM package, which can improve the efficiency of generating an RPM package.
[0004] In a first aspect, the present application provides a method for generating an RPM package, the method comprising:
[0005] Obtain target input; the target input carries the first identification information of the target dependency package required to compile the target source code package, the second identification information of the target container, and the name information of the target RPM package;
[0006] Generate a target compiled file based on the name information, start the target container based on the second identification information, and map the pre-configured compiled library file to the target container;
[0007] Based on the first identification information, compile and install the target dependency package in the target container, and write the target source code package into the target compiled file;
[0008] The target compilation file is compiled based on the target container to generate the target RPM package.
[0009] According to the RPM package generation method of the present application, by obtaining the target input, generating the target compilation file based on the target input and starting the target container, compiling and installing the target dependency package in the target container, compiling the target compilation file based on the target container, and generating the target RPM package, it can efficiently handle the dependencies in the process of compiling and generating RPM packages under various system architectures, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0010] According to one embodiment of the present application, the pre-configured compilation library file includes: a package management library, a list library and a tool library; the package management library is used to store the target source code package; the list library is used to store the target list file; the identification information of the target list file is carried by the target input; the target list file is used to store the first identification information; the tool library is used to store the target source code package.
[0011] According to one embodiment of the present application, compiling and installing the target dependency package in the target container based on the first identification information includes:
[0012] Based on the first identification information, the target dependent package is obtained from the package management library, and the target dependent package is compiled and installed in the target container.
[0013] According to one embodiment of the present application, obtaining the target dependent package from the package management library based on the first identification information includes:
[0014] determining, based on identification information of the target list file, whether the target list file exists in the list library;
[0015] When the target list file exists in the list library, the target dependent package is obtained from the package management library based on the target list file; and when the target list file does not exist in the list library, all packages in the package management library are obtained.
[0016] According to an embodiment of the present application, there are multiple target containers; each target container corresponds to a usage environment of the target RPM package.
[0017] According to one embodiment of the present application, compiling the target compilation file based on the target container to generate the target RPM package includes:
[0018] The target RPM package is copied to the mapping path of the target container, so that the local path having a mapping relationship with the mapping path synchronously obtains the target RPM package.
[0019] In a second aspect, the present application provides an RPM package generation device, the device comprising:
[0020] An input module is configured to obtain a target input, wherein the target input carries the first identification information of the target dependency package required for compiling the target source code package, the second identification information of the target container, and the name information of the target RPM package;
[0021] a startup module, configured to generate a target compilation file based on the name information, start the target container based on the second identification information, and map a pre-configured compilation library file to the target container;
[0022] An installation module, configured to compile and install the target dependency package in the target container based on the first identification information, and write the target source code package into the target compiled file;
[0023] A compilation module is used to compile the target compilation file based on the target container to generate the target RPM package.
[0024] According to the RPM package generation device of the present application, by obtaining the target input, generating the target compilation file based on the target input and starting the target container, compiling and installing the target dependency package in the target container, compiling the target compilation file based on the target container, and generating the target RPM package, it can efficiently handle the dependencies in the process of compiling and generating RPM packages under various system architectures, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0025] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the RPM package generation method as described in the first aspect above is implemented.
[0026] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the RPM package generation method as described in the first aspect above.
[0027] In a fifth aspect, the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the RPM package generation method as described in the first aspect.
[0028] In a sixth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the RPM package generation method as described in the first aspect above.
[0029] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0031] Figure 1 This is one of the flow charts of the RPM package generation method provided in the embodiment of the present application;
[0032] Figure 2 This is the second flow chart of the RPM package generation method provided in the embodiment of the present application;
[0033] Figure 3 Schematic diagram of the structure of the RPM package generation device provided in an embodiment of the present application;
[0034] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described 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 are within the scope of protection of this application.
[0036] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0037] In the related art, the method of generating an RPM package by compiling also needs to solve the path problem of the dependent environment. On the one hand, when the local environment is different from the use environment of the RPM package (for example, the local environment is an X86 architecture and the RPM package that needs to be compiled is obtained for an ARM64 architecture, etc.), it is necessary to use a cross-compilation tool chain to compile. In the case where the toolkit that needs to be compiled has a dependent library, it is necessary to compile the dependent packages included in the above-mentioned dependent library one by one and install the dynamic library and static library generated based on the above-mentioned dependent package to the specified location, and even need to modify the Makefile file of the toolkit to add the path of the above-mentioned static library and dynamic library. On the other hand, the aforementioned path problem often involves local permissions, and it is easy to cause compilation failure due to lack of permissions.
[0038] The RPM package generation method, RPM package generation device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0039] The RPM package generation method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.
[0040] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet computer having a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that, in some embodiments, the terminal may not be a portable communication device, but a desktop computer having a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).
[0041] In the following embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse, and a joystick.
[0042] The RPM package generation method provided in the embodiment of the present application can be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the RPM package generation method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablets, computers, cameras and wearable devices, etc. The RPM package generation method provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.
[0043] like Figure 1 As shown, the RPM package generation method includes: step 110, step 120, step 130 and step 140.
[0044] Step 110: Obtain target input; the target input carries the first identification information of the target dependency package required to compile the target source code package, the second identification information of the target container, and the name information of the target RPM package.
[0045] In actual implementation, the target input may be input by a user through at least one of input devices such as a keyboard, a mouse, and a touch-sensitive surface. The specific form of the target input is not limited in the embodiment of the present application.
[0046] In some embodiments, the target input may include three types of parameters: first identification information, second identification information, and name information. Based on the first identification information, second identification information, and name information, the target source code package can be compiled using the target container based on the target dependency packages required to compile the target source code package, thereby generating a target RPM package. The target RPM package can be applied to the image source of the system corresponding to the target container.
[0047] In some embodiments, the first identification information may include information such as the identification of each target dependency package. It is understandable that the number of target dependency packages required to compile the target source code package may be one or more. In some embodiments, for each target dependency package, the identification of the target dependency package may include the name of the target dependency package (generally the package name), etc. The identification of the target dependency package can be used to indicate the identity of the target dependency package, so that it can be determined which package each target dependency package is.
[0048] In some embodiments, the second identification information may include information such as the identification of each target container. In some embodiments, the number of target containers may be one or more. In some embodiments, for each target container, the identification of the target container may include, for example, the image name of the target container. The identification of the target container may be used to indicate the identity of the target container, thereby determining the specific container of each target container.
[0049] It should be noted that multiple containers can be pre-set. The above multiple containers can respectively correspond to a usage environment (including architecture and operating system, etc.). For example, the above multiple containers can respectively correspond to the X86 architecture, various ARM architectures (such as ARM64) or AArch64, etc. The target container can adopt one or more of the above multiple containers. In some embodiments, the above container can adopt a Docker container, a CoreOS rkt container or a Mesos container, etc.
[0050] In some embodiments, the name information of the target RPM package may generally include the name of the target RPM package (generally the package name) and the like.
[0051] Step 120: Generate a target compilation file based on the name information, start a target container based on the second identification information, and map the pre-configured compilation library file to the target container.
[0052] In actual execution, a target compiled file with the same name as the target RPM package can be generated based on the name information of the target RPM package. For example, if the name information of the target RPM package carried by the target input is the package name NAME of the target RPM package, a target compiled file named NAME can be generated.
[0053] The embodiment of the present application does not limit the format of the target compiled file. In some embodiments, the target compiled file can adopt a format such as spec. For example, the target compiled file can be a file named NAME.spec. Wherein, ".spec" is the file name suffix of the target compiled file.
[0054] In actual execution, based on the second identification information, a container matching the second identification information among the plurality of pre-set containers may be determined as a target container. After the target container is determined, the target container may be started.
[0055] In actual execution, for each target container, the pre-configured compiled library file can be mapped to the target container, so that the target container can read and write the pre-configured compiled library file. The pre-configured compiled library file can be used to compile the target source code package.
[0056] Step 130: Based on the first identification information, compile and install the target dependency package in the target container, and write the target source code package into a target compiled file.
[0057] In actual execution, based on the first identification information, it is possible to determine which packages are target dependency packages required to compile the target source code package. After determining the target dependency packages, the target dependency packages can be compiled and installed in each target container respectively.
[0058] In actual execution, the target source code package is also written into the target compilation file. It should be noted that the target compilation file generated in step 120 can be a blank file. After the target source code package is written into the target compilation file, the target source code package can be compiled because the target compilation file stores the source code in the target source code package.
[0059] Step 140: Compile the target compilation file based on the target container to generate a target RPM package.
[0060] In actual execution, for each target container, the target compilation file can be compiled in the target container. During the compilation process, the target dependency packages installed in the target container can be used, so that the target source code package can be successfully compiled and the target RPM package can be generated.
[0061] It should be noted that the embodiment of the present application provides a distributed RPM package compilation framework based on a container. The user only needs to provide a source code package (as a target source code package), the source code package that the source code package depends on (as a target dependency package), and a locally deployed container image (used to determine the target container) to generate the RPM package corresponding to the target source code package with one click. By compiling and generating RPM packages based on containers, the path problem of the dependency environment that needs to be solved for local compilation can be avoided, and the introduction of a cross-compilation tool chain and the path problem of the dynamic library and static library of the dependency package can also be avoided. It can be understood that when compiling based on containers, even if the local environment is different from the use environment of the RPM package, there is no need to use a cross-compilation tool chain, and therefore there is no problem of the dynamic library and static library path of the dependency package caused by the use of a cross-compilation tool chain. In addition, the target dependency package is compiled and installed in the container, and the container has the permission to use the target dependency package, thereby avoiding the problem of compilation failure due to the lack of permission to use certain target dependency packages locally.
[0062] According to the RPM package generation method provided in the embodiment of the present application, by obtaining the target input, generating the target compilation file based on the target input and starting the target container, compiling and installing the target dependency package in the target container, compiling the target compilation file based on the target container, and generating the target RPM package, the method can efficiently handle the dependencies in the process of compiling and generating RPM packages under various system architectures, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0063] In some embodiments of the present application, the pre-configured compilation library file includes: establishing a package management library, a list library and a tool library; the package management library is used to store the target source code package; the list library is used to store the target list file; the identification information of the target list file is carried by the target input; the target list file is used to store the first identification information; the tool library is used to store the target source code package.
[0064] In actual implementation, libraries such as a package management library, a list library, and a tool library can be established through pre-configuration or other means to achieve the successful generation of RPM packages. Among them, the package management library can be used to store various dependent packages. The above-mentioned dependent packages can include all target dependent packages required to compile the target source code package. The list library can be used to store various list files. Each list file can be used to store identification information of multiple dependent packages. The above-mentioned list files can include a target list file. The target list file can store the first identification information of the target dependent package required to compile the target source code package. The tool library can be used to store various source code packages used to generate RPM packages. The above-mentioned source code packages can include the target source code package.
[0065] It should be noted that the specific method of establishing a package management library, a list library, a tool library, etc. through pre-configuration or the like is not limited in the embodiments of the present application. For example, pre-configuration may be performed in response to user input to establish a package management library, a list library, a tool library, etc.
[0066] In some embodiments, the target input carries the first identification information of the target dependency package required for compiling the target source code package in a manner of carrying the identification information of the target list file.
[0067] According to the RPM package generation method provided in the embodiment of the present application, by mapping the package management library, list library and tool library to the target container, the target container has the authority to access and operate the packages and other files stored in the package management library, list library and tool library, and can operate the packages and other files stored in the package management library, list library and tool library, which can avoid the problem of compilation failure caused by lack of authority in related technologies, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0068] In some embodiments of the present application, compiling and installing a target dependency package in a target container based on the first identification information includes: obtaining the target dependency package from a package management library based on the first identification information, and compiling and installing the target dependency package in the target container.
[0069] In actual execution, the target list file can be determined based on the identification information of the target list file carried by the target input; after determining the target list file, the first identification information of the target dependency package required for compiling the target source code package can be obtained by reading the content of the target list file; after obtaining the first identification information of the target dependency package required for compiling the target source code package, each dependency package in the package management library that matches the first identification information can be determined as the target dependency package; after determining the target dependency package, all target dependency packages can be compiled and installed in each target container respectively.
[0070] According to the RPM package generation method provided in the embodiment of the present application, the target container accesses and operates the packages and other files stored in the package management library, list library and tool library, and operates the packages and other files stored in the package management library, list library and tool library to obtain the target dependent package and compile and install the target dependent package in the target container. This can avoid the problem of compilation failure caused by lack of permissions in related technologies, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0071] In some embodiments of the present application, obtaining a target dependent package from a package management library based on a target input includes: determining whether a target list file exists in the list library based on identification information of the target list file.
[0072] In actual execution, a match may be performed in the list library based on the identification information of the target list file carried in the target input to determine whether the target list file exists in the list library.
[0073] In some embodiments, if the identification information of any file in the list library is the same as the identification information of the target list file, it can be determined that the target list file exists in the list library and that the file is the target list file. If the identification information of each file in the list library is different from the identification information of the target list file, it can be determined that the target list file does not exist in the list library.
[0074] It should be noted that, in the case where the target input does not contain the identification information of the target list file (for example, the user has not entered the identification information of the target list file), it can be regarded that the identification information of the target list file carried by the target input is empty. Therefore, the identification information of each file in the list library is different from the identification information of the above-mentioned target list file, and it is regarded that the target list file does not exist in the list library.
[0075] If the target list file exists in the list library, the target dependent package is obtained from the package management library based on the target list file. If the target list file does not exist in the list library, all packages in the package management library are obtained.
[0076] In actual execution, when there is a target list file in the list library, the target list file can be determined; after determining the target list file, the first identification information of the target dependency package required for compiling the target source code package can be obtained by reading the content of the target list file; after obtaining the first identification information of the target dependency package required for compiling the target source code package, each dependency package in the package management library that matches the first identification information can be determined as the target dependency package; after determining the target dependency package, each target container can obtain the target dependency package from the package management library based on the above-mentioned mapping.
[0077] In actual execution, if the target list file exists in the list library, all dependent packages in the package management library can be obtained. That is, all packages in the package management library are used as dependent packages required to compile the target source code package. It should be noted that since the package management library stores all table dependency packages, the target dependent package can be obtained by obtaining all packages in the package management library.
[0078] According to the RPM package generation method provided by the embodiment of the present application, when there is a target list file in the list library, the target dependency package is obtained from the package management library based on the target list file, and when there is no target list file in the list library, all packages in the package management library are obtained to obtain the target dependency package, so that the target dependency package can be compiled and installed in the target container, so that the above-mentioned target dependency package can be successfully used in the process of compiling and generating the target RPM package, thereby improving the success rate and efficiency of generating the RPM package, greatly reducing the time and energy consumption of developers, reducing the cost of generating the RPM package, and thus reducing the R&D cost of the system.
[0079] In some embodiments of the present application, there are multiple target containers; each target container corresponds to a usage environment of the target RPM package.
[0080] In actual execution, there may be multiple target containers, and each target container corresponds to a usage environment of the target RPM package. In some embodiments, the usage environments corresponding to any two target containers may be different.
[0081] According to the RPM package generation method provided in the embodiment of the present application, by specifying multiple target containers in the target input, compilation can be performed simultaneously through different target containers to generate different target RPM packages, thereby realizing distributed compilation to generate RPM packages. This can greatly reduce the developer's time and energy consumption, reduce the cost of generating RPM packages, and thus reduce the system's R&D costs.
[0082] In some embodiments of the present application, compiling a target compilation file based on a target container to generate a target RPM package includes: copying the target RPM package to a mapping path of the target container so that a local path having a mapping relationship with the mapping path synchronously obtains the target RPM package.
[0083] In actual execution, after the target RPM package is generated, the target RPM package can be copied to the mapping path of the target container, and the local path can synchronously obtain the above target RPM package based on the mapping relationship between the local path and the mapping path.
[0084] According to the RPM package generation method provided in the embodiment of the present application, by copying the target RPM package to the mapping path of the target container, the local path having a mapping relationship with the mapping path synchronously obtains the target RPM package, thereby achieving local efficient and accurate acquisition of the target RPM package.
[0085] In order to facilitate the understanding of the above embodiments of the present application, Figure 2 , the implementation process of the RPM package generation method provided in the embodiment of the present application is explained.
[0086] The implementation of the RPM package generation method provided in the embodiment of the present application may mainly involve the following parts: a package management library, a list library, a tool library, and a compilation device. The compilation device may be the RPM package generation device as the execution subject of the RPM package generation method.
[0087] The package management library can be used to store dependent source code packages. The above-mentioned dependent source code packages are called dependent packages.
[0088] The tool library can be used to store the source code of the compilation package. The source code of the compilation package can be the target source code package.
[0089] The list library can be used to store list files. Users can add the name of the dependent package (i.e. package name) in the list file as needed.
[0090] The compilation device can read the target source code package for compilation. The compilation device can select the target list file in the list file according to the parameters input by the user to compile the target source code package. If the target list file is not selected, the compilation device can read all dependent packages under the package management library by default and generate a default list file. The file name of the default list file can be default.list. The file name of the target list file can be named according to the package name of the target source code package. For example, if the package name of the target source code package is xxx, the file name of the target list file can be xxx.list.
[0091] Users can enter three types of parameters through target input: the first type of parameter (the aforementioned first identification information) can be the file name xxx.list of the target list file; the second parameter (the aforementioned second identification information) can be the image name of the Docker container (taking the target container as a Docker container as an example); the third type of parameter (the aforementioned name information) can be the file name of the target RPM package, such as NAME.
[0092] The compilation device can select the xxx.list file from the list library according to the first type of parameters, and search the package management library for all dependent packages according to the target list file in the target container, compile and install them into the target container.
[0093] The compilation device can also select the local Docker container image as the target container according to the second type of parameters, start the target container and map the local package management library, list library and tool library to the target container, and complete the compilation of the RPM package in the target container (referring to obtaining the target RPM package through compilation).
[0094] The compilation device can also select the RPM package to be produced from the tool library according to the third parameter NAME, generate a NAME.spec file as a target compilation file, and compile the target compilation file through the rpmbuild tool of the Docker container to generate a target RPM package.
[0095] refer to Figure 2 The specific process of the RPM package generation method provided in the embodiment of the present application is as follows.
[0096] Preparation stage: The user provides the target source code package to generate the target RPM package and puts it into the tool library. According to the source code packages that the target source code package depends on (that is, the target dependent packages), a target list file is maintained in the list library, and the target dependent packages are put into the package management library.
[0097] Implementation phase:
[0098] Step 210: Input xxx.list, the image name of the Docker container, and the package name of the target RPM package.
[0099] The user can input the above three types of parameters and pass them to the compilation device in the form of target input. The package name of the target RPM package can be NAME.
[0100] Step 220: Generate a NAME.spec file according to NAME.
[0101] The NAME.spec file is the target compilation file. Its suffix ".spec" is determined by the compilation tool used by the target container (for example, rpmbuild in a Docker container).
[0102] Step 230: Start the target container according to the image name of the Docker container and map the package management library, list library, and tool library to the target container.
[0103] Step 240: Determine whether there is a target list file.
[0104] If yes, execute step 250 ; if no, execute step 260 .
[0105] Step 250: In the target container, select a target list file from the list library according to xxx.list, search for the target dependency package in the package management library according to the target list file, compile and install it into the target container.
[0106] Step 260: Compile and install all packages in the package management library.
[0107] The purpose of steps 240 to 260 is to install each target dependency package one by one in the target container according to the list file.
[0108] Step 270: Use the rpmbuild tool in the target container to compile and generate a target RPM package according to the NAME.spec file.
[0109] Step 280: Copy the generated target RPM package to the mapping path in the target container, and the local path can obtain the target RPM package.
[0110] In order to facilitate the understanding of the above-mentioned embodiments of the present application, the implementation process of the RPM package generation method provided in the embodiments of the present application is described below through an example.
[0111] For a test tool XXXXX (XXXXX is an example) that tests real-time performance, there is currently no RPM package corresponding to the test tool XXXXX in the Euler system's mirror source, that is, there is no RPM package named XXXXX.rpm. In addition, the Euler system's mirror source also does not have the target compilation package that the compilation test tool XXXXX depends on (taking one of the target compilation packages named numactl.rpm as an example). Therefore, in order to use the test tool XXXXX, it is necessary to maintain a set of RPM package mirror sources, and in order to maintain the RPM package mirror source, it is necessary to generate a target RPM package named XXXXX.rpm. The following process can be a one-click generation process for an RPM package.
[0112] Users can pre-provide the source code package for writing the test tool XXXXX (as the target source code package), the source code packages that the target source code package depends on (i.e., the target compilation package, including numactl.rpm, etc.), the image of the local Docker container, and the maintained target list file (file name can be XXXXX.list). The target list file may include the package names of the source code packages that the test tool XXXXX, such as numactl, depends on. The target list file can be placed in the list library. The target compilation package can be placed in the package management library. The target source code package can be placed in the library tool library.
[0113] The user can send three parameters, namely, XXXXX.list, the image name of the local Docker container (i.e., the name of the image of the local Docker container, which serves as the second identification information), and NAME XXXXX, to the aforementioned compilation device through target input. The compilation device can generate a target compilation file named XXXXX.spec based on XXXXX.
[0114] The compilation device also selects a XXXXX.list file from a list library based on the XXXXX.list parameter. Based on the image name of the local Docker container, it starts a Docker container as the target container. Within this Docker container, it compiles the target dependency packages from the installation package management library based on the XXXXX.list file. Within this Docker container, the rpmbuild tool generates a target RPM package named XXXXX.rpm based on the XXXXX.spec file.
[0115] Copy the generated target RPM package named XXXXX.rpm to the mapped path, and the target RPM package named XXXXX.rpm can be obtained in the local path.
[0116] The RPM package generation method provided in the embodiment of the present application can be executed by an RPM package generation device. In the embodiment of the present application, the RPM package generation device executing the RPM package generation method is taken as an example to illustrate the RPM package generation device provided in the embodiment of the present application.
[0117] The present application also provides an RPM package generation device. Figure 3 As shown, the RPM package generating device includes: an input module 310 , a startup module 320 , an installation module 330 and a compilation module 340 .
[0118] Input module 310, used to obtain target input; the target input carries the first identification information of the target dependency package required to compile the target source code package, the second identification information of the target container, and the name information of the target RPM package;
[0119] A startup module 320 is configured to generate a target compilation file based on the name information, start a target container based on the second identification information, and map a pre-configured compilation library file to the target container;
[0120] An installation module 330 is configured to compile and install a target dependency package in a target container based on the first identification information, and write the target source code package into a target compiled file;
[0121] The compilation module 340 is used to compile the target compilation file based on the target container to generate a target RPM package.
[0122] According to the RPM package generation device provided in the embodiment of the present application, by obtaining target input, generating a target compilation file based on the target input and starting a target container, compiling and installing the target dependency package in the target container, compiling the target compilation file based on the target container, and generating a target RPM package, it can efficiently handle the dependencies in the process of compiling and generating RPM packages under various system architectures, improve the success rate and efficiency of generating RPM packages, greatly reduce the time and energy consumption of developers, reduce the cost of generating RPM packages, and thus reduce the R&D cost of the system.
[0123] In some embodiments, the pre-configured compilation library files include: a package management library, a list library and a tool library; the package management library is used to store the target source code package; the list library is used to store the target list file; the identification information of the target list file is carried by the target input; the target list file is used to store the first identification information; the tool library is used to store the target source code package.
[0124] In some embodiments, the installation module 330 may include:
[0125] The installation unit is configured to obtain a target dependent package from a package management library based on the first identification information, and compile and install the target dependent package in a target container.
[0126] In some embodiments, the installation unit may include:
[0127] a determination subunit, configured to determine whether a target list file exists in a list library based on identification information of the target list file;
[0128] The acquisition subunit is used to obtain the target dependent package from the package management library based on the target list file when the target list file exists in the list library.
[0129] In some embodiments, the acquisition subunit may also be used to acquire all packages in the package management library when the target list file does not exist in the list library.
[0130] In some embodiments, there are multiple target containers; each target container corresponds to a usage environment of the target RPM package.
[0131] In some embodiments, the RPM package generating apparatus may further include:
[0132] The copy module is used to copy the target RPM package to the mapping path of the target container, so that the local path having a mapping relationship with the mapping path synchronously obtains the target RPM package.
[0133] The RPM package generation device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. It can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not specifically limit it.
[0134] The RPM package generation device in the embodiment of the present application can be a device having an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0135] The RPM package generation device provided in the embodiment of the present application can achieve Figures 1 to 2 To avoid repetition, the various processes implemented in the method embodiment are not described here.
[0136] In some embodiments, as Figure 4 As shown, an embodiment of the present application further provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. When the program is executed by the processor 401, each process of the above-mentioned RPM package generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0137] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0138] An embodiment of the present application also provides a non-transitory computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the various processes of the above-mentioned RPM package generation method embodiment are implemented and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0139] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0140] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned RPM package generation method when executed by a processor.
[0141] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0142] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned RPM package generation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0143] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0144] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0145] 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 is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0146] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
[0147] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0148] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and intent of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A method for generating an RPM package, characterized in that: include: Obtain target input; the target input carries the first identification information of the target dependency package required to compile the target source code package, the second identification information of the target container, and the name information of the target RPM package; Generate a target compiled file based on the name information, start the target container based on the second identification information, and map the pre-configured compiled library file to the target container; Based on the first identification information, compile and install the target dependency package in the target container, and write the target source code package into the target compiled file; The target compilation file is compiled based on the target container to generate the target RPM package.
2. The RPM package generation method according to claim 1, characterized in that: The pre-configured compilation library file includes: a package management library, a list library and a tool library; the package management library is used to store the target source code package; the list library is used to store the target list file; the identification information of the target list file is carried by the target input; the target list file is used to store the first identification information; the tool library is used to store the target source code package.
3. The RPM package generation method according to claim 2, characterized in that: The compiling and installing the target dependency package in the target container based on the first identification information includes: Based on the first identification information, the target dependent package is obtained from the package management library, and the target dependent package is compiled and installed in the target container.
4. The RPM package generation method according to claim 3, wherein: The acquiring the target dependent package from the package management library based on the first identification information includes: determining, based on identification information of the target list file, whether the target list file exists in the list library; When the target list file exists in the list library, the target dependent package is obtained from the package management library based on the target list file; and when the target list file does not exist in the list library, all packages in the package management library are obtained.
5. The RPM package generation method according to claim 1, characterized in that: There are multiple target containers; each target container corresponds to a usage environment of the target RPM package.
6. The RPM package generation method according to any one of claims 1 to 5, characterized in that: Compiling the target compiled file based on the target container to generate the target RPM package includes: The target RPM package is copied to the mapping path of the target container, so that the local path having a mapping relationship with the mapping path synchronously obtains the target RPM package.
7. An RPM package generating device, characterized in that: include: An input module is configured to obtain a target input, wherein the target input carries the first identification information of the target dependency package required for compiling the target source code package, the second identification information of the target container, and the name information of the target RPM package; a startup module, configured to generate a target compilation file based on the name information, start the target container based on the second identification information, and map a pre-configured compilation library file to the target container; An installation module, configured to compile and install the target dependency package in the target container based on the first identification information, and write the target source code package into the target compiled file; A compilation module is used to compile the target compilation file based on the target container to generate the target RPM package.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the RPM package generation method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the RPM package generation method according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the RPM package generation method according to any one of claims 1 to 6 is implemented.