/
source.rb
81 lines (71 loc) · 2.2 KB
/
source.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
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
#
# Cookbook Name:: ffmpeg
# Recipe:: source
#
# Author:: Jamie Winsor (<jamie@enmasse.com>)
#
# Copyright 2011, En Masse Entertainment, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "build-essential"
include_recipe "git"
ffmpeg_packages.each do |pkg|
package pkg do
action :purge
end
end
include_recipe "x264::source"
include_recipe "libvpx::source"
yasm_package = value_for_platform(
[ "ubuntu" ] => { "default" => "yasm" },
"default" => "yasm"
)
package yasm_package do
action :upgrade
end
# Filter the packages that we just built from source via their compile flag
flags_for_upgrade = node[:ffmpeg][:compile_flags].reject do |flag|
["--enable-libx264", "--enable-libvpx"].include?(flag)
end
find_prerequisite_packages_by_flags(flags_for_upgrade).each do |pkg|
package pkg do
action :upgrade
end
end
git "#{Chef::Config[:file_cache_path]}/ffmpeg" do
repository node[:ffmpeg][:git_repository]
reference node[:ffmpeg][:git_revision]
action :sync
notifies :run, "bash[compile_ffmpeg]"
end
# Write the flags used to compile the application to Disk. If the flags
# do not match those that are in the compiled_flags attribute - we recompile
template "#{Chef::Config[:file_cache_path]}/ffmpeg-compiled_with_flags" do
source "compiled_with_flags.erb"
owner "root"
group "root"
mode 0600
variables(
:compile_flags => node[:ffmpeg][:compile_flags]
)
notifies :run, "bash[compile_ffmpeg]"
end
bash "compile_ffmpeg" do
cwd "#{Chef::Config[:file_cache_path]}/ffmpeg"
code <<-EOH
./configure --prefix=#{node[:ffmpeg][:prefix]} #{node[:ffmpeg][:compile_flags].join(' ')}
make clean && make && make install
EOH
creates "#{node[:ffmpeg][:prefix]}/bin/ffmpeg"
end