System mirror image construction method and device, electronic equipment and storage medium

By finding and obtaining the target files required to build Linux system images in the distributed shared cache, the problem of slow construction speed in the existing technology is solved, and faster system image construction speed and higher user experience are achieved.

CN120196599APending Publication Date: 2025-06-24SEAWAY TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311786092.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2025-06-24

Smart Images

  • Figure CN120196599A_ABST
    Figure CN120196599A_ABST
Patent Text Reader

Abstract

The invention relates to a system mirror image construction method and device, electronic equipment and a storage medium, and the method comprises the steps: determining a target system, and determining a target file needed for constructing a system mirror image of the target system; when it is determined that the target file exists in a preset distributed shared cache, obtaining the target file from the distributed shared cache; and constructing a system mirror image of the target system based on the target file. Therefore, the construction speed of the system mirror image can be improved, the development progress of the system is accelerated, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a method, device, electronic device, and storage medium for constructing a system image. Background Art

[0002] Currently, real-time embedded Linux systems are widely used in fields such as consumer electronic devices, network devices, and industrial control computers. With the wide application of the Linux system, the existing functions of the Linux system have gradually been unable to meet the needs of major manufacturers. Therefore, major manufacturers need to customize and develop their own embedded Linux products. However, due to the high flexibility of the Linux system, specialized development tools are required to customize and develop the Linux system.

[0003] In the prior art, in the process of constructing a Linux system image, an image is generally built through a source code construction method. This method is only suitable for the construction of small-scale Linux systems and is suitable for manual operation, with low efficiency. Summary of the Invention

[0004] This application provides a method, device, electronic device, and storage medium for constructing a system image to solve the technical problem that the construction speed is slow when constructing a Linux system image in the prior art, which affects the user experience.

[0005] In a first aspect, this application provides a method for constructing a system image, the method comprising:

[0006] Determine a target system and determine target files required for constructing a system image of the target system;

[0007] When it is determined that the target files exist in a preset distributed shared cache, obtain the target files from the distributed shared cache;

[0008] Based on the target files, construct a system image of the target system.

[0009] As a possible implementation, the determining the target files required for constructing a system image of the target system includes:

[0010] Parse preset system files of the target system to obtain a file structure bitmap required for constructing a system image of the target system;

[0011] Determine the files corresponding to the file identifiers included in the file structure bitmap as the target files required for constructing a system image of the target system.

[0012] As a possible implementation, the determining that the target files exist in a preset distributed shared cache includes:

[0013] Generate a file dependency tree corresponding to the target system according to the file structure bitmap, where the file dependency tree includes the dependency relationships between the target files and the file identifiers of the target files;

[0014] Match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache;

[0015] If a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, it is determined that the target files exist in the distributed shared cache.

[0016] As a possible implementation, the file dependency tree further includes a hash value corresponding to each target file, and the matching of the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache includes:

[0017] Match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash value corresponding to each target file included in the file dependency tree.

[0018] As a possible implementation, the matching of the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash value corresponding to each target file included in the file dependency tree includes:

[0019] For each preset file dependency tree stored in the distributed shared cache, compare the hash value included in the file dependency tree with the hash value of the file having the same file identifier and the same corresponding dependency relationship in the preset file dependency tree to obtain a comparison result for each file included in the preset file dependency tree;

[0020] Determine whether the comparison result for each file included in each preset file dependency tree indicates that the two compared hash values are consistent;

[0021] If it is determined that there is a preset file dependency tree for which the comparison result for each file included indicates that the two compared hash values are consistent, it is determined that a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, and this preset file dependency tree is determined as the target file dependency tree;

[0022] If it is determined that there is no preset file dependency tree for which the comparison result for each file included indicates that the two compared hash values are consistent, it is determined that no target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

[0023] As a possible implementation, before determining that the target file exists in the distributed shared cache, the method further includes:

[0024] Determine whether the target file exists in the local cache;

