forked from fuse4x/kext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rb
executable file
·40 lines (31 loc) · 1.65 KB
/
build.rb
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
#!/usr/bin/env ruby
# Possible flags are:
# --debug this builds distribuition with debug flags enabled
# --root DIR install the binary into this directory. If this flag is not set - the script
# redeploys kext to local machine and restarts it
# --clean clean before build
CWD = File.dirname(__FILE__)
KEXT_DIR = '/System/Library/Extensions/'
Dir.chdir(CWD)
debug = ARGV.include?('--debug')
clean = ARGV.include?('--clean')
root_dir = ARGV.index('--root') ? ARGV[ARGV.index('--root') + 1] : nil
abort("root directory #{root_dir} does not exist") if ARGV.index('--root') and not File.exists?(root_dir)
system('git clean -xdf') if clean
configuration = debug ? 'Debug' : 'Release'
system("xcodebuild -parallelizeTargets -configuration #{configuration} -alltargets") or abort("cannot build kext")
unless root_dir
# we need to reload the kext
if system('kextstat | grep org.fuse4x.kext.fuse4x') then
system('sudo kextunload -b org.fuse4x.kext.fuse4x') or abort('cannot unload the kext')
end
end
install_path = root_dir ? File.join(root_dir, KEXT_DIR) : KEXT_DIR
system("sudo mkdir -p #{install_path}") if root_dir
system("sudo cp -R build/#{configuration}/fuse4x.kext #{install_path}") or abort
# Install load_fuse4x tool. The tool should have +s bit set to allow
# non-priveleged users mount fuse4x filesystem and init sysctl
system("sudo mkdir -p #{install_path}/fuse4x.kext/Support") or abort
system("sudo cp build/#{configuration}/load_fuse4x #{install_path}/fuse4x.kext/Support") or abort
system("sudo chmod +s #{install_path}/fuse4x.kext/Support/load_fuse4x")
system("sudo chown -R root:wheel #{install_path}/fuse4x.kext") or abort