System dependency package conflict detection method and deviceTechnical Field
The invention relates to the technical field of computers, in particular to a system dependence package conflict detection method and device.
Background
At present, when a program in a big data platform such as an enterprise system runs, the program is composed of functions realized by different dependency packages.
In the process that the enterprise system continuously releases updates, when full-scale updates are needed from time to time, the built dependency packages (star, jar files) are included, and at this time, the dependency packages of the new version and the old version are identical in name, so that dependency package conflicts occur, and the problem that the enterprise system cannot be started or cannot be used normally is caused.
Accordingly, the prior art is yet to be improved and developed.
Disclosure of Invention
In view of the above deficiencies of the prior art, an object of the present invention is to provide a method and an apparatus for detecting system dependency package conflicts, which are intended to solve the problem that in the process of continuously releasing updates by an enterprise system in the prior art, when a full upgrade is sometimes required, including a built dependency package (jar file), at this time, a dependency package conflict occurs between a new version of the dependency package and an old version of the dependency package due to the same name, so that the enterprise system cannot be started or cannot be normally used.
The technical scheme of the invention is as follows:
a system-dependent packet collision detection method, the method comprising:
acquiring a dependent package directory of an application package, and searching all dependent package file lists under the dependent package directory;
traversing the file list, and decompressing each dependent packet file in sequence;
when the decompressed file elements are detected to be files, the package names of the current class are obtained, the package names are added to a list, and a dictionary relation related to the file names and the package names is set, wherein the list is used for storing the package names of the decompressed file elements;
when all dependent package files are traversed, generating a complete dictionary with associated file names and package names;
acquiring the package name of each file in the dictionary, and detecting the same package name;
and if the same package name is detected, prompting the conflict of the dependent package.
Optionally, the obtaining the dependent package directory of the application package, and before searching all the dependent package file lists under the dependent package directory, includes:
decompressing the application program package to obtain the directory data of the dependency package;
acquiring a code execution file, and placing the code execution file in a dependency package directory;
the code execution file is run.
Optionally, after searching all the dependent package file lists in the dependent package directory, the method further includes:
a list of ignore package names to ignore is set.
Optionally, after the setting of the list of package names to be ignored, the method further includes:
and setting an empty dictionary, wherein the dictionary is used for storing the mapping relation between the file name and the package name.
Optionally, after sequentially decompressing each dependent packet file, the traversing the file list further includes:
an empty package name list is set for each dependent package file, and the package name list is used for storing all the different package names in the dependent packages.
Optionally, if the same package name is detected, after prompting the dependent package conflict, the method further includes:
and outputting the intersection of the dependent package file name and all the same package names, and storing the intersection of all the same package names into a package name list.
Optionally, when it is detected that the decompressed file element is a file, acquiring a package name of the current class, adding the package name to the list, and setting a dictionary relationship between the file name and the package name, including:
when the decompressed file element is detected to be a file, acquiring a package name of the current class, and judging whether the package name is added to the list or not;
if the packet name is added to the list, skipping the current file, and acquiring a next decompressed file element for judgment;
if the packet name is not added to the list, judging whether the packet name is in the neglected packet name list, if so, skipping the current file, and acquiring the next decompressed file element for judgment; if the package name is not in the ignore package name list, the package name is added to the package name list, and the dictionary relationship of the association of the file name and the package name is set.
Another embodiment of the present invention provides a system dependent packet collision detection apparatus, comprising at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the system dependent packet collision detection method described above.
Yet another embodiment of the present invention provides a non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the system-dependent packet collision detection method described above.
Another embodiment of the present invention provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a processor, cause the processor to perform the above-described system-dependent packet collision detection method.
Has the advantages that: compared with the prior art, the embodiment of the invention realizes the system dependent packet conflict detection by detecting the same packet name, provides convenience for subsequent users to process conflict dependent packets, and avoids the system from being incapable of normal use caused by dependent packet conflict on the whole online system.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flow chart of a system dependent packet collision detection method according to a preferred embodiment of the present invention;
FIG. 2 is a diagram illustrating a hardware structure of a system dependent packet collision detection apparatus according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is described in further detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The following describes embodiments of the present invention in detail with reference to the accompanying drawings.
The embodiment of the invention provides a system dependent packet collision detection method. Referring to fig. 1, fig. 1 is a flow chart of a system dependent packet collision detection method according to a preferred embodiment of the invention. As shown in fig. 1, it includes the steps of:
s100, acquiring a dependent package directory of an application package, and searching all dependent package file lists under the dependent package directory;
s200, traversing a file list, and decompressing each dependent packet file in sequence;
step S300, when the decompressed file elements are detected to be files, acquiring package names of the current class, adding the package names to a list, and setting a dictionary relationship between the file names and the package names, wherein the list is used for storing the package names of the decompressed file elements;
s400, when all the dependent package files are traversed, generating a complete file name and package name associated dictionary;
s500, acquiring a package name of each file in the dictionary, and detecting the same package name;
and step S600, if the same package name is detected, prompting a dependent package conflict.
When the method is specifically implemented, firstly, a dependent package directory corresponding to an application program is obtained, and all dependent package file lists under the current dependent package directory are searched; the dependency package file list is a compressed file package of suffix files. Traversing the file list, decompressing each file in sequence, judging each decompressed file element, and if the file element is a file, acquiring the packet name of the current class; judging whether the file name is added and is not in the neglected package name list, if so, adding the file name and the package name, and setting a dictionary relation related to the file name and the package name; otherwise, skipping; after traversing all files, generating a complete dictionary with associated file names and package names; and comparing the package names under each file in the dictionary pairwise, and if the same package name exists, indicating conflict.
The embodiment of the invention solves the problem of the conflict of the dependent packages by detecting whether all the dependent packages of the system contain the same package name (package) or not, because different dependent packages do not have the same package name. The system dependency package conflict detection is realized by detecting the same package name, convenience is provided for subsequent users to process conflict dependency packages, and the problem that the system cannot be normally used due to the fact that the system is on line in the whole quantity and the conflict of the dependency packages is caused is avoided.
In a further embodiment, obtaining a dependent package directory of an application package, and searching all the dependent package file lists under the dependent package directory comprises:
decompressing the application program package to obtain the directory data of the dependency package;
acquiring a code execution file, and placing the code execution file in a dependency package directory;
the code execution file is run.
In specific implementation, the execution file may be a Python execution file. Decompressing the application program file packet, and setting the Python execution file in a dependency packet directory; the Python execution file is run. The dependency package directory is typically a lib directory. There are two kinds of libs, one is a static library, such as a C-Runtime library, and the lib has implementation codes of functions, which are generally used in static build, and the implementation codes in the lib are added into an object module (EXE or DLL) file. The LIB is used with the DLL, codes are not arranged in the DLL, the LIB is used on the static calling DLL, and therefore the LIB plays a role in linking. The application may store a sub-dependency package, also called a dependency package. The method is realized by python, and is light and practical.
Further, after searching all the dependent package file lists in the dependent package directory, the method further includes:
a list of ignore package names to ignore is set.
In specific implementation, some package name lists in development need to be ignored, namely, a META-INF list is not searched. Since the java class file can be directly used for running the program in general development, but the method is not convenient, so that the jar file appears for providing release and running, the jar file is actually a zip compressed archive of the class file, and a plurality of tools can manipulate the file in the format, so that the jar file cannot express the memo information of the application program. META-INF is equivalent to a packet, and files and directories in the directory obtain the approval and interpretation of the Java 2 platform, are used for configuring application programs, extension programs, class loaders and service management. jar files have a default generated META-INF directory and a manifest.
Further, after the list of package names to be ignored is set, the method further includes:
and setting an empty dictionary, wherein the dictionary is used for storing the mapping relation between the file name and the package name.
In specific implementation, when the same package name is detected by the dictionary, the corresponding file name can be quickly acquired.
Further, traversing the file list, and after sequentially decompressing each dependent packet file, further comprising:
an empty package name list is set for each dependent package file, and the package name list is used for storing all the different package names in the dependent packages.
During specific implementation, an empty list is set for each file to store all non-unique package names in the dependency package, so that the conflict dependency package is conveniently output, and convenience is provided for user processing.
In a further embodiment, if the same package name is detected, after prompting the dependent package conflict, the method further includes:
and outputting the intersection of the dependent package file name and all the same package names, and storing the intersection of all the same package names into a package name list.
In specific implementation, if the same package name exists, a conflict is represented, and the intersection of the dependent file name and all the same package names is output in case of conflict. If the user needs to process the dependent packages with the same package name, the files corresponding to the stored package names in the package name list are directly processed without searching one by one, and the processing time is saved.
Further, when it is detected that the decompressed file element is a file, acquiring a package name of the current class, adding the package name to the list, and setting a dictionary relationship between the file name and the package name, including:
when the decompressed file element is detected to be a file, acquiring a package name of the current class, and judging whether the package name is added to the list or not;
if the packet name is added to the list, skipping the current file, and acquiring a next decompressed file element for judgment;
if the packet name is not added to the list, judging whether the packet name is in the neglected packet name list, if so, skipping the current file, and acquiring the next decompressed file element for judgment; if the package name is not in the ignore package name list, the package name is added to the package name list, and the dictionary relationship of the association of the file name and the package name is set.
In particular implementations, the file elements include files and directories. Judging each decompressed file element, if the decompressed file element is a file, acquiring a current class full package name, judging whether the decompressed file element is not added to a package name list and is not in an neglected package name list, if the decompressed file element is a file, adding the decompressed file element, setting the relation between the file name and the package name dictionary, if the decompressed file element is added to the package name list and/or in the neglected package name list, skipping, continuously detecting whether the next file element is a file, and if the decompressed file element is a directory, not executing any operation.
It should be noted that, in the foregoing embodiments, a certain order does not necessarily exist among the steps, and it can be understood by those skilled in the art according to the description of the embodiments of the present invention that, in different embodiments, the steps may have different execution orders, that is, may be executed in parallel, may also be executed in an exchange manner, and the like.
Another embodiment of the present invention provides a system dependent packet collision detection apparatus, as shown in fig. 2, theapparatus 10 includes:
one ormore processors 110 and amemory 120, where oneprocessor 110 is illustrated in fig. 2, theprocessor 110 and thememory 120 may be connected by a bus or other means, and the connection by the bus is illustrated in fig. 2.
Processor 110 is used to implement various control logic forapparatus 10, which may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), a single chip microcomputer, an ARM (Acorn RISCMache) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Also, theprocessor 110 may be any conventional processor, microprocessor, or state machine.Processor 110 may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
Thememory 120 is a non-volatile computer-readable storage medium, and can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions corresponding to the system dependent packet collision detection method in the embodiment of the present invention. Theprocessor 110 executes various functional applications and data processing of theapparatus 10 by executing nonvolatile software programs, instructions and units stored in thememory 120, namely, implements the system-dependent packet collision detection method in the above method embodiment.
Thememory 120 may include a storage program area and a storage data area, wherein the storage program area may store an application program required for operating the device, at least one function; the storage data area may store data created according to the use of thedevice 10, and the like. Further, thememory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments,memory 120 optionally includes memory located remotely fromprocessor 110, which may be connected todevice 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more units are stored in thememory 120, which when executed by the one ormore processors 110, perform the system-dependent packet collision detection method in any of the method embodiments described above, e.g., performing the method steps S100-S600 in fig. 1 described above.
Embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer-executable instructions for execution by one or more processors, for example, to perform method steps S100-S600 in fig. 1 described above.
By way of example, non-volatile storage media can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, RAM is available in many forms such as Synchronous RAM (SRAM), dynamic RAM, (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The disclosed memory components or memory of the operating environment described herein are intended to comprise one or more of these and/or any other suitable types of memory.
Another embodiment of the present invention provides a computer program product comprising a computer program stored on a non-volatile computer-readable storage medium, the computer program comprising program instructions which, when executed by a processor, cause the processor to perform the system dependent packet collision detection method of the above-described method embodiment. For example, the method steps S100 to S600 in fig. 1 described above are performed.
The above-described embodiments are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that the embodiments may be implemented by software plus a general hardware platform, and may also be implemented by hardware. Based on such understanding, the above technical solutions essentially or contributing to the related art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of the various embodiments or some parts of the embodiments.
Conditional language such as "can," "might," or "may" is generally intended to convey that a particular embodiment can include (yet other embodiments do not include) particular features, elements, and/or operations, among others, unless specifically stated otherwise or otherwise understood within the context as used. Thus, such conditional language is also generally intended to imply that features, elements, and/or operations are in any way required for one or more embodiments or that one or more embodiments must include logic for deciding, with or without input or prompting, whether such features, elements, and/or operations are included or are to be performed in any particular embodiment.
What has been described herein in the specification and drawings includes examples that can provide a system dependent packet collision detection method and apparatus. It will, of course, not be possible to describe every conceivable combination of components and/or methodologies for purposes of describing the various features of the disclosure, but it can be appreciated that many further combinations and permutations of the disclosed features are possible. It is therefore evident that various modifications can be made to the disclosure without departing from the scope or spirit thereof. In addition, or in the alternative, other embodiments of the disclosure may be apparent from consideration of the specification and drawings and from practice of the disclosure as presented herein. It is intended that the examples set forth in this specification and the drawings be considered in all respects as illustrative and not restrictive. Although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.