[0025] If it is determined that the target file does not exist in the local cache, execute the step of determining that the target file exists in the preset distributed shared cache;

[0026] If it is determined that the target file exists in the local cache, obtain the target file from the local cache, and construct a system image of the target system according to the target file obtained from the local cache.

[0027] As a possible implementation, the method further includes:

[0028] In the case where it is determined that the target file does not exist in both the local cache and the distributed shared cache, construct a system image of the target system through a preset compilation tool;

[0029] Obtain a plurality of compilation files generated by the compilation tool during the construction of the system image;

[0030] Construct a dependency tree corresponding to the plurality of compilation files, and store the dependency tree in the distributed shared cache.

[0031] In a second aspect, an embodiment of the present application provides a device for constructing a system image, and the device includes:

[0032] A determination module, configured to determine a target system and determine a target file required for constructing a system image of the target system;

[0033] An acquisition module, configured to obtain the target file from the distributed shared cache when it is determined that the target file exists in the preset distributed shared cache;

[0034] A construction module, configured to construct a system image of the target system based on the target file.

[0035] As a possible implementation, the determination module includes:

[0036] A parsing sub-module, configured to parse a preset system file of the target system to obtain a file structure bitmap required for constructing a system image of the target system;

[0037] A first determination sub-module, configured to determine, as the target file required for constructing a system image of the target system, a file corresponding to a file identifier included in the file structure bitmap.

[0038] As a possible implementation, the obtaining module includes:

[0039] A generating sub-module, configured to generate a file dependency tree corresponding to the target system according to the file structure bitmap, where the file dependency tree includes the dependency relationships between the target files and the file identifiers of the target files;

[0040] A matching sub-module, configured to match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache;

[0041] A second determining sub-module, configured to determine that the target file exists in the distributed shared cache if a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

[0042] As a possible implementation, the file dependency tree further includes a hash value corresponding to each target file, and the matching sub-module includes:

[0043] A matching unit, configured to match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash values corresponding to each target file included in the file dependency tree.

[0044] As a possible implementation, the matching unit is specifically configured to:

[0045] For each preset file dependency tree stored in the distributed shared cache, compare each hash value included in the file dependency tree with the hash values of the files having the same file identifier and the same corresponding dependency relationship in the preset file dependency tree, to obtain a comparison result for each file included in the preset file dependency tree;

[0046] Determine whether the comparison results for each file included in each preset file dependency tree all indicate that the two compared hash values are consistent;

[0047] If it is determined that there is a preset file dependency tree for which the comparison results for each file included therein all indicate that the two compared hash values are consistent, determine that a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, and determine this preset file dependency tree as the target file dependency tree;

[0048] If it is determined that there is no preset file dependency tree for which the comparison results for each file included therein all indicate that the two compared hash values are consistent, determine that no target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

[0049] As a possible implementation, the apparatus further includes:

[0050] A second determination module, configured to determine whether the target file exists in the local cache before determining that the target file exists in the distributed shared cache;

[0051] An execution module, configured to, if it is determined that the target file does not exist in the local cache, execute the step of determining that the target file exists in the preset distributed shared cache;

[0052] A target acquisition module, configured to, if it is determined that the target file exists in the local cache, acquire the target file from the local cache, and construct a system image of the target system according to the target file acquired from the local cache.

[0053] As a possible implementation manner, the apparatus further includes:

[0054] An image construction module, configured to, in the case that it is determined that the target file does not exist in both the local cache and the distributed shared cache, construct a system image of the target system through a preset compilation tool;

[0055] A file acquisition module, configured to acquire a plurality of compilation files generated by the compilation tool during the process of constructing the system image;

[0056] A storage module, configured to construct a dependency tree corresponding to the plurality of compilation files, and store the dependency tree in the distributed shared cache.

[0057] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory, where the processor is configured to execute a system image construction program stored in the memory to implement the system image construction method according to any one of the first aspects.

