This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
212 lines (184 loc) · 6.18 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
packagemaker = '/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker'
#Used clam AV version
CLAMAV_VERSION = '0.95.2'
#Needed macports
PORTS = %w{zlib bzip2}
#sf.net mirror
SF_MIRROR = 'freefr'
source = "clamav-#{CLAMAV_VERSION}"
def sudo_rm(path)
if File.exist? path
sh "sudo rm -r #{path}"
end
end
task :ports do
installed = `port installed`
PORTS.each do |port|
sh "sudo port -d install #{port} +universal" if installed.index(port) == nil
end
end
namespace :palourde do
task :i18n do
sh 'genstrings source/PAController.m'
end
task :build do
sh 'xcodebuild -target Palourde -configuration Release'
end
task :clean do
sh 'xcodebuild clean'
end
task :install => :build do
sh 'sudo mkdir -p /Library/Palourde/'
sudo_rm '/Library/Palourde/Palourde.app'
sh 'sudo cp -r build/Release/Palourde.app /Library/Palourde/'
end
end
namespace :clamav do
file "#{source}.tar.gz" do
sh "curl -O http://#{SF_MIRROR}.dl.sourceforge.net/sourceforge/clamav/#{source}.tar.gz"
end
file source => "#{source}.tar.gz" do
sh "tar -xvzf #{source}.tar.gz"
end
task :patch => source do
if not File.exist? "#{source}/freshclam/freshclam.m"
Dir.chdir "#{source}/freshclam" do
%w{freshclam manager}.each do |f|
mv "#{f}.c", "#{f}.m" if File.exist? "#{f}.c"
end
end
Dir.chdir source do
sh "patch -p0 -N -i ../patches/freshclam.patch"
end
end
end
task :build => [:patch, :ports] do
if File.exist? "#{source}/clamd/clamd"
puts "[Info] deja fait"
else
export = {
'CFLAGS'=> '-O0 -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386 -mmacosx-version-min=10.5',
'CPPFLAGS'=> '-I/opt/local/include -isysroot /Developer/SDKs/MacOSX10.5.sdk',
'CXXFLAGS'=> '-O2 -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386 -mmacosx-version-min=10.5',
'MACOSX_DEPLOYMENT_TARGET'=> '10.5',
'CPP'=> '/usr/bin/cpp-4.0',
'CXX'=> '/usr/bin/g++-4.0',
'F90FLAGS'=> '-O2',
'LDFLAGS'=> '-L/opt/local/lib -arch ppc -arch i386 -mmacosx-version-min=10.5',
'FCFLAGS'=> '-O2',
'OBJC'=> '/usr/bin/gcc-4.0',
'INSTALL'=> '/usr/bin/install -c',
'OBJCFLAGS'=> '-O2',
'FFLAGS'=> '-O2',
'CC'=> '/usr/bin/gcc-4.0'
}
Dir.chdir source do
sh './configure --enable-static --with-zlib=/opt/local --with-libbz2-prefix=/opt/local --with-iconv --prefix=/Library/Palourde/Palourde.app/Contents/Resources --disable-clamav --disable-dependency-tracking --sysconfdir=/Library/Preferences/ --with-dbdir=/Library/Palourde/Definitions/ --enable-id-check --enable-clamdtop '
sh 'make clean'
cmd = ''
export.each do |k,v|
cmd += "#{k}='#{v}' "
end
sh "#{cmd} make all"
end
end
end
task :install => :build do
Dir.chdir source do
sh 'sudo make install'
end
end
task :clean do
rm_r source
end
end
def stop(name)
if `launchctl list`.include? name
sh "sudo launchctl stop #{name}"
end
end
def launchctl(action, file)
if File.exist? file
sh "sudo launchctl #{action} #{file}"
end
end
desc "Install applications and conf files"
task :install => ['palourde:install', 'clamav:install', :conf]
desc "Remove installed stuff"
task :uninstall do
stop 'com.macbouffon.palourde.agent.plist'
stop 'com.macbouffon.palourde.freshclam.plist'
stop 'com.macbouffon.palourde.clamd.plist'
sudo_rm '/Library/Palourde'
sudo_rm '/Library/Preferences/clamd.conf'
sudo_rm '/Library/Preferences/freshclam.conf'
sudo_rm '/Library/LaunchAgents/net.palourde.agent.plist'
sudo_rm '/Library/LaunchDaemons/net.palourde.clamd.plist'
sudo_rm '/Library/LaunchDaemons/net.palourde.freshclam.plist'
sudo_rm '/Library/LaunchAgents/com.macbouffon.palourde.agent.plist'
sudo_rm '/Library/LaunchDaemons/com.macbouffon.palourde.clamd.plist'
sudo_rm '/Library/LaunchDaemons/com.macbouffon.palourde.freshclam.plist'
end
task :clean => ['palourde:clean', 'clamav:clean', :uninstall] do
rm_r 'build' if File.exist? 'build'
rm 'Palourde.dmg' if File.exist? 'Palourde.dmg'
end
desc "compile applications"
task :build => ['palourde:build', 'clamav:build']
def chown(file)
sh "sudo chown -R root:admin #{file}"
end
def copy_chown(file, to)
sh "sudo cp etc/#{file} #{to}"
chown "#{to}#{file}"
end
desc "Spread conf files"
task :conf do
copy_chown 'clamd.conf', '/Library/Preferences/'
copy_chown 'freshclam.conf', '/Library/Preferences/'
copy_chown 'net.palourde.agent.plist', '/Library/LaunchAgents/'
copy_chown 'net.palourde.clamd.plist', '/Library/LaunchDaemons/'
copy_chown 'net.palourde.freshclam.plist', '/Library/LaunchDaemons/'
end
task :default => :dmg
desc "Build a cute package"
task :pkg => :install do
sh 'freeze Palourde.packproj'
#rm 'palourde.pkg' if File.exist? 'palourde.pkg'
#sudo_rm 'package' if File.exist? 'package'
#mkdir_p 'package/Library/Palourde'
#mkdir_p 'package/Library/Preferences'
#mkdir_p 'package/Library/LaunchAgents'
#mkdir_p 'package/Library/LaunchDaemons'
#sh 'sudo cp -r /Library/Palourde/Palourde.app package/Library/Palourde'
#sh 'sudo chmod 775 package/Palourde.app'
#sh 'cp -p /Library/Preferences/clamd.conf package/Library/Preferences/'
#sh 'cp -p /Library/Preferences/freshclam.conf package/Library/Preferences/'
#sh 'cp -p /Library/LaunchAgents/net.palourde.agent.plist package/Library/LaunchAgents/'
#sh 'cp -p /Library/LaunchDaemons/net.palourde.clamd.plist package/Library/LaunchDaemons/'
#sh 'cp -p /Library/LaunchDaemons/net.palourde.freshclam.plist package/Library/LaunchDaemons/'
#sh 'find package -name ".DS_Store" -exec rm -f {} \;'
#chown 'package'
#sh "#{packagemaker} --root ./package --id net.palourde --out Palourde.pkg --version 0.1 --title Palourde --domain system --root-volume-only --verbose --discard-forks --scripts pkg_scripts --install-to /"
#--scripts pkg_scripts
#--target 10.5
end
desc "Build an image file"
task :dmg => :pkg do
rm_r 'dmg' if File.exist? 'dmg'
mkdir 'dmg'
cp_r 'build/Palourde.pkg', 'dmg'
rm 'Palourde.dmg' if File.exist? 'Palourde.dmg'
sh 'hdiutil create -volname Palourde -srcfolder dmg Palourde.dmg'
rm_r 'dmg'
end
desc 'Update virus definition'
task :freshclam do
sh "sudo /Library/Palourde/Palourde.app/Contents/Resources/bin/freshclam"
end
task :postinstall do
sh 'sudo ./pkg_scripts/postinstall'
end
task :purge do
sudo_rm '/Library/Palourde/Definitions'
end