-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_xpi.bat
69 lines (56 loc) · 1.86 KB
/
make_xpi.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
::Extension short name (no spaces or punctuation)
@set extname=tabkit
::Extension version (left blank as I just want tabkit.xpi, not e.g. tabkit0.5.xpi)
@set version=
::Check mimimum necessary files are present (the script would work without some of them, but their absence suggests a problem with the extension)
@if not exist chrome.manifest goto nochromemanifest
@if not exist xpi goto noxpi
@if not exist xpi\install.rdf goto noinstallrdf
@if not exist xpi\chrome goto nochrome
@if not exist xpi\chrome\content goto nocontent
::Check required tools are available on the Path
for /F %%X in ("xcopy.exe") DO IF "%%~$PATH:X"=="" goto noxcopy
for /F %%X in ("7z.exe") DO IF "%%~$PATH:X"=="" goto no7z
::Cleanup things that might get in the way
@if exist temp rmdir /s /q temp
@if exist "%extname%%version%.xpi" del "%extname%%version%.xpi"
::Work with a temporary copy of the files
xcopy /E /I /Q /Y xpi temp
::Make the jar
cd temp\chrome
del content\consoleOverlay.xul
7z a -mx=0 -r -tzip "%extname%.jar" *
for /D %%d IN (*.*) DO rmdir /S /Q %%d
::Make the xpi
cd ..
@rem if exist ..\install.rdf copy /Y ..\install.rdf install.rdf
copy /Y ..\chrome.manifest chrome.manifest
7z a -mx=9 -r -tzip "..\%extname%%version%.xpi" *
cd ..
::Clean up
rmdir /s /q temp
@goto end
:nochromemanifest
@echo Error: file "chrome.manifest" not found
@goto pause
:noxpi
@echo Error: folder "xpi" not found in current directory
@goto pause
:noinstallrdf
@echo Error: file "xpi\install.rdf" not found
@goto pause
:nochrome
@echo Error: folder "xpi\chrome" not found
@goto pause
:nocontent
@echo Error: folder "xpi\chrome\content" not found
@goto pause
:noxcopy
@echo Error: required tool "xcopy.exe" not found on system path
@goto pause
:no7z
@echo Error: required tool "7z.exe" not found on system path
@goto pause
:pause
@pause
:end