[0058] In a fourth aspect, an embodiment of the present application provides a storage medium, where the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the system image construction method according to any one of the first aspects

[0059] The technical solution provided by the embodiment of the present application determines a target system, determines a target file required to construct a system image of the target system, and in the case that it is determined that the target file exists in the preset distributed shared cache, acquires the target file from the distributed shared cache, and constructs a system image of the target system based on the target file. This technical solution constructs a system image by using the target files generated by other machines pre-cached in the distributed shared cache to construct the system image, avoiding the technical problem in the prior art that directly generating the target files required to construct the system image results in a slow system image construction speed, thereby achieving the improvement of the system image construction speed, accelerating the system development progress, and enhancing the user experience. Description of the Drawings

[0060] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments in accordance with the present invention, and are used together with the specification to explain the principles of the present invention.

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0062] One or more embodiments are exemplarily illustrated by the pictures in the corresponding accompanying drawings. These exemplary illustrations do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements. Unless otherwise stated, the drawings in the figures do not constitute a scale limitation.

[0063] Figure 1 It is a flowchart of an embodiment of a method for constructing a system image provided for an embodiment of the present application;

[0064] Figure 2 It is a flowchart of an embodiment of a method for constructing a system image in the prior art provided for an embodiment of the present application;

[0065] Figure 3 It is a schematic diagram of the structure of a file dependency tree provided for an embodiment of the present application;

[0066] Figure 4 It is a flowchart of an embodiment of another method for constructing a system image provided for an embodiment of the present application;

[0067] Figure 5 It is a flowchart of an embodiment of yet another method for constructing a system image provided for an embodiment of the present application;

[0068] Figure 6 It is a block diagram of an embodiment of a device for constructing a system image provided for an embodiment of the present application;

[0069] Figure 7 It is a schematic diagram of the structure of an electronic device provided for an embodiment of the present application. Detailed implementation manners

[0070] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are some, but not all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.

[0071] The following disclosure provides many different embodiments or examples for implementing different structures of the present invention. To simplify the disclosure of the present invention, components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit the present invention. In addition, the present invention may repeat reference numerals and / or letters in different examples. This repetition is for the purpose of simplification and clarity and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0072] To solve the technical problem in the prior art that the building speed is slow when building a Linux system image, which affects the user experience, this application provides a method, apparatus, electronic device, and storage medium for building a system image, which can realize building a system image by using target files generated by pre-caching other machines in a distributed shared cache to build the system image, avoiding the technical problem in the prior art that directly generating the target files required for building the system image results in a slow building speed of the system image, thereby realizing improving the building speed of the system image, accelerating the development progress of the system, and enhancing the user experience.

[0073] The following further explains the method for building a system image provided by this application with specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.

[0074] See Figure 1 , which is a flowchart of an embodiment of a method for building a system image provided by an embodiment of this application. As Figure 1 shown, the process may include the following steps:

[0075] Step 101: Determine the target system and determine the target files required to build the system image of the target system.

[0076] The above-mentioned target system is the system for which the system image is to be built, which may be a Linux system or other systems, and the embodiments of this application do not limit this.

[0077] The above-mentioned target files refer to the files generated by compilation during the process of building the system image of the system, which may include but are not limited to: compiled source code files, compilation intermediate files, binary files, and hash verification files at each stage. Specifically, refer to Table 1 below:

[0078] Table 1

[0079]

[0080] In one embodiment, the execution subject of the embodiments of the present application may be a Yocto tool for building a system image. The Yocto tool can unify the customization and development standards of embedded Linux, which avoids a lot of repetitive work and greatly simplifies the customization and development of the embedded Linux system.

[0081] Based on this, the execution subject of the embodiments of the present application can receive a control instruction input by a user and parse the control instruction to determine the target system for which a system image is to be built.

[0082] In another embodiment, the execution subject of the embodiments of the present application may be a terminal device installed with the Yocto tool, which may include but is not limited to: a laptop computer, a desktop computer, and a smart phone, etc.

