Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set up dvipdf and ghostscript

  • Loading branch information...
commit 243a9d0a21e5d2a80aa6ba675ffddcf234172ea3 1 parent 5df3a42
@jpallen jpallen authored
Showing with 51 additions and 4 deletions.
  1. +39 −0 clsi/definitions/latex_chroot.rb
  2. +12 −4 clsi/recipes/default.rb
View
39 clsi/definitions/latex_chroot.rb
@@ -16,6 +16,10 @@
creates File.join(chrooted_texlive_dir, "README")
end
+ directory File.join(params[:chroot_root], "tmp") do
+ owner params[:owner]
+ mode 0777
+ end
directory params[:chroot_lib_directory] do
owner params[:owner]
end
@@ -23,6 +27,8 @@
owner params[:owner]
end
+ package "ghostscript"
+
ruby_block "Copy libraries and system binaries to Chroot" do
block do
def copy_libraries_for_binary(binary_path)
@@ -54,12 +60,45 @@ def location_of(binary)
end
end
+ unless File.exist?(File.join(params[:chroot_root], "usr/bin"))
+ relative_bin_dir = params[:binary_directory][(params[:chroot_root].length)..-1]
+ FileUtils.ln_s(File.join("/", relative_bin_dir), File.join(params[:chroot_root], "usr/bin"))
+ end
+
unless File.exist?(File.join(params[:chroot_bin_directory], params[:system_binaries][0]))
for binary_name in params[:system_binaries]
FileUtils.cp(location_of(binary_name), params[:chroot_bin_directory])
copy_libraries_for_binary(location_of(binary_name))
end
end
+
+ # Install ghostscript and dvipdf (comes with ghostscript) for converting dvi -> pdf
+ unless File.exist?(File.join(params[:chroot_bin_directory], "dvipdf"))
+ FileUtils.cp(location_of("dvipdf"), params[:chroot_bin_directory])
+ end
+
+ unless File.exist?(File.join(params[:chroot_bin_directory], "gs"))
+ FileUtils.cp(location_of('gs'), params[:chroot_bin_directory])
+ copy_libraries_for_binary(location_of('gs'))
+
+ status, stdout, stderr = systemu(['gs', '-h'])
+ directories = stdout.match(/^Search path:\n((?: .*\n)*)/)[1]
+ directories.gsub!("\n", '')
+ directories.gsub!(/ *\: */, ':')
+ directories.strip!
+ directories = directories.split(":")
+ directories = directories[1..-1] # remove '.'
+ print "Installing ghostscript directories:\n"
+ for directory in directories
+ if File.exist?(directory)
+ print directory + "\n"
+ chrooted_directory = File.join(params[:chroot_root], directory)
+ FileUtils.mkdir_p(chrooted_directory)
+ FileUtils.cp_r(directory, File.dirname(chrooted_directory))
+ end
+ end
+ end
+
end
end
end
View
16 clsi/recipes/default.rb
@@ -80,10 +80,18 @@
end
for binary_name, destination in node[:clsi][:chrooted_binaries]
- execute "Build chrooted #{binary_name}" do
- command "gcc #{node[:clsi][:install_directory]}/current/chrootedbinary.c -o #{destination} " +
- "-DCHROOT_DIR='\"#{node[:clsi][:chroot_directory]}\"' -DCOMMAND='\"/usr/local/texlive/bin/i386-linux/#{binary_name}\"'"
- creates destination
+ if binary_name == "dvipdf"
+ execute "Build chrooted #{binary_name}" do
+ command "gcc #{node[:clsi][:install_directory]}/current/chrootedbinary.c -o #{destination} " +
+ "-DCHROOT_DIR='\"#{node[:clsi][:chroot_directory]}\"' -DCOMMAND='\"/bin/#{binary_name}\"'"
+ creates destination
+ end
+ else
+ execute "Build chrooted #{binary_name}" do
+ command "gcc #{node[:clsi][:install_directory]}/current/chrootedbinary.c -o #{destination} " +
+ "-DCHROOT_DIR='\"#{node[:clsi][:chroot_directory]}\"' -DCOMMAND='\"/usr/local/texlive/bin/i386-linux/#{binary_name}\"'"
+ creates destination
+ end
end
file destination do
Please sign in to comment.
Something went wrong with that request. Please try again.