Method, device, equipment and product for realizing nested installation of software package
By backing up the state file directory and temporarily modifying the singleton lock file name, this paper solves the installation error during nested installation in the Debian package management system, ensuring the smooth completion of the sub-package installation and the consistency of the parent package's state file.
Patent Information
- Application Number
- CN202510752854.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2025-09-12
AI Technical Summary
In the Debian package management system, nested installation of subpackages can cause installation errors because the singleton lock file is occupied by the parent package. Furthermore, subpackages modifying the status file directory can cause installation failure of the parent package.
Back up the parent package's state file directory and temporarily modify the singleton lock file name, start the child package installation process, and restore the state file directory and lock file name after the installation is complete to ensure installation consistency.
This fixes the issue of sub-package installation process being blocked due to lock file mutual exclusion during nested installations, ensuring smooth installation of the parent package and consistent state file directories.
Smart Images

Figure CN120631385A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software package installation, and in particular relates to a method, apparatus, device and product for implementing nested installation of software packages. Background Art
[0002] When deploying patches or components, current Debian-based package management systems usually use the apt tool or dpkg tool to complete the software package installation task. These tools maintain a singleton lock when performing software package installation to prevent concurrent operations of multiple processes, which may lead to package status conflicts. At the same time, the dpkg tool also records the intermediate status files of the software package installation through the status file directory during the installation process to track the installation progress and status. However, when performing a nested installation of a parent software package that contains several sub-software packages, the singleton lock file has been occupied by the installation process of the parent software package. Therefore, the nested sub-software packages will directly report an error and cannot be installed. Furthermore, since the status file directory will be modified during the installation of the sub-software package, there is also a problem that modifying the status file directory will cause the installation process of the parent software package to report an error, and ultimately the nested installation of the entire software package will fail. Summary of the Invention
[0003] In view of this, the present invention aims to overcome the defects in the prior art and proposes a method, apparatus, device and product for implementing nested installation of software packages.
[0004] In a first aspect, the present invention discloses a method for implementing nested installation of software packages, which is applied to installing a parent software package containing a plurality of sub-software packages, comprising: starting the parent software package installation process, backing up the generated first state file directory, and modifying the original file name of the corresponding singleton lock to a temporary file name;
[0005] Start the sub-package installation process and generate the corresponding second-state file directory. When the sub-package is installed, overwrite the second-state file directory with the backed-up first-state file directory and modify the temporary file name of the singleton lock back to the original file name.
[0006] In one embodiment of the present invention, starting the parent software package installation process is to use the dpkg tool for installation.
[0007] In one embodiment of the present invention, the startup sub-software package installation process is installed using the dpkg tool.
[0008] In one embodiment of the present invention, backing up the generated first-state file directory includes: copying the first-state file directory to a predetermined buffer area.
[0009] In one embodiment of the present invention, the method further includes: backing up the first state file directory and modifying the original file name of the singleton lock to a temporary file name simultaneously.
[0010] In one embodiment of the present invention, starting the sub-software package installation process and generating the corresponding second-state file directory includes: resetting the first-state file directory to the second-state file directory during the sub-software package installation process.
[0011] In a second aspect, the present invention discloses a device for implementing nested installation of a software package, the device comprising:
[0012] A setting module is used to install a parent software package containing several sub-software packages, including: starting the parent software package installation process, backing up the generated first state file directory, and changing the original file name of the corresponding singleton lock to a temporary file name;
[0013] The recovery module is used to start the sub-package installation process and generate the corresponding second-state file directory. When the sub-package is installed, the second-state file directory is overwritten with the backed-up first-state file directory, and the temporary file name of the singleton lock is modified back to the original file name.
[0014] In a third aspect, the present invention discloses an electronic device comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0015] In a fourth aspect, the present invention discloses a computer-readable storage medium having a computer program stored thereon, which implements the above method when executed by a processor.
[0016] In a fifth aspect, the present invention discloses a computer program product, comprising a computer program, which implements the above method when executed by a processor.
[0017] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0018] The present invention discloses a method, apparatus, device and product for realizing nested installation of software packages, comprising: being applied to installing a parent software package containing a plurality of sub-software packages, starting the parent software package installation process, backing up the generated first-state file directory, and modifying the original file name of the corresponding singleton lock to a temporary file name; starting the sub-software package installation process, generating the corresponding second-state file directory, and after the sub-software package is installed, overwriting the second-state file directory with the backed-up first-state file directory, and modifying the temporary file name of the singleton lock back to the original file name. The method, apparatus, device and product for realizing nested installation of software packages disclosed by the present invention solve the problem of blocking the sub-software package installation process due to mutual exclusion of lock files during nested installation by temporarily releasing lock occupation, and at the same time, by backing up the generated first-state file directory and restoring it, ensures the consistency of the state file directory after the sub-software package is installed, so that the installation of the entire parent software package is successfully completed. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0020] In the attached figure:
[0021] Figure 1 A schematic diagram of an application scenario of a method for implementing nested installation of software packages according to an embodiment of the present invention;
[0022] Figure 2 A schematic diagram of a method for implementing nested installation of software packages according to an embodiment of the present invention;
[0023] Figure 3 A schematic flow chart of a method for implementing nested installation of software packages according to an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of a prior art embodiment of a method for implementing nested installation of software packages according to an embodiment of the present invention;
[0025] Figure 5 A schematic diagram of a device for implementing nested installation of software packages according to an embodiment of the present invention;
[0026] Figure 6 The figure is a schematic diagram of an electronic device for implementing nested installation of software packages according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0028] In the description of the present invention, it should be further clarified that the terms "first," "second," etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first," "second," etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.
[0029] The present invention discloses a method, apparatus, device and product for realizing nested installation of software packages. Figure 1 As shown, under existing technical conditions, when performing a nested installation of a parent software package containing several sub-software packages, because the singleton lock file is already occupied by the installation process of the parent software package, the nested sub-software packages will directly report an error during installation and cannot be completed. At the same time, because the status file directory is modified during the installation of the sub-software packages, the installation process of the parent software package will also report an error, resulting in the failure of the nested installation of the entire software package. The present invention discloses a method, apparatus, device and product for implementing nested installation of software packages. By temporarily releasing the lock occupation, the problem of the sub-software package installation process being blocked due to the mutual exclusion of the lock file during nested installation is solved. At the same time, by backing up the generated first status file directory and restoring it, the consistency of the status file directory is ensured after the sub-software packages are installed, so that the installation of the entire parent software package is successfully completed.
[0030] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0031] In one embodiment of the present invention, Figure 2 and Figure 3 As shown, a method for implementing nested installation of software packages includes:
[0032] Step S201 is used to install a parent software package containing several sub-software packages, including:
[0033] Start the parent software package installation process, back up the generated first state file directory, and change the original file name of the corresponding singleton lock to a temporary file name;
[0034] For example, the original file name of the singleton lock file is changed to a temporary file name of lock.bak to avoid failure to complete the sub-package installation process due to the singleton lock file being occupied.
[0035] The parent package installation process and the child package installation process are both started by using the dpkg tool.
[0036] In this embodiment, the parent software package installation process is an outer-layer installation, the child software package installation process is an inner-layer installation, and the inner-layer installation is nested within the outer-layer installation.
[0037] Backing up the generated first state file directory includes: copying the first state file directory to a predetermined buffer area.
[0038] In this embodiment, the first state file directory is represented as / var / lib / dpkg / updates.
[0039] In this embodiment, a status snapshot is created and the / var / lib / dpkg / updates directory is copied to a predetermined cache area, for example: / var / cache / patch / cache / ${package name} / dpkg-status-cache;
[0040] In one embodiment of the present invention, the method further includes: backing up the first state file directory and modifying the original file name of the singleton lock to a temporary file name simultaneously.
[0041] Step S202: Start the sub-package installation process and generate the corresponding second-state file directory. When the sub-package is installed, overwrite the second-state file directory with the backed-up first-state file directory and modify the temporary file name of the singleton lock back to the original file name.
[0042] Exemplarily, the installation engine is started to execute the sub-package installation, such as calling the custom script launcher.sh. Since the original file name of the singleton lock file has been modified to the temporary file name lock.bak, the dpkg tool that executes the sub-package installation process can successfully obtain resources.
[0043] Exemplarily, during the sub-software package installation process, the first-state file directory is reset to the second-state file directory.
[0044] Exemplarily, after the sub-software package is installed, the / var / lib / dpkg / updates directory is overwritten with the backed-up first status file directory to restore the status tracking capability of the parent software package installation.
[0045] In this embodiment, a state file snapshot mechanism is used to prevent the inner layer installation from overwriting the key state of the outer layer installation, thereby ensuring the consistency of the state file during the outer layer installation process.
[0046] In this embodiment, the singleton lock file is renamed back to the original file name to ensure normal permission control of subsequent package management operations and enable the smooth completion of the outer layer installation.
[0047] In another embodiment of the present invention, renaming the singleton lock file is performed in the lock isolation module, starting the installation engine to execute the sub-package installation is performed in the installation engine module, and backing up the first state file directory is performed in the state snapshot module.
[0048] In the prior art, when installing a parent software package that includes several sub-software packages, such as Figure 4 As shown, the parent package installation process is represented as the outer installation, and the child package installation process is represented as the inner installation. The outer installation is started to generate the first state file directory. During the outer installation postinst script execution phase, the inner installation is triggered. At this time, the inner installation will clear the first state file directory and reset the second state file directory. The state file directory can be represented as / var / lib / dpkg / updates.
[0049] After the inner layer installation is completed, because the second state file directory read by the outer layer installation is different from the original first state file directory, the outer layer installation reports an error and the nested installation process of the software package cannot be implemented.
[0050] like Figure 5 As shown, the present invention also discloses a device for implementing nested installation of software packages, comprising:
[0051] The setup module 501 is used to install a parent software package containing a plurality of sub-software packages, including: starting the parent software package installation process, backing up the generated first state file directory, and changing the original file name of the corresponding singleton lock to a temporary file name;
[0052] The recovery module 502 is used to start the sub-package installation process and generate the corresponding second-state file directory. When the sub-package is installed, the second-state file directory is overwritten with the backed-up first-state file directory and the temporary file name of the singleton lock is modified back to the original file name.
[0053] The present invention also discloses an electronic device, such as Figure 6 As shown, an embodiment is disclosed, which is a block diagram of the electronic device for implementing nested installation of software packages.
[0054] The electronic device 60 of this embodiment includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the ROM 602 or the program loaded from the storage part 608 into the RAM 603. The processor 601 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a dedicated microprocessor, etc. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present invention.
[0055] RAM 603 stores various programs and data required for the operation of electronic device 60. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 executes the programs in ROM 602 and / or RAM 603 to perform various operations according to the method flow of the embodiment of the present invention. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603, and processor 601 may also execute the programs stored in one or more memories to perform various operations according to the method flow of the embodiment of the present invention.
[0056] According to an embodiment of the present invention, the electronic device 60 may further include an I / O interface 605, which is also connected to the bus 604. The electronic device 60 may further include one or more of the following components connected to the I / O interface 605: an input unit 606 including a keyboard, a mouse, etc.; an output unit 607 including a cathode ray tube, a liquid crystal display, and a speaker; a storage unit 608 including a hard disk; and a communication unit 609 including a network interface card such as a LAN card or a modem. The communication unit 609 performs communication processing via a network such as the Internet. A drive 6010 is also connected to the I / O interface 605 as needed. Removable media 6011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 6010 as needed, so that computer programs read therefrom can be installed into the storage unit 608 as needed.
[0057] The present invention also provides a computer-readable storage medium.
[0058] The computer-readable storage medium may be included in the electronic device / device system described in the above embodiments, or may exist independently and not be incorporated into the electronic device / device. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of the present invention.
[0059] According to embodiments of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples include, but are not limited to, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0060] Embodiments of the present invention also include a computer program product.
[0061] The computer program product includes a computer program, which contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the method provided by the embodiment of the present invention.
[0062] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal over a network medium. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0063] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written by any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages. Programming languages include, but are not limited to, Java, C++, Python, C language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network or a wide area network, or can be connected to an external computing device.
[0064] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of the systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the boxes may occur in an order different from that marked in the accompanying drawings. For example, two boxes shown in succession may actually be executed substantially in parallel, or they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, as well as the combination of boxes in the block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or may be implemented using a combination of dedicated hardware and computer instructions. It will be understood by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways, and all such combinations and / or couplings fall within the scope of the present invention.
[0065] The embodiments of the present invention have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present invention. Although each embodiment has been described above separately, this does not mean that the measures in each embodiment cannot be advantageously used in combination. The scope of the present invention is defined by the appended claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A method for implementing nested installation of software packages, characterized in that: The method is applied to installing a parent software package containing several sub-software packages, including: starting the parent software package installation process, backing up the generated first state file directory, and changing the original file name of the corresponding singleton lock to a temporary file name; The sub-package installation process is started to generate a corresponding second-state file directory. When the sub-package installation is completed, the second-state file directory is overwritten with the backed-up first-state file directory, and the temporary file name of the singleton lock is modified back to the original file name.
2. A method for implementing nested installation of software packages according to claim 1, characterized in that: The parent software package installation process is started by using the dpkg tool for installation.
3. A method for implementing nested installation of software packages according to claim 1, characterized in that: The sub-software package installation process is started by using the dpkg tool for installation.
4. A method for implementing nested installation of software packages according to claim 1, characterized in that: The step of backing up the generated first state file directory includes: copying the first state file directory to a predetermined buffer area.
5. A method for implementing nested installation of software packages according to claim 1, characterized in that: The method further includes: backing up the first state file directory and modifying the original file name of the singleton lock to the temporary file name simultaneously.
6. A method for implementing nested installation of software packages according to claim 1, characterized in that: The starting the sub-software package installation process to generate a corresponding second-state file directory includes: during the sub-software package installation process, resetting the first-state file directory to the second-state file directory.
7. A device for implementing nested installation of software packages, characterized by: The device comprises: A setting module is used to install a parent software package containing several sub-software packages, including: starting the parent software package installation process, backing up the generated first state file directory, and changing the original file name of the corresponding singleton lock to a temporary file name; A recovery module is used to start the sub-package installation process, generate a corresponding second-state file directory, and when the sub-package is installed, overwrite the second-state file directory with the backed-up first-state file directory, and modify the temporary file name of the singleton lock back to the original file name.
8. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.