[0083] Based on this, the execution subject of the embodiments of the present application can obtain a build task set by a user through a visual interface and obtain the target system for which a system image is to be built from the build task.

[0084] In one embodiment, the execution subject of the embodiments of the present application can determine target files required for building a system image of a target system by parsing a preset system file of the target system. Among them, the preset file of the target system may be a bb file of the target system.

[0085] As an optional implementation manner, the execution subject of the embodiments of the present application can parse a preset system file of the target system to obtain a file structure bitmap required for building a system image of the target system. Then, files corresponding to file identifiers included in the file structure bitmap can be determined as target files required for building a system image of the target system. The above file identifiers may be file names of target files or identifiers such as formats of target files. The embodiments of the present application do not limit this.

[0086] Step 102, in the case of determining that the target file exists in the preset distributed shared cache, obtain the above target file from the distributed shared cache.

[0087] Step 103, build a system image of the target system based on the above target file.

[0088] The following is a unified description of Step 102 and Step 103:

[0089] The above distributed shared cache is a shared cache in a distributed file system, which can connect multiple terminal devices through a network, and each terminal device can modify or read files stored in the shared cache.

[0090] In practical applications, the system image of the target system is generally built through the Yocto tool. However, due to the relatively large volume of the Yocto tool, its build speed is slow when building the Linux system image, which reduces the development progress of the Linux system and affects the user experience.

[0091] Based on this, in the embodiments of the present application, in order to accelerate the development progress of the system, it can be determined whether there is a target file generated historically currently. If so, the target file can be directly applied to build the system image, thereby accelerating the development progress of the system and enhancing the user experience.

[0092] In the prior art, the above target file can be obtained from the local cache, and the system image can be built according to the target file obtained locally. Specifically, it can be as Figure 2 shown in the process, see Figure 2 , which is a flowchart of an embodiment of a method for building a system image in the prior art provided by the embodiments of the present application. As Figure 2 shown, bitbake is the build engine of the yocto tool. Bitbake will first parse all bb files in the project and then generate a bitmap and a dependency tree. According to the dependency tree, relevant local caches are searched. If found, the local cache is used for building; otherwise, the source code is used for building, and binary packages (in the forms of rpm and deb, etc.) are built. Finally, the image is packaged according to the dependency tree.

[0093] However, although the above method of the local cache mechanism solves the problem of slow system image building to a certain extent, this mechanism is limited by the space size and processing speed of the local host. That is, if the space of the local host is small and the processing speed is slow, the system image building speed will still be slow.

[0094] In response to this, a distributed shared cache is added in the embodiments of the present application, which can transfer the local cache pressure to the entire distributed network and increase the upper limit of the cache mechanism. Among them, the above distributed shared cache can be a cache in a distributed file system composed of multiple machines. After each machine generates a system image, the files involved in the process of generating the system image can be uploaded to the distributed shared cache, so that when other machines generate the same system image, they can directly use the files stored in the distributed shared cache for building, thus realizing the sharing of compilation results.

[0095] Therefore, after the execution subject of the embodiments of the present application determines the target file required to build the system image of the target system, it can determine whether the above target file exists in the preset distributed shared cache, and in the case of determining that the target file exists in the distributed shared cache, obtain the target file from the distributed shared cache to build the system image of the target system based on the target file.

[0096] In one embodiment, to facilitate determining whether all target files required for building a system image exist in the distributed shared cache, when the distributed shared cache receives a compilation file generated for building a system image, a dependency tree of the compilation file may be generated and stored. Based on this, when the execution entity of the embodiment of the present application determines whether target files of a target system exist in the distributed shared cache, a file dependency tree of the target files may be generated, and the file dependency tree may be matched with the dependency tree stored in the distributed shared cache, so as to determine whether the target files corresponding to the target system exist in the distributed shared cache according to the matching result.

