Skip to content

Commit

Permalink
Merge pull request #49 from zinsbaustein/update_to_0.12.5
Browse files Browse the repository at this point in the history
Update to 0.12.5
  • Loading branch information
unixmonkey authored Oct 31, 2019
2 parents 24e4309 + f2d79ae commit 01a0733
Show file tree
Hide file tree
Showing 34 changed files with 245 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .docker/Dockerfile-centos_6
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM centos:6

RUN yum install -y ruby libjpeg-turbo libpng libXrender fontconfig libXext

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
5 changes: 5 additions & 0 deletions .docker/Dockerfile-centos_7
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM centos:7

RUN yum install -y ruby libjpeg-turbo libpng libXrender fontconfig libXext

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:8

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng12-0 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_9
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:9

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-ubuntu_14.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg8 libxrender1 libfontconfig1

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-ubuntu_16.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg8 libxrender1 libfontconfig1

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-ubuntu_18.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:18.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg8 libxrender1 libfontconfig1

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
pkg/*
bin/wkhtmltopdf_centos_6_amd64
bin/wkhtmltopdf_centos_7_amd64
bin/wkhtmltopdf_debian_8_amd64
bin/wkhtmltopdf_debian_9_amd64
bin/wkhtmltopdf_macos_cocoa
bin/wkhtmltopdf_macos_carbon
bin/wkhtmltopdf_ubuntu_14.04_amd64
bin/wkhtmltopdf_ubuntu_16.04_amd64
bin/wkhtmltopdf_ubuntu_18.04_amd64
bin/wkhtmltopdf_centos_6_i386
bin/wkhtmltopdf_centos_7_i386
bin/wkhtmltopdf_debian_8_i386
bin/wkhtmltopdf_debian_9_i386
bin/wkhtmltopdf_ubuntu_14.04_i386
bin/wkhtmltopdf_ubuntu_16.04_i386
bin/wkhtmltopdf_ubuntu_18.04_i386
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.12.5
Update `wkhtmltopdf` binaries with version 0.12.5

# 0.12.4
Update `wkhtmltopdf` binaries with version 0.12.4

Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# wkhtmltopdf_binary_gem

## Extracting binaries

Hints for extracting binaries from https://wkhtmltopdf.org/downloads.html (dpkg and rpm2cpio is available on Homebrew).

Debian/Ubuntu

dpkg -x wkhtmltox_0.12.5-1.trusty_amd64.deb .

CentOS

rpm2cpio wkhtmltox-0.12.5-1.centos7.x86_64.rpm | cpio -idmv

macOS

xar -xf wkhtmltox-0.12.5-1.macos-cocoa.pkg
cat Payload | gunzip -dc | cpio -i

## Compression

Binaries should be compressed with `gzip --best` after extracting. The matching binary will be extracted on first
execution of `bin/wkhtmltopdf`.

## Testing with Docker

Make sure you have Docker and Docker Compose installed (see https://docs.docker.com/compose/install/ for more
information).

There are Dockerfiles for the supported Linux based distributions under `.docker`. You can build them all with
`docker-compose build` and run each individually with e.g. `docker-compose run ubuntu_18.04`.

There also is a rudimentary minitest test that simply invokes `docker-compose run` for each distribution and
expects to see the output of `wkhtmltopdf --version`. Just run `rake` to run it.

You can clean up after testing with `docker-compose down --rmi all`.
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
require 'rubygems'
require 'rubygems/package_task'
require 'rake/testtask'

spec = eval(File.new("wkhtmltopdf-binary.gemspec").readlines.join("\n"))
Gem::PackageTask.new(spec) do |pkg|
pkg.need_tar = true
end

Rake::TestTask.new do |t|
t.libs << 'test'
end

desc 'Run tests'
task default: :test
38 changes: 31 additions & 7 deletions bin/wkhtmltopdf
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,38 @@
# of the License at http://www.apache.org/licenses/LICENSE-2.0

require 'rbconfig'
require 'zlib'

suffix = case RbConfig::CONFIG['host_os']
when /linux/
(RbConfig::CONFIG['host_cpu'] == 'x86_64') ? 'linux_amd64' : 'linux_x86'
when /darwin/
'darwin_x86'
else
raise "Invalid platform. Must be running on linux or intel-based Mac OS."
when /linux/
os = `. /etc/os-release 2> /dev/null && echo ${ID}_${VERSION_ID}`.strip

# CentOS 6 doesn't have `/etc/os-release`.
if os.empty? && File.read('/etc/centos-release').start_with?('CentOS release 6')
os = 'centos_6'
end

architecture = RbConfig::CONFIG['host_cpu'] == 'x86_64' ? 'amd64' : 'i386'

"#{os}_#{architecture}"
when /darwin/
RbConfig::CONFIG['host_cpu'] == 'x86_64' ? 'macos_cocoa' : 'macos_carbon'
else
'unknown'
end

binary = "#{__FILE__}_#{suffix}"

if File.exist?("#{binary}.gz") && !File.exist?(binary)
File.open binary, 'wb', 0o755 do |file|
Zlib::GzipReader.open("#{binary}.gz") { |gzip| file << gzip.read }
end
end

unless File.exist? binary
raise 'Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 ' \
'CentOS 6/7, Debian 8/9, or intel-based macOS ' \
"(missing binary: #{binary})."
end

system *$*.unshift("#{__FILE__}_#{suffix}")
system *$*.unshift(binary)
Loading

0 comments on commit 01a0733

Please sign in to comment.