Method, device and equipment for packaging Firefox on Windows platform and medium
By installing the Mercurial environment tool on the Windows platform and using the Win32 API to control the packaging window, the automated integration problem of Firefox packaging was solved, an efficient automated packaging process was implemented, and human operational errors and costs were reduced.
Patent Information
- Application Number
- CN202510593245.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-09-16
AI Technical Summary
On the Windows platform, the Firefox packaging process lacks automation, resulting in complex and costly operations and an inability to integrate with the GitLab runner, making it difficult to achieve efficient automated packaging.
By installing the Mercurial environment tool, starting the gitlab runner and start-shell.bat, using the Win32 API to find and control the packaging window, sending script instructions and generating log files, monitoring the packaging process, and implementing an automated packaging process.
It realizes the automatic packaging of Firefox on the Windows platform, reduces human errors, improves work efficiency and reduces enterprise costs.
Smart Images

Figure CN120653267A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field, and in particular to a method, apparatus, device and medium for packaging Firefox on a Windows platform. Background Art
[0002] Currently, Firefox packaging isn't fully automated; it requires strict environment and steps. First, packagers must set up the pre-installation Firefox kernel packaging environment, a technically demanding process involving extensive system configuration and dependency installation. Next, the manual phase involves executing a series of commands: First, checkout the target branch to obtain the specified version of code, ensuring the package is based on the correct code baseline. Next, launch the Firefox packaging application, which serves as the platform for packaging operations and is crucial for its stability and functionality. Next, switch your workspace to the target branch's code root directory. The accuracy of this step is crucial for the subsequent packaging process to correctly read the code files. Next, configure the packaging parameters. Different packaging requirements may require numerous adjustments, and even the slightest mistake can lead to packaging failure or an unexpected package. Finally, run the Firefox packaging command, ". / machbuild," which is the core packaging step. This process generates the installation package and other files based on the previously configured code and code. Finally, sign the software to ensure security and authenticity.
[0003] On Windows, Firefox packaging is subject to numerous limitations. It can only be performed in a Mercurial terminal, requiring packagers to be familiar with Mercurial terminal usage and operation logic, which increases labor costs and operational difficulty. Furthermore, it cannot be used with widely used runners such as GitLab and GitHub.
[0004] GitLab Runner only supports cmd and powershell on Windows. Firefox must be packaged in its own tool, making it impossible to directly integrate it into GitLab Runner. Using automated methods opens a new process, separate from the original GitLab Runner, which requires handling inter-process communication. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method, apparatus, device and medium for packaging Firefox on a Windows platform, thereby realizing automated Firefox packaging on a Windows platform and greatly improving work efficiency.
[0006] In a first aspect, the present invention provides a method for packaging Firefox on a Windows platform, comprising the following steps:
[0007] Step 1. Install the environment tool Mercurial on Windows platform;
[0008] Step 2. Start the runner of gitlab and start start-shell.bat;
[0009] Step 3: Set the package.sh file, which is a shell script packaged with Firefox.
[0010] Step 4: Use Win32 API to find the window where the start-shell.bat is running and obtain the corresponding handle;
[0011] Step 5: Use the Win32 API to send a string, sh package.sh, to the handle, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file;
[0012] Step 6: Monitor the contents of the log file. When the package is detected to be successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
[0013] In a second aspect, the present invention provides a device for packaging Firefox on a Windows platform, comprising:
[0014] Install the module and install the environment tool Mercurial on Windows platform;
[0015] Start the module, start the gitlab runner, and start-shell.bat;
[0016] Set up the module and the package.sh file, which is a shell script packaged with Firefox;
[0017] Get the handle module, search the window where the start-shell.bat is running through the Win32 API, and get the corresponding handle;
[0018] Obtain a log module, use the Win32 API to send a string to the handle, the string is shpackage.sh, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file;
[0019] Complete the packaging module and monitor the contents of the log file. When the packaging is successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
[0020] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.
[0021] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the program is executed by a processor.
[0022] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:
[0023] The present invention realizes automatic Firefox packaging under the Windows platform; through the one-key programmed processing of the present invention, errors caused by manual packaging process are reduced, work efficiency is greatly improved, and enterprise costs are reduced.
[0024] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0026] Figure 1 This is a flowchart of the method in Example 1 of the present invention;
[0027] Figure 2 This is a schematic diagram of the structure of the device in Example 2 of the present invention. DETAILED DESCRIPTION
[0028] The embodiments of the present application provide a method, apparatus, device, and medium for packaging Firefox on a Windows platform, thereby achieving automated Firefox packaging on a Windows platform.
[0029] The technical solutions in the embodiments of this application have the following general ideas:
[0030] Step 1. Install Mercurial, the environment tool required for Firefox packaging (this is a prerequisite and only needs to be done once).
[0031] Step 2: When the code branch is master_{major version number} (such as master_136) and there is a git commit, trigger the gitlab runner to run the packaging task.
[0032] On Windows platforms, GitLab Runner can support Firefox packaging. The Firefox packaging can be secondary development of Firefox to package a fingerprint browser based on the Firefox kernel.
[0033] 1: Install Mercurial. By default, it is installed in the C:\mozilla-build directory. Mercurial is an official cross-platform toolkit for Firefox, used to package the Firefox browser.
[0034] 2: Write the Python code that the runner will run:
[0035] 2.1 Use Python to open 'C:\mozilla-build\start-shell.bat'; start-shell.bat is the launcher of the Firefox packaging tool;
[0036] 2.2 We write the Firefox packaging shell script in the package.sh file (the code here is some parameters required by the official Firefox packaging. Note that this shell can only be run in a software started after start-shell.bat is run);
[0037] 2.3 At this time, use win32 API to find a window that appears after running this bat file.
[0038] win32gui.EnumWindows(lambdahwnd,lParam:lParam.append(hwnd),Windows);
[0039] Find the hwnd (handle) of the target window from the Windows list above;
[0040] 2.4 Use the win32 API to send the string "shpackage.sh" to the hwnd and send the enter character to simulate the manual method to trigger the execution of the package script
[0041] text=r'sh package.sh platform Windows&>ci.log&&echo[flag=OK]>ci.log'
[0042] for charintext:
[0043] win32api.SendMessage(hwnd,win32con.WM_CHAR,ord(char),0);
[0044] 2.5 Monitor the contents of the ci.log file above. This log contains logs indicating successful or failed packaging. If [flag=OK] is detected, the packaging process has succeeded and the runner task can be stopped. Otherwise, the monitored content will be printed to the runner's console panel.
[0045] file="ci.log"
[0046] lines = file.readlines()
[0047] forline in lines[last_lines:]:
[0048] print(line)
[0049] if "[flag=OK]" in lines[-1]:
[0050] print(f"\033[92m---success---\033[0m")
[0051] break;
[0052] 2.6 After the task is completed, use the win32 API to close the hwnd window above:
[0053] win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0).
[0054] Example 1
[0055] like Figure 1 As shown, this embodiment provides a method for packaging Firefox on a Windows platform, comprising the following steps:
[0056] Step 1. Install the environment tool Mercurial on Windows platform;
[0057] Step 2. Start the runner of gitlab and start start-shell.bat;
[0058] Step 3: Set the package.sh file, which is a shell script packaged with Firefox.
[0059] Step 4: Use Win32 API to find the window where the start-shell.bat is running and obtain the corresponding handle;
[0060] Step 5: Use the Win32 API to send a string, sh package.sh, to the handle, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file;
[0061] Step 6: Monitor the contents of the log file. When the package is detected to be successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
[0062] In this embodiment, preferably, step 2 specifically includes: triggering the start of the gitlab runner according to the change of the setting file or manually starting the gitlab runner to start start-shell.bat.
[0063] In this embodiment, preferably, step 4 is specifically: searching the window where the start-shell.bat is running through Win32 API:
[0064] win32gui.EnumWindows(lambda hwnd,lParam:lParam.append(hwnd),Windows),
[0065] Get the handle corresponding to the window.
[0066] In this embodiment, preferably, step 6 is specifically as follows: monitoring the content of the log file, and when monitoring that the packaging is successful, stopping the gitlab runner, and using the win32 API to close the window corresponding to the handle, win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0); otherwise, printing the monitored content to the runner's console panel.
[0067] Based on the same inventive concept, this application also provides a device corresponding to the method in Example 1, see Example 2 for details.
[0068] Example 2
[0069] like Figure 2 As shown, in this embodiment, a device for packaging Firefox on a Windows platform is provided, including:
[0070] Install the module and install the environment tool Mercurial on Windows platform;
[0071] Start the module, start the gitlab runner, and start-shell.bat;
[0072] Set up the module and the package.sh file, which is a shell script packaged with Firefox;
[0073] Get the handle module, search the window where the start-shell.bat is running through the Win32 API, and get the corresponding handle;
[0074] Obtain a log module, use the Win32 API to send a string to the handle, the string is shpackage.sh, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file;
[0075] Complete the packaging module and monitor the contents of the log file. When the packaging is successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
[0076] In this embodiment, preferably, the startup module specifically triggers the startup of the gitlab runner according to the change of the setting file or manually starts the gitlab runner to start start-shell.bat.
[0077] In this embodiment, preferably, the handle acquisition module specifically searches for the window where the start-shell.bat is running through Win32 API:
[0078] win32gui.EnumWindows(lambda hwnd,lParam:lParam.append(hwnd),Windows),
[0079] Get the handle corresponding to the window.
[0080] In this embodiment, preferably, the packaging completion module specifically monitors the content of the log file, and when it is monitored that the packaging is successful, stops the gitlab runner, and uses the win32 API to close the window corresponding to the handle, win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0); otherwise, prints the monitored content to the runner's console panel.
[0081] Since the device described in the second embodiment of the present invention is used to implement the method of the first embodiment of the present invention, those skilled in the art will be able to understand the specific structure and variations of the device based on the method described in the first embodiment of the present invention, and therefore will not be described in detail here. All devices used in the method of the first embodiment of the present invention fall within the scope of protection of the present invention.
[0082] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to the first embodiment, see the third embodiment for details.
[0083] Example 3
[0084] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any implementation method in the first embodiment can be implemented.
[0085] Since the electronic device described in this embodiment is the device used to implement the method in Example 1 of this application, based on the method described in Example 1 of this application, those skilled in the art will be able to understand the specific implementation of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection to be provided by this application.
[0086] Based on the same inventive concept, this application provides a storage medium corresponding to Example 1, see Example 4 for details.
[0087] Example 4
[0088] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any implementation method in the first embodiment can be implemented.
[0089] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0090] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0091] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0092] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0093] Although the specific embodiments of the present invention are described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A method for packaging Firefox on a Windows platform, characterized by: The steps include: Step 1. Install the environment tool Mercurial on Windows platform; Step 2. Start the runner of gitlab and start start-shell.bat; Step 3: Set the package.sh file, which is a shell script packaged with Firefox. Step 4: Use Win32 API to find the window where the start-shell.bat is running and obtain the corresponding handle; Step 5: Use the Win32 API to send a string, sh package.sh, to the handle, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file; Step 6: Monitor the contents of the log file. When the package is detected to be successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
2. The method for packaging Firefox on a Windows platform according to claim 1, wherein: Step 2 specifically includes: starting the gitlab runner according to the setting file changes or manually starting the gitlab runner to start start-shell.bat.
3. The method for packaging Firefox on a Windows platform according to claim 1, wherein: The step 4 is specifically: searching the window where the start-shell.bat is running through Win32 API: win32gui.EnumWindows(lambda hwnd,lParam:lParam.append(hwnd),Windows), Get the handle corresponding to the window.
4. The method for packaging Firefox on a Windows platform according to claim 1, wherein: The step 6 specifically includes: monitoring the content of the log file, and when it is detected that the packaging is successful, stopping the gitlab runner, and using the win32 API to close the window corresponding to the handle, win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0); If not, the monitored content will be printed to the runner's console panel.
5. A device for packaging Firefox on a Windows platform, characterized by: include: Install the module and install the environment tool Mercurial on Windows platform; Start the module, start the gitlab runner, and start-shell.bat; Set up the module and the package.sh file, which is a shell script packaged with Firefox; Get the handle module, search the window where the start-shell.bat is running through the Win32 API, and get the corresponding handle; Obtain a log module, use the Win32 API to send a string to the handle, the string is shpackage.sh, and send a carriage return character to trigger the execution of the package.sh file; and generate a corresponding log file; Complete the packaging module and monitor the contents of the log file. When the packaging is successful, stop the gitlab runner and use the win32 API to close the window corresponding to the handle.
6. The device for packaging Firefox on a Windows platform according to claim 5, characterized in that: The startup module specifically starts the gitlab runner according to the change of the setting file or starts the gitlab runner manually to start start-shell.bat.
7. The device for packaging Firefox on a Windows platform according to claim 5, characterized in that: The handle acquisition module specifically searches for the window where the start-shell.bat is running via the Win32 API: win32gui.EnumWindows(lambda hwnd,lParam:lParam.append(hwnd),Windows), Get the handle corresponding to the window.
8. The device for packaging Firefox on a Windows platform according to claim 5, characterized in that: The package completion module specifically monitors the content of the log file, and when it detects that the package is successful, stops the gitlab runner and uses the win32 API to close the window corresponding to the handle, win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0); If not, the monitored content will be printed to the runner's console panel.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.