GNU linux universal application program packaging method and graphical application packerTechnical Field
The invention belongs to the technical field of computers, and particularly relates to a general application program packaging method for GNU linux and a graphical application packer.
Background
The release line versions of the GNU linux are numerous, application packaging modes of all versions are different, the same application program needs to run on different release boards, the packaging party can install and use the application program according to the requirements of each release board, and the packaging of the application program is basically completed through a terminal command line, so that the graphical operability is not realized, the popularization and the use of the application program in the different release line versions of the GNU linux are not facilitated, and the packaging operation of the application program by a novice user is inconvenient.
At present, an application packaging mode which can be operated on release line versions of different GNU linux is AppImage, and the packaging mode needs to be operated through a terminal command line, has no graphical operation interface, and is inconvenient for novice users to use; the application program dependency analysis collection function is not provided, and a user is required to carry out application dependency analysis through other tools so as to complete application packaging; the progress of application degree packaging is not displayed, and as the software package in the AppImage format is generally larger, the packaging time is longer, if the progress is not displayed, the illusion of system blocking is brought to a user; no modification of rpath is provided, and when the packaged application does not depend on the underlying library of the system and needs to rely on the packaged library file, the dependency path needs to be specified, which would otherwise cause the application to fail to run on a different release plate.
Disclosure of Invention
The invention aims to provide a GNU linux universal application program packaging method and a graphical application packaging device, which can solve the problem of application program dependence analysis, can specify a dependence library path, can display the whole packaging process and can perform graphical operation.
In order to achieve the above object, the technical scheme of the present invention is as follows:
a GNU linux universal application program packaging method comprises the following steps:
s1, carrying out static dependency analysis on an application program to be packaged based on an ELF file, displaying a static dependency relationship through a graphical interactive interface, and providing a export interface to export to a catalog of the application program to be packaged;
s2, performing running state dependency analysis on the application program to be packaged by establishing a communication sub-node in a process space, displaying the running state dependency relationship through a graphical interactive interface, and providing an export interface to export to a catalog where the application program to be packaged is located;
s3, completing the rapth path assignment of the application dependent file through the graphical interactive interface;
s4, constructing an interface layer for the squarhfs file, using the inside of the context package, judging the package integrity by checking a symbol table of the generated ELF file, and realizing the real-time display of the package progress on the graphical interactive interface and terminating the package function;
s5, completing information filling in the graphical interaction interface and starting packaging until completion or termination.
Further, the process of static dependency analysis in step S1 includes:
s101, reading an ELF file of an application program to be packaged, capturing the seed information of the ELF file, and obtaining the file name of a directly-dependent dependency library;
s102, acquiring a full path of a dependent library file by inquiring a custom path or a default ld.so.cache of a system based on the name of the dependent library file;
s103, recursively acquiring information of all the dependency libraries of all ELF files in the application program catalogs to be packaged through a breadth-based traversal algorithm, merging library files, performing deduplication by adopting a set, acquiring all the dependency library catalogs, and obtaining all static dependencies of the application programs to be packaged.
Further, the process of the operation state dependency analysis in step S2 includes:
s201, expanding kernel procfs, and establishing a child node which communicates with the outside of the kernel in a process node;
s202, when a dependency library file required by a process is loaded by an out-of-core loader, writing an original and real file information pair of the dependency library file into the child node;
s203, establishing a dependency file tree relation in the running process based on the original and real file information of the dependency library file written into the child node.
Further, the step S4 specifically includes:
s401, in a graphical interactive interface program, constructing an interface layer for a squarhfs file, defining a set of state machine for visual progress and interruptible package cancellation, wherein the method comprises the following steps: creating a context, creating a squarhfs file, acquiring a packaging processing progress, interrupting to cancel packaging, and destroying the context;
s402, packaging the internal state based on the context, and then checking the GLOBAL type variable in the symbol table in the ELF file to make complete packaging judgment, so that re-entry use during multi-threading of the host program is realized, and real-time display of packaging progress is realized.
The invention also provides a graphical application packer universal for GNU linux, which comprises the following components: the system comprises a graphical interaction interface, a static analysis module, a runtime analysis module, a rapth setting module and an application packaging module, wherein the static analysis module, the runtime analysis module, the rapth setting module and the application packaging module are associated with the graphical interaction interface;
static analysis module: based on the ELF file, carrying out static dependency analysis on the application program to be packaged, displaying a static dependency relationship through a graphical interactive interface, and providing a export interface to export to a catalog of the application program to be packaged;
and a runtime analysis module: through establishing a communication sub-node in a process space, running state dependency analysis is carried out on the application program to be packaged, the running state dependency relationship is displayed through a graphical interaction interface, and an export interface is provided for export to a catalog where the application program to be packaged is located;
a rapth setting module: completing the rapth path specification of the application dependent file through the graphical interactive interface;
and (5) an application packaging module: an interface layer is built for the squarfs file, the inside of a context package is used, the integrity of the package is judged by checking a symbol table of the generated ELF file, and the real-time display of the packaging progress on a graphical interactive interface and the packaging terminating function are realized;
graphical interaction interface: and completing information filling and starting packaging in the graphical interactive interface until completing or ending.
Further, the static analysis module includes:
a reading unit: reading an ELF file of an application program to be packaged, capturing the seed information of the ELF file, and obtaining the file name of a directly-dependent dependency library;
query unit: acquiring a full path of a dependent library file by inquiring a custom path or a system default ld.so.cache based on the name of the dependent library file;
traversing the duplicate removal unit: and recursively acquiring information of all the dependency libraries of all ELF files in the application program catalogue to be packaged through a breadth-based traversal algorithm, merging library files, performing deduplication by adopting a set, acquiring all the dependency library catalogue, and acquiring all static dependencies of the application program to be packaged.
Further, the runtime analysis module includes:
a child node establishing unit: expanding the kernel procfs, and establishing a child node which communicates with the outside of the kernel in the process node;
an out-of-core loading unit: when the dependency library file needed by the process is loaded by the out-of-core loader, writing the original and real file information pairs of the dependency library file into the child nodes;
relationship establishment unit: and establishing a dependency file tree relation in the running process based on the original and real file information of the dependency library file written into the child node.
Further, the application packaging module includes:
interface layer unit: an interface layer is built for a squarhfs file, a set of state machines for visual progress and interruptible unpacking is defined, and the method comprises the following steps: creating a context, creating a squarhfs file, acquiring a packaging processing progress, interrupting to cancel packaging, and destroying the context;
reentrant usage unit: based on the encapsulation of the context to the internal state, the encapsulation is completely judged by checking the GLOBAL type variable in the symbol table in the ELF file, and the reentrant use in the multi-thread process of the host program is realized, so that the real-time display of the packing progress is realized.
The invention also provides a computer readable storage medium, wherein the storage medium stores a computer program, and the computer program is used for executing the GNU linux universal application program packaging method.
Compared with the prior art, the invention has the following beneficial effects:
1. the invention can complete the whole process of application program packaging in a graphical interaction mode;
2. the invention can provide a dependency analysis and collection function, directly carry out the static and running state dependency analysis of the application program without other tools, display the dependency relationship through a graphical interaction interface and select the dependency information for export, and finish application packaging;
3. the invention provides rpath setting function, which ensures that the packaged application program can find out correct dependent files after being installed on a target operating system, and the application program can normally run;
4. the invention solves the problem that the squarfs tool mksquashfs can not realize safe call by a host program, and can display the packing process of the squarfs file and the function of stopping the application program packing and rollback in the middle of packing in real time.
Drawings
FIG. 1 is a diagram of a static analysis interface for an application packager graphical interactive interface according to a first embodiment of the present invention;
FIG. 2 is a runtime analysis interface diagram of an application packager graphical interactive interface of a first embodiment of the present invention;
fig. 3 is a real-time display diagram of an application packaging process of an application packager graphical interactive interface according to a first embodiment of the present invention.
Detailed Description
It should be noted that, without conflict, the embodiments of the present invention and features of the embodiments may be combined with each other.
The invention has the design concept that the dependency information of the application program is displayed in a graphical mode and exported to the catalog of the application to be packaged, the rpath path and related application information such as authors, contact ways, application introduction, installation paths, application icons and the like are filled in through an interactive interface, the whole packaging process is displayed in real time, the functions of desktop shortcut, menu display starting, application unloading and the like are integrated, and the GNU linux universal packaging device which can analyze the application program dependency, can assign a dependency library path, display packaging progress and can perform graphical operation is realized.
Embodiment one:
in a first embodiment, a design scheme of a graphical application packer and a packing method thereof are provided.
The graphical application packer comprises a graphical interaction interface, a static analysis module, a runtime analysis module, a rapth setting module and an application packing module, wherein the static analysis module, the runtime analysis module, the rapth setting module and the application packing module are associated with the graphical interaction interface.
1. Dependency analysis:
the application program to be packaged can be in a running state or a static state, so that the interface diagrams of the static analysis module and the running analysis module for generating the dependency information of the application program to be packaged are shown in fig. 1 and 2;
in the static analysis module, for a static state application program to be packaged, acquiring the seed information of an analyzed ELF file by reading the ELF file of the static state application program to be packaged, and acquiring the library file name directly relied on by the file; acquiring a full path of a dependent library file by inquiring a custom path or a system default ld.so.cache based on the library file name; recursively acquiring information of all the dependency libraries through a breadth-wise traversal algorithm, merging library files, performing deduplication by adopting a set, acquiring all file dependency library catalogs, and acquiring all static dependencies of an application program to be packaged; the analysis process of the breadth-wise traversal algorithm is to acquire a dependency library B.so through the A file, and acquire a dependency library C.so of the B.so until no dependency exists; all directories of the ELF file dependency library in the static program directory to be packaged are obtained through the steps; and graphically displaying all the dependency information, each of which can be exported by the export function button.
For a running application program to be packaged, a process dependency file needs to be obtained by reading a process space. However, when the process space loads the dependent file, the file name information of the dependent file is only maintained by open and mmap, but not the "file name" in the dynamic segment of the ELF file corresponding to the process, that is, if the latter is a soft link name, the "real file name" of the dependent file in the process space cannot be corresponding to the dynamic segment of the ELF file, and because of the existence of the non-correspondence, the tree relationship between the process dependent files cannot be obtained accurately. In the running analysis module, a sub-node which can communicate with outside of the core is established in a process node by expanding the procfs of the core, and when a dependency library file required by a process is loaded by an outside-core loader with corresponding functions, the original and real file information pairs of the dependency library file are written into the sub-node, so that the corresponding relation of the dependency file is maintained in a running process space of the corresponding process, and the dependency file tree relation in running is established. By this scheme, on one hand, backward compatibility (all communication is based on extended child nodes) with other cores and out-of-core loaders without the function is maintained; on the other hand, the life cycle of the child node is expanded and is constrained by the life cycle of the process, and the importance is that the complexity of management is reduced by the determined boundary, so that the full life cycle states of creation, work, extinction and the like of each process are ensured to be unchanged from the prior art, and the normal of the whole system is finally ensured. According to the ID information of the application program process to be packaged, a process dictionary table is generated, the dictionary table is converted into a process tree, the upper and lower relationships of the process are analyzed, the process is graphically displayed on a dependency analysis interface, all the dependency information of the process is graphically displayed on each process, and each process dependency information column is provided with a function-leading-out button.
Whether the static analysis module or the operation analysis module, the user can select the dependency information to be contained according to the condition of the operating system of the application target operation, and export the dependency information to the catalog of the application program to be packaged.
2. Specifying rpath path:
the rapth setting module finishes the rapth path assignment of the application dependent file through the graphical interaction interface according to the information such as the dependent library and the like on which the application is required to run, so as to ensure that the packaged application can find the correct dependent file after being installed on the target operating system, and the application can run normally.
3. The application packages and provides real-time progress information:
and finishing information filling and starting packaging. For the squarfs file, the squarfs tool mksquashfs related code is called by a host program, and the root of the problems is that the original design of the mksquashfs is that the application program cannot call to display the packing progress in real time. In order to realize the packaging process of displaying the squarhfs file in real time, the invention constructs a new interface layer in the application packaging module, defines a set of state machine for visual progress and interruptible package cancellation, and comprises the following steps: creating a context, creating a squarhfs file, acquiring a packaging processing progress, interrupting and canceling packaging, destroying the context and the like, packaging the internal state based on the context, and then judging the complete packaging by checking a GLOBAL type variable in a symbol table in an ELF file to realize re-entry use when the host program is multithreaded so as to meet the multithreading requirement, thereby realizing the functions of real-time display of the packaging progress, packaging desktop shortcuts, starting menu display, application unloading and the like, and ending the packaging and rollback of the application program in the middle of packaging. An interface diagram of a real-time display of the application packaging module of the present invention is shown in fig. 3.
Embodiment two:
the second embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are used to perform the packaging method as provided in the first embodiment described above.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The above embodiments are merely preferred embodiments of the present invention and are not intended to limit the present invention, and any modifications, equivalent substitutions, improvements, etc. within the spirit and principle of the present invention should be included in the scope of the present invention.