Source code packet compiling method and device, electronic equipment and readable storage medium
By managing the source code package sequence and recursively enumerating dependencies, the problem of dependencies failing to function properly during cross-system migration is solved, enabling automated compilation and efficient deployment of source code packages in the target system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHONGKE FANGDE SOFTWARE CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, computer programs migrated across systems suffer from low deployment and operation efficiency due to dependencies failing to function properly on the target system, and package management tools struggle to handle dependency version incompatibility issues.
By arranging the source packages into a sequence, the target source package is first obtained from the first storage source, and the dependencies are obtained from the second storage source in turn. If a dependency is missing, it is added as a source package to the beginning of the sequence. This process is repeated until all source packages are compiled. The dependencies are enumerated using a recursive function to ensure that all dependencies can be compiled on the target system.
It enables automated construction of source code packages across systems, ensuring that each source code package is successfully compiled on the target system, and improving the automation level and accuracy of the dependency compilation process.
Smart Images

Figure CN121918833A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and computer-readable storage medium for compiling source code packages. Background Technology
[0002] Computer programs use pre-written software packages to implement specific functions. These software packages are called dependencies, and dependencies need to be compiled into binary files to run.
[0003] In related technologies, package management tools retrieve pre-compiled dependencies from a specified package storage source, i.e., obtain the binary files corresponding to the dependencies, thereby ensuring that computer programs can run smoothly.
[0004] However, for the same computer program, there is a need to run it across systems, and some pre-compiled dependencies may not function properly on the target system being migrated. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and computer-readable storage medium for compiling source code packages to solve the problems in the prior art.
[0006] In a first aspect, embodiments of this application provide a method for compiling a source code package, the method comprising: Based on the read operation of the target source package located at the head of the source package sequence, the target source package is obtained from the first storage source, and all dependencies of the target source package are obtained from the second storage source; If the second storage source stores all the dependencies of the target source package, the target source package is compiled according to the dependencies, and the current target source package is removed from the source package sequence. If at least one target dependency is missing from the second storage source, the missing target dependency is treated as a source package and added to the head of the source package sequence. Re-enter the step of reading the target source package at the head of the source package sequence until all source packages in the source package sequence have been compiled.
[0007] Secondly, embodiments of this application provide a source code package compilation apparatus, the apparatus comprising: Acquisition module: used to acquire the target source package from the first storage source based on the read operation of the target source package located at the head of the queue in the source package sequence, and to acquire all the dependencies of the target source package from the second storage source; The removal module is used to compile the target source package according to the dependencies when the second storage source stores all the dependencies of the target source package, and remove the current target source package from the source package sequence; Add module: used to add the missing target dependency as a source package and add it to the head of the source package sequence when at least one target dependency is missing in the second storage source; Loop module: Used to re-enter the step of reading the target source package at the head of the queue in the source package sequence until all source packages in the source package sequence have been compiled.
[0008] Thirdly, embodiments of this application also provide an electronic device, including a processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method of the first aspect.
[0009] Fourthly, embodiments of this application also provide a computer-readable storage medium that, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method of the first aspect.
[0010] In this embodiment, the source code packages to be compiled are arranged into a source code package sequence. After reading the target source code package at the head of the source code package sequence, the source code of the target source code package is obtained from a first storage source, and then all dependencies of the target source code package are obtained from a second storage source. If all dependencies can be obtained from the second storage source, the compilation of the target source code package can be completed based on these dependencies; if the target dependency is missing from the second storage source, the target dependency is added to the head of the source code package sequence as a target source code package to be read, and the target dependency is parsed; the above operations are repeated until all source code packages in the source code package sequence are compiled. The method provided by this embodiment can ensure that all dependencies of the target source code package can be obtained, thereby realizing the automated construction of the target source code package and all its dependencies, ensuring that each source code package in the source code package sequence can be compiled successfully, and improving the automation level and accuracy of the compilation process of computer program dependencies.
[0011] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating the steps of a source code package compilation method provided in an embodiment of this application; Figure 2 This is a flowchart of another method for compiling a source code package provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the steps of another source code package compilation method provided in this application embodiment; Figure 4 This is a block diagram of a source code package compilation apparatus provided in an embodiment of this application; Figure 5 This is a block diagram of an apparatus according to this application; Figure 6 This is a schematic diagram of the server structure in some embodiments of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0015] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and are not limited in number; for example, a first object can be one or more. Furthermore, the term "and / or" in the specification and claims is used to describe the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. In the embodiments of this application, the term "multiple" refers to two or more, and other quantifiers are similar.
[0016] Figure 1This is a flowchart illustrating the steps of a source code package compilation method provided in an embodiment of this application, as follows: Figure 1 As shown, the method may include: Step 101: Based on the read operation of the target source package located at the head of the source package sequence, obtain the target source package from the first storage source and obtain all the dependencies of the target source package from the second storage source.
[0017] A dependency is pre-written additional code used to implement specific functionalities; this additional code is also called a package. For a program project with dependencies, the complete set of dependencies is required for the computer program to function correctly. A dependency may have its own dependencies. In dependency management, dependencies directly used by a program project are called direct dependencies, and dependencies of those dependencies are called indirect dependencies. Package management tools are used to automate the handling of dependencies. Different systems or different programming languages use different package management tools, such as yum (Yellow dog Updater, Modified) for CentOS; dnf (Dandified YUM) for Fedora and RHEL; apt (Advanced Packaging Tool) for Debian and Ubuntu; npm (Node Package Manager) for Node.js; and Maven for Java. These tools can retrieve and install dependencies from specified storage sources.
[0018] For cross-system application projects—that is, projects written on the initial system and migrated to the target system—package management tools have limitations. Since dependencies need to be compiled into binary files before execution, package management tools typically obtain pre-compiled dependencies directly—i.e., directly obtain the binary files. However, in cross-system scenarios, these binary files, compiled on the initial system, may not run successfully on the target system. Furthermore, package management tools cannot automatically complete missing dependencies from a specified storage source; when different versions of the same dependency exist, dependency incompatibility issues can easily arise, causing the application project to malfunction. Package management tools in related technologies struggle to effectively handle this problem. In short, directly using package management tools in related technologies slows down the cross-system deployment and execution process of application projects, hindering the integration efficiency and quality of the projects.
[0019] To address the aforementioned issues, this application provides a method for compiling source code packages. When a program project requires the compilation and installation of a series of source code packages, it can automatically obtain, compile, and install the given source code packages, ensuring the successful compilation and installation of all source code packages and guaranteeing that these source code packages can run smoothly on the current system.
[0020] First, users can provide a sequence of source packages as needed, representing all the source packages that need to be compiled and installed. It's understandable that these source packages can be dependencies of one or more program projects. In cross-system scenarios, to address the issue of directly obtaining pre-compiled binary files not running correctly, the source code of the dependencies (included in the source packages) can be obtained. This source code can then be compiled on the target system before installation, ensuring that these dependencies can be compiled into binary files that run successfully on the target system. The source package sequence can be structured as a table, where each item (each row) represents a source package. This item can record the relationship between the source package name, its sequence number, and its storage address (the first storage source, which is not mandatory).
[0021] By parsing the source package sequence, the target source package at the head of the sequence can be obtained. Based on the name of the target source package, it can be retrieved from the preset storage address (first storage source). Each source package contains its dependencies, specifying which items it depends on and their individual dependencies. Therefore, after obtaining the target source package, all its dependencies can be determined based on the dependencies. Once these dependencies are identified, pre-compiled dependencies can be retrieved from another storage address (second storage source) to improve the overall compilation efficiency. The difference between the first and second storage sources is that the source packages stored in the second storage source can be pre-compiled and adapted to the target system, i.e., binary files. These source packages can be directly installed and run on the target system (local machine).
[0022] In step 101, obtaining the target source package from the first storage source can be achieved by calling commands provided by the package management tool. For example, when executing step 101 for the first time, the target source package can be obtained from a storage address specified by apt (this address can be manually configured by the user) by calling the apt source command; obtaining the target source package from the first storage source can also be achieved by directly pulling the source code of the target source package from the given git repository.
[0023] Step 102: If the second storage source stores all the dependencies of the target source package, compile the target source package according to the dependencies, and remove the current target source package from the source package sequence.
[0024] If the second storage source contains all the dependencies of the target source package, these dependencies can be retrieved, and the target source package can be compiled based on these dependencies. These dependencies retrieved from the second storage source can be pre-compiled source packages, which can be directly installed and run after being downloaded to the local machine. If the target source package is successfully compiled and installed, the currently processed target source package can be removed from the source package sequence, allowing the processing of the next source package in the sequence.
[0025] In step 101 above, obtaining all dependencies of the target source package from the second storage source, and in step 102, can be achieved by calling commands provided by the package management tool. For example, by calling the `apt build-dep` command, this command will check the specified file in the target source package (such as the dependency description file under the Debian / control path), obtain the pre-compiled dependencies from another storage address specified by apt itself (this address can be the default configuration of apt), and attempt to install these pre-compiled dependencies.
[0026] Step 103: If at least one target dependency is missing from the second storage source, the missing target dependency is added as a source package to the head of the source package sequence.
[0027] If the second storage source is missing some dependencies—that is, if at least one target dependency is missing—then this target dependency can be added as a source package to the head of the source package sequence. The significance of this configuration is that the source package containing the target dependency can be obtained from the first storage source, and then the dependencies within that source package can be compiled on the target system (locally) to obtain a binary file that can run on the target system.
[0028] For example, if the source package sequence contains only package A, and when parsing the dependencies of package A, it is found that target dependency B and target dependency C are missing, then B and C can be inserted at the head of the source package sequence, making the source package sequence BCA.
[0029] If the target dependencies are missing from the second storage source—for example, if the target dependencies are not present in the second storage source, or if the stored version of the target dependencies is not the required version—the `apt build-dep` command will report an error. The `apt build-dep` command only issues an error warning but does not output the specific dependencies of the missing target dependencies, providing an incomplete description of the source packages to which the target dependencies belong. Therefore, you can use commands provided by other package management tools, such as `dpkg-checkbuilddeps`, to obtain the complete dependencies of the target dependencies and identify all missing dependencies. These missing dependencies will be added to the head of the source package sequence to be retrieved from the first storage source, and the source packages containing these dependencies will be compiled on the target system. This ensures that all dependencies in the target source package can be successfully compiled on the target system, guaranteeing that the target source package can ultimately run successfully on the target system.
[0030] Step 104: Re-enter the step of reading the target source code package located at the head of the queue in the source code package sequence until all source code packages in the source code package sequence have been compiled.
[0031] After step 102 or step 103 is completed, step 101 can be re-entered to re-read the target source package located at the head of the source package sequence, thereby enabling the compilation of the next source package.
[0032] For step 102, executing step 104 after step 102 indicates that the current target source code package has been compiled and the compilation operation of the next source code package input by the user has begun.
[0033] For example, the source package sequence includes packages E and F, and the source package sequence is EFG. All dependencies of these two source packages can be obtained from the second storage source. In step 101, package E is the target source package. Step 102 is to obtain all dependencies of package E and compile package E. After compilation, package E is removed, making the source package sequence FG. After entering step 104, step 101 will be re-executed. According to the new source package sequence, package F will be processed as the new target source package.
[0034] Regarding step 103, executing step 104 after step 103 indicates that the current target source code package has a missing dependency of the second storage source. Therefore, these missing dependencies need to be processed before the compilation of the current target source code package can be completed successfully.
[0035] For example, if the source package sequence only contains package A, in step 101, the target source package is package A. In step 103, it is found that package A is missing target dependencies package B and package C. Therefore, B and C can be inserted at the head of the source package sequence, making the source package sequence BCA. After entering step 104, step 101 is re-executed. Package B will be parsed first. In one scenario, package B is missing target dependency package D, so step 103 is re-entered, and package D is also inserted at the head of the source package sequence, making the source package sequence DBCA. In another scenario, all dependencies of package B can be obtained from the second storage source, so step 102 is re-entered to compile package B, and package B is removed from the source package sequence, making the source package sequence CA. Then, step 104 is re-entered. Based on the above logic, after packages B and C are compiled, the compilation of package A begins.
[0036] For target dependencies that have no dependencies of their own and cannot be obtained from the second storage source, when proceeding from step 104 to step 101, the source code package of the target dependency can be obtained from the first storage source by calling the package management tool. The source code in the package can then be compiled on the target system being migrated. For example, the source code package of the target dependency can be obtained from the first storage source using the `dpkg-buildpackage` command, and then compiled locally.
[0037] By continuously repeating step 104, it can be ensured that each source code package in the source code package sequence can be compiled into a binary file adapted to the target system, thus guaranteeing that each source code package in the source code package sequence can run smoothly on the target system.
[0038] In summary, in this embodiment, the source code packages to be compiled are arranged into a source code package sequence. After reading the target source code package at the head of the source code package sequence, the source code of the target source code package is obtained from the first storage source, and then all dependencies of the target source code package are obtained from the second storage source. If all dependencies can be obtained from the second storage source, the compilation of the target source code package can be completed based on these dependencies; if the target dependency is missing from the second storage source, the target dependency is added to the head of the source code package sequence as the target source code package to be read, and the target dependency is parsed; the above operations are repeated until all source code packages in the source code package sequence are compiled. The method provided by this embodiment can ensure that all dependencies of the target source code package can be obtained, thereby realizing the automated construction of the target source code package and all its dependencies, ensuring that each source code package in the source code package sequence can be compiled successfully, and improving the automation level and accuracy of the compilation process of computer program dependencies.
[0039] Figure 2 This is another method for compiling a source code package provided in the embodiments of this application. Figure 2The illustrated embodiments describe the specific steps and flow of the method, such as... Figure 2 As shown, the method may include: Step 201: Based on the read operation of the target source package located at the head of the source package sequence, obtain the target source package from the first storage source and obtain all the dependencies of the target source package from the second storage source.
[0040] Step 201 can be referred to step 101 above, and will not be repeated here.
[0041] Optionally, there is one first storage source; when obtaining the target source code package from the first storage source, the target source code package is always obtained from the same first storage source. Alternatively, there are at least two first storage sources; when retrieving the target source code package from the first storage source, the target source code package is retrieved from one of the at least two first storage sources.
[0042] In step 201, obtaining the target source package from the first storage source can be achieved by calling commands provided by the package management tool. For example, the target source package can be obtained from a storage address specified by apt (this address can be manually configured by the user) by calling the `apt source` command; obtaining the target source package from the first storage source can also be achieved by directly pulling the source code of the target source package from a given git repository. In the above implementation, both the storage address specified by apt and the git repository can serve as the first storage source, and both can exist simultaneously.
[0043] When step 201 is executed multiple times, the target source code package can be obtained from the same first storage source. The significance of this configuration is that it can reduce the number of times a connection is established during communication, thereby improving the speed performance of obtaining the target source code package. When using the same first storage source, it is only necessary to ensure the security of one first storage source, thereby simplifying the security audit process. Using the same first storage source can also simplify the process of configuring the compilation method of the source code package and reduce operation and maintenance costs.
[0044] When executing step 201 multiple times, the target source code package can also be obtained from different first storage sources, i.e., from one of at least two first storage sources. The significance of this configuration is that multiple first storage sources can provide reliability redundancy. When one first storage source is restricted (e.g., inaccessible due to maintenance or being blocked), the target source code package can still be obtained from other first storage sources, improving the availability and fault tolerance of the source code package compilation method. For certain source code packages requiring special authorization (e.g., specific programs in the financial or geographic information industries that need to be audited before being obtained from designated storage addresses), using different first storage sources ensures that the means of obtaining the target source code package are compliant and legal, reducing potential legal risks. Furthermore, using different first storage sources allows for customized acquisition strategies for different target source code packages, increasing the flexibility of configuring the source code package compilation method (e.g., some target source code packages are obtained from free public storage addresses, while others involving industry secrets are obtained from private storage addresses to avoid leaks).
[0045] Optionally, the version of the source code package stored in the first storage source is different from the version of the source code package to which the dependency belongs stored in the second storage source.
[0046] The source code package version stored in the first storage source is different from the source code package version of the dependency in the second storage source. This configuration enables the source code package to be compiled and run smoothly across different systems or different system versions. For example, for different versions of the same system, a first storage source and a second storage source are configured, where the first storage source corresponds to a higher system version and the second storage source corresponds to a lower system version. The compiled source code package stored in the second storage source is of a lower version, which, although it can run on the lower version system, contains security vulnerabilities; while obtaining a higher version source code package from the first storage source can patch the security vulnerabilities, allowing the compiled source code package to run stably and reliably on the lower version system.
[0047] The source code packages in the first storage source can have a higher version than the source code packages of the dependencies in the second storage source. This gives the source code packages obtained from the first storage source a variety of technical advantages, ensuring that after compilation, these source code packages can run reliably, stably, and securely on the target system. These technical advantages include, but are not limited to: patching security vulnerabilities, fixing bugs, improving runtime performance, unlocking new capabilities, and providing additional tool support capabilities.
[0048] Step 202: If the second storage source stores all the dependencies of the target source package, compile the target source package according to the dependencies, and remove the current target source package from the source package sequence.
[0049] Step 202 can be referred to step 102 above, and will not be repeated here.
[0050] Step 203: If at least one target dependency is missing in the second storage source, a recursive function is used to determine all sub-dependencies of the target dependency.
[0051] When a target dependency is missing from the second storage source, all its sub-dependencies can be identified. Only after these sub-dependencies are successfully compiled can the target dependency be compiled successfully. These sub-dependencies include both direct and indirect dependencies of the target dependency. All sub-dependencies can be obtained by processing the target dependency using a recursive function.
[0052] Optionally, in step 203, a recursive function is used to determine all sub-dependencies of the target dependency, which may specifically include: Sub-step 2031: Select the target dependency as the dependency to be detected; Sub-step 2032: Substitute the dependency to be detected into the recursive function to enumerate all direct dependencies of the dependency to be detected; Sub-step 2033: If the dependency to be detected does not have the aforementioned direct dependency, exit the current recursive function; Sub-step 2034: If the dependency to be detected has at least one direct dependency, then the direct dependency is used as a new dependency to be detected and substituted back into the recursive function. Sub-step 2035: Wait for all the recursive functions to exit, and take all the enumerated direct dependencies as all the sub-dependencies of the target dependency.
[0053] Sub-steps 2031-2035 above describe the specific process of obtaining all sub-dependencies of a target dependency using a recursive function. For a source package to which a target dependency belongs, there can be multiple direct dependencies, and these direct dependencies can also have their own direct dependencies (indirect dependencies of the target dependency). Therefore, by using a recursive function, the direct dependencies of each dependency can be enumerated, thereby determining all sub-dependencies of the target dependency. A recursive function is a function that calls itself within its function body. Its core idea is to decompose complex problems into smaller, structurally similar problems, making it more concise in code implementation and easier to understand and maintain.
[0054] The key elements of a recursive function include its function purpose, baseline condition, and recursion propagation. The function purpose clarifies what the recursive function needs to do; the baseline condition clarifies when to stop the recursive function, preventing infinite calls that could lead to a stack overflow; and recursion propagation narrows the parameter range of the recursive function with each call, allowing the recursive function to continuously approach the baseline condition.
[0055] In the compilation method of the source code package provided in this application, the function of the recursive function can be to enumerate all direct dependencies of the parameters of the recursive function, i.e., the content described in sub-step 2032. Enumerating all direct dependencies can be achieved by calling specific instructions provided by the package management tool. For example, the dpkg-checkbuilddeps command can be used to enumerate detailed information of the source code package, including all direct dependencies of the source code package.
[0056] The baseline condition for a recursive function can be that if the dependency represented by the current parameter cannot enumerate any more direct dependencies, then the current recursive function exits, as described in sub-step 2033 above. For example, if the recursive function is f(x), where x is a formal parameter, then for the dependency H package to be detected, all direct dependencies of the H package can be enumerated through f(H). If the dependency H package to be detected has no direct dependencies, then f(H) exits.
[0057] The recursive progression of the recursive function can involve substituting the direct dependencies of the dependency to be detected as new dependencies into the recursive function, as described in step 2034 above. For example, if the recursive function is f(x), where x is a formal parameter, first, the target dependency I package is substituted into f(x) as a parameter. f(I) enumerates the direct dependencies J and K packages of I package. Then, J package is substituted into f(x) as a new parameter, and f(J) enumerates all direct dependencies of J package. If J package has no direct dependencies, f(J) exits. At this point, I package still has a direct dependency K package, so K package is substituted into f(x) as a new parameter. f(K) enumerates all dependencies of K package. If K package also has no direct dependencies, f(K) exits. At this point, f(I) has no more direct dependencies to enumerate, so f(I) exits, completing the enumeration of all sub-dependencies of I package.
[0058] Finally, as described in sub-step 2035, after the recursive function has been fully executed, all the enumerated dependencies are the child dependencies of the target dependency.
[0059] By using recursive functions, it can be ensured that all sub-dependencies of the target dependency are enumerated one by one, avoiding the omission of dependencies during the compilation of the target source code package and ensuring that the target source code package can be compiled successfully.
[0060] Step 204: If the target dependency does not have the sub-dependency, or if the second storage source stores all the sub-dependencies of the target dependency, add the target dependency to the head of the source package sequence.
[0061] If no sub-dependencies are enumerated in step 203, or if all enumerated sub-dependencies can be obtained from the second storage source, then the target dependency can be added as a new source package to the head of the source package sequence. If the target dependency has no sub-dependencies, it means the target dependency can be compiled directly, so the compilation of the target dependency can begin according to step 202; if all sub-dependencies of the target dependency can be obtained from the second storage source, it means that all sub-dependencies of the target dependency have been compiled into binary files that can run smoothly on the target system. These binary files can be directly obtained, enabling the successful compilation of the target dependency, so the compilation of the target dependency can begin according to step 202.
[0062] Step 205: If at least one target sub-dependency is missing in the second storage source, add the target sub-dependency and the target dependency to the head of the source package sequence.
[0063] If the enumerated target sub-dependencies do not have corresponding binary files in the second storage source, then it is necessary to retrieve the source code packages to which these target sub-dependencies belong from the first storage source, and then compile these source code packages on the target system to ensure that the target dependencies can be compiled successfully. Therefore, these target sub-dependencies and target dependencies need to be added as new source code packages to the head of the source code package sequence for processing.
[0064] Optionally, step 205 may include: Sub-step 2051: Sort the target sub-dependencies and the target dependency according to all the dependencies of the target dependency to obtain the dependency sequence; Sub-step 2052: According to the dependency sequence, add the target sub-dependency and the target dependency to the head of the source code package sequence in sequence.
[0065] For step 205, a target dependency may have multiple target sub-dependencies. These target sub-dependencies may also have their own target sub-dependencies. There may be overlapping dependencies between these target sub-dependencies. The sub-dependencies that these sub-dependencies depend on need to be compiled first to ensure that all sub-dependencies can be compiled successfully. For example, for a target dependency package A, there are target sub-dependencies package B and package C, and there is no dependency relationship between package B and package C. These three dependencies can be added as source packages to the beginning of the source package sequence in the order BCA, i.e., the source package sequence is BCA. If package B itself has a target sub-dependency package D, then based on the BCA order, package D needs to be added to the beginning of the source package sequence, in this case, the source package sequence is DBCA. That is, compiling in the order of package D, package B, and package C ensures that package A compiles successfully. If package D itself has a target sub-dependency package C, then package C needs to be compiled first to ensure that package D is compiled successfully. In this case, compiling in the order of package C, package D, and package B ensures that package A compiles successfully, in this case, the source package sequence is CDBA.
[0066] Substeps 2051-2052 above describe the method steps for handling the order of target sub-dependencies and target dependencies when adding target sub-dependencies and target dependencies to the head of the source package sequence.
[0067] By analyzing the dependencies between target sub-dependencies and between target sub-dependencies and target dependencies, a deduplicated dependency sequence can be determined. In this sequence, the successful compilation of dependencies at the beginning of the sequence guarantees the successful compilation of dependencies at the end of the sequence. Adding target dependencies and target sub-dependencies to the head of the source package sequence according to this sequence ensures that all source packages in the sequence can be compiled successfully.
[0068] Optionally, sub-step 2051 may specifically include: Sub-step 20511: Use a directed acyclic graph to represent all the dependencies of the target dependency; in the directed acyclic graph, each node represents a dependency, and the directed edge between two nodes represents the dependency between the two dependencies; Sub-step 20512: Perform topological sorting on all nodes of the directed acyclic graph to obtain the dependency sequence.
[0069] The specific sorting method is shown in sub-steps 20511-20512 above. First, all dependencies of the target dependency can be represented in the form of a Directed Acyclic Graph (DAG). A DAG is a graph-based data structure with directionality and acyclicity. Directionality means that the edges connecting two nodes in a DAG have a clear direction (A→B and B→A are different), that is, every edge in a DAG is a directed edge. Acyclicity means that there are no cycles in a DAG, and it is impossible to start from a node and return to that node along the direction of a directed edge. Based on the above characteristics, DAG has topological sorting feasibility, that is, there is at least one acyclic topological sequence in a DAG, in which all nodes in the DAG can be arranged into a linear sequence, such that the starting point of each directed edge is before the ending point. Therefore, all dependencies of the target dependency can be represented by a DAG. Each node in the DAG represents a dependency (including dependencies that can be obtained from the second storage source and dependencies that are missing from the second storage source). Each directed edge in the DAG represents the dependency relationship between two dependencies. For example, B→A can be used to indicate that package A depends on package B, that is, package B is a dependency of package A.
[0070] For DAGs, specific sorting algorithms, such as Kahn's algorithm, can be used to obtain acyclic topological sequences. The process of sorting a DAG using Kahn's algorithm includes: Step 1: Initialize a queue Q to store all nodes in the DAG with an in-degree of 0. An in-degree of 0 means that there is no directed edge ending at that node. In terms of dependency relationships, this means that in the DAG, the dependency represented by that node has no dependencies of its own. Step 2: Take a node from queue Q, remove the node from the DAG, and store it in the result sequence R; Step 3: Remove all directed edges connected to the node and update the in-degree of adjacent nodes in the DAG; Step 4: If the in-degree of an adjacent node becomes 0 after the update, then add the adjacent node to queue Q. Step 5: Repeat steps 2-4 above until queue Q becomes empty.
[0071] After completing step 5 above, the resulting sequence R is the sequence of all sub-dependencies of the target dependency. Removing the sub-dependencies that can be obtained from the second storage source from this sequence yields the dependency sequence required in sub-step 2051. By calling commands provided by a package management tool, such as dpkg-buildpackage, the source packages to which these sub-dependencies belong can be obtained from the first storage source, downloaded to the target system (local), and compilation and installation can begin.
[0072] Step 206: Re-enter the step of reading the target source package at the head of the source package sequence until all source packages in the source package sequence have been compiled.
[0073] This step can be referred to as step 104 above, and will not be repeated here.
[0074] Optionally, the method may further include: Step 207: Based on the dependency sequence, complete the missing target dependencies and target sub-dependencies in the second storage source.
[0075] Understandably, after obtaining the dependency sequence in step 205, it can be determined which specific dependencies are missing in the second storage source for the target source package. In other words, what dependencies are needed to successfully compile the target source package on the target system. Therefore, the missing target dependencies and target sub-dependencies in the second storage source can be completed based on the dependency sequence. Locally compiled target dependencies and target sub-dependencies can be uploaded to the second storage source to complete the second storage source, or pre-compiled target dependencies and target sub-dependencies that can run successfully on the target system can be obtained from a specified third storage source.
[0076] For dependencies that have been compiled, the source code package to which the dependency belongs, the compiled binary file, and related log files can be stored in a specified location (e.g., deps_build / <dependency name> / ), and a dependency sequence description file (which can be named depslist.txt) can be generated. The dependency description file can be used to store the above dependency sequence. Based on this, the dependency description file can record the current compilation status of a certain dependency, thereby enabling the reproduction, tracking, debugging, and analysis of dependency relationships in the dependency sequence, and facilitating the completion of missing target dependencies and target sub-dependencies in the second storage source.
[0077] In this embodiment, the source code packages to be compiled are arranged into a source code package sequence. After reading the target source code package at the head of the source code package sequence, the source code of the target source code package is obtained from a first storage source, and then all dependencies of the target source code package are obtained from a second storage source. If all dependencies can be obtained from the second storage source, the compilation of the target source code package can be completed based on these dependencies; if the target dependency is missing from the second storage source, the target dependency is added to the head of the source code package sequence as a target source code package to be read, and the target dependency is parsed; the above operations are repeated until all source code packages in the source code package sequence are compiled. The method provided by this embodiment can ensure that all dependencies of the target source code package can be obtained, thereby realizing the automated construction of the target source code package and all its dependencies, ensuring that each source code package in the source code package sequence can be compiled successfully, and improving the automation level and accuracy of the compilation process of computer program dependencies.
[0078] Figure 3 This is yet another method for compiling a source code package provided in the embodiments of this application, such as... Figure 3 As shown, the method may include: Step S1: The user inputs a list of target packages.
[0079] In step S1, the target package list, i.e. the source code package sequence mentioned above, can be understood to be manually entered by the user.
[0080] Step S2: Dependency recursion analysis.
[0081] Step S2 is equivalent to step 203 above.
[0082] Step S3: Secondary missing dependency analysis.
[0083] In step S3, the secondary missing dependency refers to the target sub-dependency.
[0084] Step S4: Recursive dependency queue construction and deduplication.
[0085] The recursive dependency sequence in step S4 is equivalent to the dependency sequence in sub-step 2051 above.
[0086] Step S5: Compile the packages sequentially according to the recursive dependency queue.
[0087] In step S5, the package refers to all dependencies of the target source code package.
[0088] Step S6: Perform a pre-check to determine if any dependencies are not satisfied. If not, proceed to step S7; otherwise, repeat step S2.
[0089] In step S6, determining whether the dependency is satisfied means judging whether all the dependencies of the target source code package have been compiled.
[0090] Step S7: Compile cache and dependency chain archive.
[0091] Step S7 refers to caching the compiled dependencies (caching them locally) and archiving the recursive dependency queue. The archived recursive dependency queue can be used to implement step 207 above. Caching the compiled dependencies can enable the target source code package to be run repeatedly locally.
[0092] Step S8: Interactive human intervention.
[0093] During the execution of any of steps S2 and S7 above, the user decision-making interface provides the capability for manual intervention. This includes, for example, skipping specified packages (e.g., if dpkg-buildpackage fails, the specified package can be removed from the recursive dependency sequence to ensure successful processing), replacing dependent source code (changing the first or second storage source, such as obtaining the source package from a specified src, or through a dsc file dget, or through a specified git repository), modifying build parameters, and directly modifying the source code within the source package. Manual intervention provides greater flexibility to the compilation method of the source package provided in this application, ensuring the smooth operation of the entire process.
[0094] Step S9: The entire source code construction is complete.
[0095] Once all source packages in the target package list have been compiled and installed, the entire source code build process is complete.
[0096] This application's embodiments, by introducing recursive dependency resolution and auto-completion mechanisms, achieve fully automated construction of complex source code packages, significantly improving the automation level of the build process and the accuracy of dependency resolution. This effectively solves the build failure problem caused by missing dependencies or incorrect build order in existing technologies. Combined with topology sorting and build caching mechanisms, this application's embodiments ensure high success rates, traceability, and reproducibility of subsequent dependency build processes; simultaneously, manual intervention enhances the system's fault tolerance and adaptability. This application's embodiments automate the dependency build process for source code packages, saving labor costs and significantly improving the efficiency and quality of system integration.
[0097] Figure 4 This is a block diagram of a source code package compilation device 30 provided in an embodiment of this application. Device 30 may include: The acquisition module 301 is used to acquire the target source code package from the first storage source based on the reading operation of the target source code package located at the head of the queue in the source code package sequence, and to acquire all the dependencies of the target source code package from the second storage source. The removal module 302 is used to compile the target source package according to the dependencies when the second storage source stores all the dependencies of the target source package, and remove the current target source package from the source package sequence; Adding module 303 is used to add the missing target dependency as a source code package and add it to the head of the source code package sequence when at least one target dependency is missing in the second storage source; The loop module 304 is used to re-enter the step of reading the target source package located at the head of the queue in the source package sequence until all source packages in the source package sequence have been compiled.
[0098] Optionally, adding module 301 may include: A recursive acquisition submodule is used to determine all sub-dependencies of the target dependency using a recursive function. The first submodule is added when the target dependency does not have the sub-dependency, or when the second storage source stores all the sub-dependencies of the target dependency, and the target dependency is added to the head of the source package sequence. The second addition submodule adds the target sub-dependency and the target dependency to the head of the source package sequence if the second storage source is missing at least one target sub-dependency.
[0099] Optionally, the second added submodule may include: The sorting unit is used to sort the target sub-dependencies and the target dependency according to all the dependencies of the target dependency to obtain a dependency sequence; An adding unit is used to add the target sub-dependency and the target dependency to the head of the source package sequence in sequence according to the dependency sequence.
[0100] Optionally, the sorting unit may include: A directed graph subunit is used to represent all dependencies of the target dependency using a directed acyclic graph; in the directed acyclic graph, each node represents a dependency, and a directed edge between two nodes represents a dependency between the two dependencies; The topology sorting subunit is used to perform topology sorting on all nodes of the directed acyclic graph to obtain the dependency sequence.
[0101] Optionally, recursively retrieving submodules may include: The startup unit is used to select the target dependency as a dependency to be detected. An enumeration unit is used to enumerate all direct dependencies of the dependency to be detected by substituting the dependency to be detected into the recursive function. The exit unit is used to exit the current recursive function if the dependency to be detected does not have the direct dependency. The recursive execution unit is used to, when the dependency to be detected has at least one direct dependency, treat the direct dependency as a new dependency to be detected and resubmit it into the recursive function; The sub-dependency acquisition unit is used to wait for all the recursive functions to exit, and to take all the enumerated direct dependencies as all sub-dependencies of the target dependency.
[0102] Optionally, there is one first storage source; when obtaining the target source code package from the first storage source, the target source code package is always obtained from the same first storage source. Alternatively, there are at least two first storage sources; when retrieving the target source code package from the first storage source, the target source code package is retrieved from one of the at least two first storage sources.
[0103] Optionally, the version of the source code package stored in the first storage source is different from the version of the source code package to which the dependency belongs stored in the second storage source.
[0104] Optionally, the device 30 may further include: The completion module is used to complete the missing target dependencies and target sub-dependencies in the second storage source based on the dependency sequence.
[0105] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0106] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0107] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0108] This application provides a source code package compilation apparatus, including a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising methods for performing the methods described in one or more of the above embodiments.
[0109] Figure 5 This is a block diagram illustrating a source code package compilation apparatus 800 according to an exemplary embodiment. For example, apparatus 800 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0110] Reference Figure 5 The device 800 may include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0111] Processing component 802 typically controls the overall operation of device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0112] Memory 804 is configured to store various types of data to support the operation of device 800. Examples of this data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0113] Power supply component 806 provides power to various components of device 800. Power supply component 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to device 800.
[0114] Multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0115] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when device 800 is in an operating mode, such as call mode, recording mode, and voice information processing mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0116] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0117] Sensor assembly 814 includes one or more sensors for providing status assessments of various aspects of device 800. For example, sensor assembly 814 can detect the on / off state of device 800, the relative positioning of components such as the display and keypad of device 800, and can also detect changes in the position of device 800 or a component of device 800, the presence or absence of user contact with device 800, the orientation or acceleration / deceleration of device 800, and temperature changes of device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0118] Communication component 816 is configured to facilitate wired or wireless communication between device 800 and other devices. Device 800 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0119] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0120] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of the device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0121] Figure 6 This is a schematic diagram of the server structure in some embodiments of this application. The server 1900 can vary significantly due to different configurations or performance, and may include one or more central processing units (CPUs) 1922 (e.g., one or more processors) and memory 1932, and one or more storage media 1930 (e.g., one or more mass storage devices) for storing application programs 1942 or data 1944. The memory 1932 and storage media 1930 can be temporary or persistent storage. The program stored in the storage media 1930 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 1922 may be configured to communicate with the storage media 1930 and execute the series of instruction operations in the storage media 1930 on the server 1900.
[0122] Server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input / output interfaces 1958, one or more keyboards 1956, and / or one or more operating systems 1941, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0123] A non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of a device (server or terminal), enable the device to perform the methods of the embodiments described above.
[0124] A non-transitory computer-readable storage medium is provided, which, when the instructions in the storage medium are executed by the processor of a device (server or terminal), enables the device to perform the methods described in the above embodiments; therefore, further details will not be repeated here. Additionally, the beneficial effects of employing the same method will also not be repeated. For technical details not disclosed in the computer program products or computer program embodiments related to this application, please refer to the description of the method embodiments of this application.
[0125] Furthermore, it should be noted that this application also provides a computer program product or computer program, which may include computer instructions, which may be stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor can execute the computer instructions to cause the computer device to perform the methods described in the above embodiments; therefore, these will not be repeated here. Additionally, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the embodiments of the computer program product or computer program involved in this application, please refer to the description of the method embodiments of this application.
[0126] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0127] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
[0128] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0129] The foregoing has provided a detailed description of an account information management method, apparatus, electronic device, and computer-readable storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for compiling a source code package, characterized in that, The method includes: Based on the read operation of the target source package located at the head of the queue in the source package sequence, the target source package is obtained from the first storage source, and all dependencies of the target source package are obtained from the second storage source; If the second storage source stores all the dependencies of the target source package, the target source package is compiled according to the dependencies, and the current target source package is removed from the source package sequence. If at least one target dependency is missing from the second storage source, the missing target dependency is treated as a source package and added to the head of the source package sequence. Re-enter the step of reading the target source package at the head of the source package sequence until all source packages in the source package sequence have been compiled.
2. The method according to claim 1, characterized in that, Adding the missing target dependency to the head of the source package sequence includes: A recursive function is used to determine all sub-dependencies of the target dependency; If the target dependency does not have the sub-dependency, or if the second storage source stores all the sub-dependencies of the target dependency, the target dependency is added to the head of the source package sequence. If at least one target sub-dependency is missing in the second storage source, the target sub-dependency and the target dependency are added to the head of the source package sequence.
3. The method according to claim 2, characterized in that, The step of adding the target sub-dependency and the target dependency to the head of the source code package sequence when at least one target sub-dependency is missing in the second storage source includes: Based on all the dependencies of the target dependency, sort the target sub-dependencies and the target dependency to obtain a dependency sequence; According to the dependency sequence, the target sub-dependency and the target dependency are added to the head of the source package sequence in sequence.
4. The method according to claim 3, characterized in that, The step of sorting the target sub-dependencies and the target dependency according to all dependencies of the target dependency to obtain a dependency sequence includes: A directed acyclic graph is used to represent all dependencies of the target dependency; in the directed acyclic graph, each node represents a dependency, and the directed edge between two nodes represents the dependency relationship between the two dependencies. Perform a topological sort on all nodes of the directed acyclic graph to obtain the dependency sequence.
5. The method according to claim 2, characterized in that, The recursive function is used to determine all sub-dependencies of the target dependency, including: The target dependency is selected as the dependency to be detected. The dependency to be detected is used as a parameter and substituted into the recursive function to enumerate all direct dependencies of the dependency to be detected. If the dependency to be tested does not have the stated direct dependency, exit the current recursive function; If the dependency to be detected has at least one direct dependency, the direct dependency is treated as a new dependency to be detected and substituted back into the recursive function. Wait for all the recursive functions to exit, and then treat all the enumerated direct dependencies as all the sub-dependencies of the target dependency.
6. The method according to claim 1, characterized in that, There is one first storage source; when retrieving the target source code package from the first storage source, the target source code package is always retrieved from the same first storage source. Alternatively, there are at least two first storage sources; when retrieving the target source code package from the first storage source, the target source code package is retrieved from one of the at least two first storage sources.
7. The method according to claim 1, characterized in that, The version of the source code package stored in the first storage source is different from the version of the source code package to which the dependency is stored in the second storage source.
8. The method according to claim 3, characterized in that, The method further includes: Based on the dependency sequence, complete the missing target dependencies and target sub-dependencies in the second storage source.
9. A compilation apparatus for a source code package, characterized in that, The device includes: Acquisition module: used to acquire the target source package from the first storage source based on the read operation of the target source package located at the head of the queue in the source package sequence, and to acquire all the dependencies of the target source package from the second storage source; The removal module is used to compile the target source package according to the dependencies when the second storage source stores all the dependencies of the target source package, and remove the current target source package from the source package sequence; Add module: used to add the missing target dependency as a source package and add it to the head of the source package sequence when at least one target dependency is missing in the second storage source; Loop module: Used to re-enter the step of reading the target source package at the head of the queue in the source package sequence until all source packages in the source package sequence have been compiled.
10. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the method as described in any one of claims 1 to 8.