[0097] As an exemplary implementation manner, it can be known from the description in step 101 that before building a system image of a target system, the execution entity of the embodiment of the present application may parse preset system files of the target system to obtain a file structure bitmap of the target system.

[0098] Based on this, the execution entity of the embodiment of the present application may generate a file dependency tree corresponding to the target system according to the file structure bitmap, where the file dependency tree may include the dependency relationship between target files and the file identifier of the target file, and the file identifier may be the file name of the target file or the format identifier of the target file, and the embodiment of the present application does not limit this.

[0099] To facilitate understanding of the file dependency tree, the file dependency tree is illustrated by the following example: Refer to Figure 3 , which is a schematic structural diagram of a file dependency tree provided by the embodiment of the present application. As shown in Figure 3 , the file dependency tree may include multiple bb files of the target system, which may include but are not limited to: Mysql.bb, expat.bb, Krb5.bb, openssl.bb, and xxx.bb, etc. Among them, Mysql.bb is the root node, expat.bb and Krb5.bb are the child nodes of Mysql.bb respectively, openssl.bb is the child node of expat.bb, and xxx.bb is the child node of Krb5.bb.

[0100] After that, the file dependency tree may be matched with multiple preset file dependency trees stored in the distributed shared cache.

[0101] Optionally, if a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, it may be determined that target files exist in the distributed shared cache.

[0102] Furthermore, the file dependency tree further includes a hash value corresponding to each target file. For example Figure 3The root node Mysql.bb also includes the corresponding source code and patch hash values. Based on this, when matching the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache, the file dependency tree can be matched with the multiple preset file dependency trees stored in the distributed shared cache according to the hash value corresponding to each target file included in the file dependency tree.

[0103] Specifically, for each preset file dependency tree stored in the distributed shared cache, each hash value included in the file dependency tree can be compared with the hash value of the file with the same file identifier and the same corresponding dependency relationship in the preset file dependency tree, and the comparison result of each file included in the preset file dependency tree can be obtained.

[0104] After that, it can be determined whether the comparison result of each file included in each preset file dependency tree all indicates that the two compared hash values are the same.

[0105] Optionally, if it is determined that there is a preset file dependency tree in which the comparison result of each file included all indicates that the two compared hash values are the same, it is determined that a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, and this preset file dependency tree is determined as the target file dependency tree.

[0106] On the contrary, if it is determined that there is no preset file dependency tree in which the comparison result of each file included all indicates that the two compared hash values are the same, it can be determined that a target file dependency tree identical to the file dependency tree is not matched from the multiple preset file dependency trees.

[0107] At this time, if the target file dependency tree is not matched from the distributed shared cache, the system image of the target system can be directly built through the source code.

[0108] The technical solution provided by the embodiments of the present application determines the target system, determines the target files required to build the system image of the target system, and when it is determined that there are target files in the preset distributed shared cache, obtains the target files from the distributed shared cache, and builds the system image of the target system based on the target files. This technical solution builds the system image by using the target files generated by other machines building the system image pre-cached in the distributed shared cache, avoiding the technical problem in the prior art that directly generating the target files required to build the system image results in a slow speed of building the system image, thereby achieving the improvement of the building speed of the system image, accelerating the development progress of the system, and enhancing the user experience.

[0109] See Figure 4 , which is the flowchart of the embodiment of another method for building a system image provided by the embodiments of the present application. As Figure 4 shown, this process may include the following steps:

[0110] Step 401: Determine the target system and determine the target files required to build the system image of the target system.

[0111] For a detailed description of Step 401, refer to the description in Step 101, which will not be repeated here.

[0112] Step 402: Determine whether the target files exist in the local cache. If they exist, execute Step 403; if not, execute Step 405.

[0113] Step 403: Obtain the target files from the local cache.

[0114] Step 404: Build the system image of the target system based on the target files obtained from the local cache.

[0115] The following is a unified description of Step 403 and Step 404:

