-
Notifications
You must be signed in to change notification settings - Fork 21
/
rakefile
184 lines (161 loc) · 7.11 KB
/
rakefile
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# -*-ruby-*-
# This rakefile is compatible with both 0.8 and 10
verbose(false) #disable printing of rake mkdir messages
## generic framework
require "./buildtools/buildtools.rb"
## default tasks
task :default => :devel
task :all => :devel
## clean tasks
task :download_clean do
Kernel.system( "make --no-print-directory -C downloads distclean" )
end
## clean up any running UVM
task :uvm_clean do
# if running, kill it
Kernel.system("if [ -f /var/run/uvm.pid ] && [ -f /proc/`cat /var/run/uvm.pid`/cmdline ] && grep -q #{SRC_HOME} /proc/`cat /var/run/uvm.pid`/cmdline ; then #{SRC_HOME}/dist/etc/init.d/untangle-vm stop ; fi")
# change symlinks back to original
Kernel.system('if [ -L /usr/share/untangle/bin ] && [ -d /usr/share/untangle/bin.backup ] ; then sudo rm -f /usr/share/untangle/bin && sudo mv /usr/share/untangle/bin.backup /usr/share/untangle/bin ; fi')
# remove apache file
if File.exist?("/etc/apache2/uvm-dev.conf")
info "[rm -rf ] /etc/apache2/uvm-dev.conf"
FileUtils.rm_rf("/etc/apache2/uvm-dev.conf") if File.exist?("/etc/apache2/uvm-dev.conf")
end
end
task :kindaclean do
info "[rm -rf ] #{BuildEnv::SRC.devel}"
FileUtils.rm_rf(BuildEnv::SRC.devel) if File.exist?(BuildEnv::SRC.devel)
info "[rm -rf ] #{BuildEnv::SRC.staging}"
FileUtils.rm_rf(BuildEnv::SRC.staging) if File.exist?(BuildEnv::SRC.staging)
info "[rm -rf ] debian/dirs"
FileUtils.rm_rf(FileList['debian/*'].select { |f| f != 'debian/source' and File.directory?(f) })
info "[rm -rf ] debian/*init"
FileUtils.rm_rf(FileList['debian/*init'])
## Clear the stamp hashes
Rake::StampHash.instance.clear
end
task :clean => [:uvm_clean, :download_clean, :kindaclean]
## download task; it is needed by both arch-dep and arch-indep,
## because Jars.findJars sets up the base classpath used everywhere
task :download do
Kernel.system("make --no-print-directory -C downloads")
raise unless $?.success?
Jars.findJars
end
## arch-dep tasks
task :core => :download do
require "./buildtools/untangle-core.rb"
end
task :builduvmcore => :core do
Rake::Task[:libuvmcore_so].invoke
end
task :installuvmcore => :builduvmcore do
Rake::Task[:dest_uvmcore_so].invoke
end
## arch-indep tasks
task :targets => :download do
# Require all arch-indep sub packages; done manually because order
# matters.
require "#{SRC_HOME}/uvm/package.rb"
require "#{SRC_HOME}/reports/package.rb"
require "#{SRC_HOME}/ftp-casing/package.rb"
require "#{SRC_HOME}/http-casing/package.rb"
require "#{SRC_HOME}/smtp-casing/package.rb"
require "#{SRC_HOME}/webroot-base/package.rb"
require "#{SRC_HOME}/router/package.rb"
require "#{SRC_HOME}/shield/package.rb"
require "#{SRC_HOME}/firewall/package.rb"
require "#{SRC_HOME}/threat-prevention/package.rb"
require "#{SRC_HOME}/application-control-lite/package.rb"
require "#{SRC_HOME}/intrusion-prevention/package.rb"
require "#{SRC_HOME}/spam-blocker-base/package.rb"
require "#{SRC_HOME}/virus-blocker-base/package.rb"
require "#{SRC_HOME}/clam-base/package.rb"
require "#{SRC_HOME}/web-filter-base/package.rb"
require "#{SRC_HOME}/web-filter/package.rb"
require "#{SRC_HOME}/phish-blocker/package.rb"
require "#{SRC_HOME}/spam-blocker-lite/package.rb"
require "#{SRC_HOME}/web-monitor/package.rb"
require "#{SRC_HOME}/ad-blocker/package.rb"
require "#{SRC_HOME}/virus-blocker-lite/package.rb"
require "#{SRC_HOME}/captive-portal/package.rb"
require "#{SRC_HOME}/application-control/package.rb"
require "#{SRC_HOME}/bandwidth-control/package.rb"
require "#{SRC_HOME}/branding-manager/package.rb"
require "#{SRC_HOME}/configuration-backup/package.rb"
require "#{SRC_HOME}/directory-connector/package.rb"
require "#{SRC_HOME}/openvpn/package.rb"
require "#{SRC_HOME}/wireguard-vpn/package.rb"
require "#{SRC_HOME}/tunnel-vpn/package.rb"
require "#{SRC_HOME}/ipsec-vpn/package.rb"
require "#{SRC_HOME}/live-support/package.rb"
require "#{SRC_HOME}/policy-manager/package.rb"
require "#{SRC_HOME}/spam-blocker/package.rb"
require "#{SRC_HOME}/ssl-inspector/package.rb"
require "#{SRC_HOME}/virus-blocker/package.rb"
require "#{SRC_HOME}/wan-balancer/package.rb"
require "#{SRC_HOME}/wan-failover/package.rb"
require "#{SRC_HOME}/web-cache/package.rb"
require "#{SRC_HOME}/license/package.rb"
if File.exists?("#{SRC_HOME}/plugins/package.rb")
require "#{SRC_HOME}/plugins/package.rb"
end
end
task :build => [:builduvmcore, :targets] do
Rake::Task[BuildEnv::SRC['untangle-vm']].invoke
Rake::Task[BuildEnv::SRC['app']].invoke
end
task :hier => :targets do
Rake::Task[BuildEnv::SRC.hierTarget].invoke
end
task :devel => [:build, :hier, :installuvmcore] do
Rake::Task[BuildEnv::SRC['install']].invoke
Rake::Task[BuildEnv::SRC.installTarget].invoke
## Ad Blocker hack to rename ad-blocker.js to ab.js NGFW-10728
## Make this copy target and put it in the first servlet after admin
if File.exists?("#{SRC_HOME}/dist/usr/share/untangle/web/admin/script/apps/ad-blocker.js")
FileUtils.cp("#{SRC_HOME}/dist/usr/share/untangle/web/admin/script/apps/ad-blocker.js", "#{SRC_HOME}/dist/usr/share/untangle/web/admin/script/apps/ab.js")
end
if File.exists?("#{SRC_HOME}/debian/untangle-libuvm/usr/share/untangle/web/admin/script/apps/ad-blocker.js")
FileUtils.cp("#{SRC_HOME}/debian/untangle-libuvm/usr/share/untangle/web/admin/script/apps/ad-blocker.js", "#{SRC_HOME}/debian/untangle-libuvm/usr/share/untangle/web/admin/script/apps/ab.js")
end
end
task :unittest do
Kernel.system(
{"PYTHONPATH" =>
"./uvm/hier/usr/lib/python3/dist-packages/"},
"python3 -m pytest ./uvm/hier/usr/lib/python3/dist-packages/unit_tests")
end
task :i18n => [:builduvmcore, :targets] do
## Generate and update po files
# raise "generate failed" unless Kernel.system("#{BuildEnv::SRC.i18ntools}/generate.py")
# raise "translate failed" unless Kernel.system("#{BuildEnv::SRC.i18ntools}/translate.py", "--languages=xx")
Rake::Task[BuildEnv::SRC.i18nTarget].invoke
end
task :debian_init_files do
FileList["./debian/**/etc/init.d/*"].each do |f|
FileUtils.cp(f, "./debian/#{File.basename(f)}.init")
end
end
task :install => [:devel, :i18n, :debian_init_files]
task :javadocanalyzer do
javaDirs = FileList["./**/*.java"].exclude(%r{downloads/})
sourcepath = javaDirs.map { |d| d.split('/')[1..2].join('/') }.uniq.join(',')
puts sourcepath
Kernel.exec("./buildtools/javadoc-analyzer.py",
"--path=#{sourcepath}")
end
task :javadoc => [:download] do
javaDirs = FileList["./**/*.java"].exclude(%r{downloads/})
sourcepath = javaDirs.map { |d| d.split('/')[1..2].join('/') }.uniq.join(':')
puts sourcepath
subpackages = 'com.untangle'
cpath = FileList["#{BuildEnv::SRC.devel}/*","#{BuildEnv::downloads}/**/*jar"].join(':')
css = "./buildtools/javadoc.css"
Kernel.exec(JavaCompiler.JavadocCommand,
'-docletpath', './downloads/wikidoclet.1.0.4.jar',
'-doclet', 'wikidoclet.WikiDoclet',
'-splitindex','-docencoding','UTF-8','-use','-docfilessubdirs', '-stylesheetfile', css, '-sourcepath', sourcepath, '-classpath', cpath,
'-d', "#{BuildEnv::SRC.staging}/javadoc",
'-subpackages', subpackages, '-J-Xmx512m')
end