[0116] The above-mentioned local cache refers to the cache of the terminal where the execution entity of the embodiment of the present application is located. When the execution entity of the embodiment of the present application obtains files from the local cache, it does not need to obtain them through the network.

[0117] In practical applications, there may be machines with a large cache space and a fast processing speed. For such machines, obtaining the target files of the target system from the local cache is faster and more convenient than obtaining the target files from the distributed shared cache through the network.

[0118] Based on this, when the execution entity of the embodiment of the present application obtains the target files required to build the system image of the target system, it can first determine whether the target files exist in the local cache.

[0119] Optionally, if the target files exist in the local cache, the target files can be obtained from the local cache, and the system image of the target system can be directly built based on the target files obtained from the local cache.

[0120] On the contrary, if the target files do not exist in the local cache, Step 405 can be continued to be executed.

[0121] Step 405: Determine whether the target files exist in the distributed shared cache. If so, execute Step 406; if not, execute Step 407.

[0122] Step 406: Obtain the target files from the distributed shared cache and build the system image of the target system based on the target files.

[0123] For a detailed description of Step 405 and Step 406, refer to the descriptions in Step 102 and Step 103, which will not be repeated here.

[0124] Step 407: Build the system image of the target system through a preset compilation tool.

[0125] Step 408: Obtain multiple compilation files generated by the compilation tool during the process of building the system image.

[0126] Step 409: Build the dependency tree corresponding to the multiple compilation files and store the dependency tree in the distributed shared cache.

[0127] The following is a unified description of Steps 407 to 409:

[0128] The above-mentioned compilation tool refers to a tool used to generate the system image of the target system, such as the Yocto tool.

[0129] In the embodiments of the present application, when it is determined that the target files required for building the system image of the target system do not exist in both the local cache and the distributed shared cache, the execution entity of the embodiments of the present application can directly build the system image of the target system through the compilation tool. Here, when building the system image through the compilation tool, it can be directly built from the source code, and the required target files need to be generated during the building process.

[0130] After that, the compilation files generated by the compilation tool during the process of building the system image can be obtained. Here, the compilation files refer to the target files required for the target system to build the system image.

[0131] After that, the dependency tree corresponding to the above-mentioned multiple compilation files can be built and the dependency tree can be stored in the distributed shared cache, so that when other terminals generate the system image of the target system, they can directly obtain the required target files from the distributed shared cache.

[0132] For example, see Figure 5 , which is a flowchart of an embodiment of another method for building a system image provided by the embodiments of the present application. As Figure 5 shown, the execution entity of the embodiments of the present application first generates the file dependency tree of the target system.

[0133] After that, according to the structure of the tree, the root node is the package to be built (organized in.bb files), and the child nodes are its dependencies. Each node contains the hash values of the source code, patches, bb files, and config files. The Bitbake engine first generates a dependency tree locally before building, and then compares the dependency tree with the network shared cache during the building process. If the match is successful, the Bitbake engine obtains the pre-built packages (in the form of rpm and deb, etc.) through the network shared cache. If the match fails, it builds from the local source code and builds binary packages (in the form of rpm and deb, etc.) to update the shared cache, and finally completes the image packaging according to the dependency tree.

[0134] The technical solution provided by the embodiment of the present application determines the target system, determines the target files required to build the system image of the target system, determines whether the target files exist in the local cache. If they exist, the target files are obtained from the local cache, and the system image of the target system is built according to the target files obtained from the local cache. If they do not exist, it is determined whether the target files exist in the distributed shared cache. If so, the target files are obtained from the distributed shared cache, and the system image of the target system is built based on the target files. If not, the system image of the target system is built through a preset compilation tool, multiple compilation files generated by the compilation tool during the process of building the system image are obtained, a dependency tree corresponding to the multiple compilation files is built, and the dependency tree is stored in the distributed shared cache. This technical solution proposes a distributed shared cache mechanism on the basis of the local cache, transfers the local cache pressure to the entire distributed network, and improves the upper limit of the cache mechanism. In other words, it reduces the hardware requirements of the host, improves the building speed of the system image, speeds up the system development progress, and enhances the user experience.

[0135] See Figure 6 , which is a block diagram of an embodiment of a device for building a system image provided by an embodiment of the present application. As Figure 6 shown, the device may include:

[0136] A determination module 61, configured to determine a target system and determine target files required to build a system image of the target system;

[0137] An acquisition module 62, configured to obtain the target files from the distributed shared cache when it is determined that the target files exist in the preset distributed shared cache;

[0138] A construction module 63, configured to build a system image of the target system based on the target files.

[0139] As a possible implementation manner, the determination module 61 includes:

[0140] A parsing sub-module, configured to parse a preset system file of the target system to obtain a file structure bitmap required to build a system image of the target system;

[0141] A first determination sub-module, configured to determine files corresponding to file identifiers included in the file structure bitmap as target files required to build a system image of the target system.

[0142] As a possible implementation manner, the acquisition module 62 includes:

[0143] A generation sub-module, configured to generate a file dependency tree corresponding to the target system according to the file structure bitmap, where the file dependency tree includes the dependency relationships between the target files and the file identifiers of the target files;

[0144] A matching sub-module, configured to match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache;

[0145] A second determination sub-module, configured to determine that the target file exists in the distributed shared cache if a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

[0146] As a possible implementation, the file dependency tree further includes a hash value corresponding to each target file, and the matching sub-module includes:

[0147] A matching unit, configured to match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash values corresponding to each target file included in the file dependency tree.

[0148] As a possible implementation, the matching unit is specifically configured to:

[0149] For each preset file dependency tree stored in the distributed shared cache, compare each hash value included in the file dependency tree with the hash values of the files with the same file identifier and the same corresponding dependency relationship in the preset file dependency tree, to obtain a comparison result for each file included in the preset file dependency tree;

[0150] Determine whether the comparison results for each file included in each preset file dependency tree all indicate that the two compared hash values are consistent;

[0151] If it is determined that there is a preset file dependency tree for which the comparison results for each file included all indicate that the two compared hash values are consistent, determine that a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, and determine this preset file dependency tree as the target file dependency tree;

[0152] If it is determined that there is no preset file dependency tree for which the comparison results for each file included all indicate that the two compared hash values are consistent, determine that no target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

[0153] As a possible implementation, the apparatus further includes (not shown in the figure):

[0154] A second determination module, configured to determine whether the target file exists in the local cache before determining that the target file exists in the distributed shared cache;

[0155] An execution module, configured to execute the step of determining that the target file exists in the preset distributed shared cache if it is determined that the target file does not exist in the local cache;

[0156] A target acquisition module, configured to, if it is determined that the target file exists in the local cache, acquire the target file from the local cache, and construct a system image of the target system according to the target file acquired from the local cache.

[0157] As a possible implementation manner, the apparatus further includes (not shown in the figure):

[0158] An image construction module, configured to construct a system image of the target system through a preset compilation tool when it is determined that the target file does not exist in both the local cache and the distributed shared cache;

[0159] A file acquisition module, configured to acquire a plurality of compilation files generated by the compilation tool during the process of constructing the system image;

[0160] A storage module, configured to construct a dependency tree corresponding to the plurality of compilation files and store the dependency tree in the distributed shared cache.

[0161] As Figure 7 shown, a schematic structural diagram of an electronic device provided in an embodiment of the present application includes a processor 71, a communication interface 72, a memory 73, and a communication bus 74. Among them, the processor 71, the communication interface 72, and the memory 73 complete communication with each other through the communication bus 74.

[0162] The memory 73 is configured to store a computer program;

[0163] In an embodiment of the present application, when the processor 71 is configured to execute the program stored on the memory 73, it implements the method for constructing a system image provided in any one of the foregoing method embodiments, including:

[0164] Determine a target system and determine a target file required to construct a system image of the target system;

[0165] When it is determined that the target file exists in the preset distributed shared cache, acquire the target file from the distributed shared cache;

[0166] Based on the target file, construct a system image of the target system.

[0167] An embodiment of the present application further provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for constructing a system image provided in any of the foregoing method embodiments are implemented.

[0168] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0169] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the related technology, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0170] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" as used herein may also include the plural forms. The terms "comprising", "including", "containing", and "having" are inclusive and thus specify the presence of the stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring them to be executed in the particular order described or illustrated, unless the execution order is explicitly stated. It should also be understood that additional or alternative steps can be used.

[0171] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for constructing a system image, characterized in that The method includes: Determine a target system and determine target files required for building a system image of the target system; When it is determined that the target files exist in a preset distributed shared cache, obtain the target files from the distributed shared cache; Based on the target files, build a system image of the target system.

2. The method according to claim 1, wherein The determining of the target files required for building a system image of the target system includes: Parse preset system files of the target system to obtain a file structure bitmap required for building a system image of the target system; Determine files corresponding to file identifiers included in the file structure bitmap as target files required for building a system image of the target system.

3. The method according to claim 2, wherein The determining that the target files exist in the preset distributed shared cache includes: Generate a file dependency tree corresponding to the target system according to the file structure bitmap, where the file dependency tree includes dependency relationships between the target files and file identifiers of the target files; Match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache; If a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, determine that the target files exist in the distributed shared cache.

4. The method according to claim 3, wherein The file dependency tree further includes a hash value corresponding to each of the target files, and the matching of the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache includes: Match the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash value corresponding to each target file included in the file dependency tree.

5. The method according to claim 4, characterized in that The matching of the file dependency tree with multiple preset file dependency trees stored in the distributed shared cache according to the hash value corresponding to each target file included in the file dependency tree includes: For each preset file dependency tree stored in the distributed shared cache, compare the hash value included in the file dependency tree with the hash value of a file having the same file identifier and the same corresponding dependency relationship in the preset file dependency tree to obtain a comparison result for each file included in the preset file dependency tree; Determine whether the comparison result for each file included in each preset file dependency tree indicates that the two compared hash values are consistent; If it is determined that there is a preset file dependency tree for which the comparison result for each file included indicates that the two compared hash values are consistent, determine that a target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees, and determine this preset file dependency tree as the target file dependency tree; If it is determined that there is no preset file dependency tree for which the comparison result for each file included indicates that the two compared hash values are consistent, determine that no target file dependency tree identical to the file dependency tree is matched from the multiple preset file dependency trees.

6. The method according to claim 1, characterized in that, Before determining that the target files exist in the distributed shared cache, the method further includes: Determine whether the target files exist in a local cache; If it is determined that the target file does not exist in the local cache, then perform the step of determining that the target file exists in the preset distributed shared cache; If it is determined that the target file exists in the local cache, then obtain the target file from the local cache, and construct a system image of the target system based on the target file obtained from the local cache.

7. The method according to claim 6, characterized in that, The method further includes: In the case where it is determined that the target file does not exist in both the local cache and the distributed shared cache, construct a system image of the target system through a preset compilation tool; Obtain a plurality of compilation files generated by the compilation tool during the process of constructing the system image; Construct a dependency tree corresponding to the plurality of compilation files, and store the dependency tree in the distributed shared cache.

8. A system image building device, characterized in that, The apparatus includes: A determination module, configured to determine a target system and determine a target file required for constructing a system image of the target system; An obtaining module, configured to obtain the target file from the distributed shared cache when it is determined that the target file exists in the preset distributed shared cache; A construction module, configured to construct a system image of the target system based on the target file.

9. An electronic device, characterized in that, Including: A processor and a memory, where the processor is configured to execute a system image construction program stored in the memory to implement the system image construction method according to any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the system image construction method according to any one of claims 1 to 7.