image_optim_pack 0.5.0-x86-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +79 -0
  4. data/.travis.yml +35 -0
  5. data/CHANGELOG.markdown +210 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE.txt +27 -0
  8. data/Makefile +393 -0
  9. data/README.markdown +93 -0
  10. data/Vagrantfile +60 -0
  11. data/acknowledgements/7z.txt +56 -0
  12. data/acknowledgements/advancecomp.txt +674 -0
  13. data/acknowledgements/bmp2png.txt +8 -0
  14. data/acknowledgements/cexcept.txt +8 -0
  15. data/acknowledgements/gifread.txt +14 -0
  16. data/acknowledgements/gifsicle.txt +343 -0
  17. data/acknowledgements/iqa.txt +30 -0
  18. data/acknowledgements/jhead.txt +12 -0
  19. data/acknowledgements/jpeg-archive.txt +20 -0
  20. data/acknowledgements/jpegoptim.txt +339 -0
  21. data/acknowledgements/libjpeg-turbo.txt +27 -0
  22. data/acknowledgements/libjpeg-x86-simd.txt +17 -0
  23. data/acknowledgements/libjpeg.txt +64 -0
  24. data/acknowledgements/libpng.txt +90 -0
  25. data/acknowledgements/mozjpeg.txt +7 -0
  26. data/acknowledgements/optipng-authors.txt +26 -0
  27. data/acknowledgements/optipng.txt +21 -0
  28. data/acknowledgements/pngcrush.txt +35 -0
  29. data/acknowledgements/pngquant.txt +56 -0
  30. data/acknowledgements/smallfry.txt +13 -0
  31. data/acknowledgements/zlib.txt +34 -0
  32. data/acknowledgements/zopfli-contributors.txt +6 -0
  33. data/acknowledgements/zopfli.txt +201 -0
  34. data/boxes/.gitignore +3 -0
  35. data/boxes/.rubocop.yml +13 -0
  36. data/boxes/Gemfile +11 -0
  37. data/boxes/Rakefile +144 -0
  38. data/boxes/definitions/freebsd-amd64/definition.rb +38 -0
  39. data/boxes/definitions/freebsd-amd64/install.sh +66 -0
  40. data/boxes/definitions/freebsd-i386/definition.rb +38 -0
  41. data/boxes/definitions/freebsd-i386/install.sh +66 -0
  42. data/boxes/definitions/freebsd-postinstall.sh +38 -0
  43. data/boxes/definitions/openbsd-amd64/definition.rb +71 -0
  44. data/boxes/definitions/openbsd-i386/definition.rb +71 -0
  45. data/boxes/definitions/openbsd-postinstall.sh +29 -0
  46. data/image_optim_pack-darwin-x86.gemspec +3 -0
  47. data/image_optim_pack-darwin-x86_64.gemspec +3 -0
  48. data/image_optim_pack-freebsd-amd64.gemspec +3 -0
  49. data/image_optim_pack-freebsd-x86.gemspec +3 -0
  50. data/image_optim_pack-linux-x86.gemspec +3 -0
  51. data/image_optim_pack-linux-x86_64.gemspec +3 -0
  52. data/image_optim_pack-openbsd-x86.gemspec +3 -0
  53. data/image_optim_pack-openbsd-x86_64.gemspec +3 -0
  54. data/image_optim_pack.gemspec +41 -0
  55. data/lib/image_optim/pack.rb +117 -0
  56. data/lib/image_optim_pack.rb +1 -0
  57. data/script/livecheck +116 -0
  58. data/script/run +71 -0
  59. data/script/update_versions +22 -0
  60. data/spec/image_optim/pack_spec.rb +114 -0
  61. data/spec/image_optim_spec.rb +39 -0
  62. data/spec/spec_helper.rb +8 -0
  63. data/vendor/darwin-i386/advpng +0 -0
  64. data/vendor/darwin-i386/gifsicle +0 -0
  65. data/vendor/darwin-i386/jhead +0 -0
  66. data/vendor/darwin-i386/jpeg-recompress +0 -0
  67. data/vendor/darwin-i386/jpegoptim +0 -0
  68. data/vendor/darwin-i386/jpegtran +0 -0
  69. data/vendor/darwin-i386/libjpeg.dylib +0 -0
  70. data/vendor/darwin-i386/libpng.dylib +0 -0
  71. data/vendor/darwin-i386/libz.dylib +0 -0
  72. data/vendor/darwin-i386/optipng +0 -0
  73. data/vendor/darwin-i386/pngcrush +0 -0
  74. data/vendor/darwin-i386/pngquant +0 -0
  75. metadata +182 -0
@@ -0,0 +1,66 @@
1
+ #!/bin/sh -x
2
+
3
+ # Credit: http://www.aisecure.net/2011/05/01/root-on-zfs-freebsd-current/
4
+
5
+ NAME=$1
6
+
7
+ # create disks
8
+ gpart create -s gpt ada0
9
+ gpart add -t freebsd-boot -l boot -b 40 -s 512K ada0
10
+ gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
11
+ gpart add -t freebsd-ufs -l root -b 1M -s 2G ada0
12
+ gpart add -t freebsd-swap -l swap -s 512M ada0
13
+ gpart add -t freebsd-ufs -l var -s 1G ada0
14
+ gpart add -t freebsd-ufs -l tmp -s 512M ada0
15
+ gpart add -t freebsd-ufs -l usr -a 1M ada0
16
+
17
+ # create filesystems
18
+ newfs -U /dev/gpt/root
19
+ newfs -U /dev/gpt/var
20
+ newfs -U /dev/gpt/tmp
21
+ newfs -U /dev/gpt/usr
22
+
23
+ # mount the filesystems
24
+ mount /dev/gpt/root /mnt
25
+ mkdir /mnt/var && mount /dev/gpt/var /mnt/var
26
+ mkdir /mnt/tmp && mount /dev/gpt/tmp /mnt/tmp
27
+ mkdir /mnt/usr && mount /dev/gpt/usr /mnt/usr
28
+
29
+ # correct permissions
30
+ chmod 1777 /mnt/tmp
31
+ mkdir /mnt/var/tmp && chmod 1777 /mnt/var/tmp
32
+ cd /mnt && mkdir usr/home && ln -s usr/home home
33
+
34
+ # Install the OS
35
+ cd /usr/freebsd-dist
36
+ cat base.txz | tar --unlink -xpJf - -C /mnt
37
+ cat lib32.txz | tar --unlink -xpJf - -C /mnt
38
+ cat kernel.txz | tar --unlink -xpJf - -C /mnt
39
+ cat src.txz | tar --unlink -xpJf - -C /mnt
40
+
41
+ # Enable required services
42
+ cat >> /mnt/etc/rc.conf << EOT
43
+ hostname="${NAME}"
44
+ ifconfig_em0="dhcp"
45
+ sshd_enable="YES"
46
+ EOT
47
+
48
+ # Enable swap
49
+ cat >> /mnt/etc/fstab << EOT
50
+ /dev/gpt/swap none swap sw 0 0
51
+ /dev/gpt/root / ufs rw 1 1
52
+ /dev/gpt/var /var ufs rw 1 1
53
+ /dev/gpt/tmp /tmp ufs rw 1 1
54
+ /dev/gpt/usr /usr ufs rw 1 1
55
+ EOT
56
+
57
+ # Install a few requirements
58
+ touch /mnt/etc/resolv.conf
59
+ echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config
60
+
61
+ # Set up user accounts
62
+ mkdir /mnt/usr/home/vagrant && chown 1001:1001 /mnt/home/vagrant
63
+ echo "vagrant" | pw -V /mnt/etc useradd vagrant -h 0 -s csh -G wheel -d /home/vagrant -c "Vagrant User"
64
+ echo "vagrant" | pw -V /mnt/etc usermod root -h 0
65
+
66
+ reboot
@@ -0,0 +1,38 @@
1
+ set -ex
2
+
3
+ ntpdate -v -b in.pool.ntp.org
4
+ date > /etc/vagrant_box_build_time
5
+
6
+ ASSUME_ALWAYS_YES=yes pkg info
7
+ pkg install -y sudo bash-static wget
8
+
9
+ # setup the vagrant key
10
+ mkdir -p /home/vagrant/.ssh
11
+ chmod 700 /home/vagrant/.ssh
12
+ wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
13
+ chmod 600 /home/vagrant/.ssh/authorized_keys
14
+ chown -R vagrant /home/vagrant/.ssh
15
+
16
+ # passwordless sudo
17
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /usr/local/etc/sudoers
18
+
19
+ # undo customizations
20
+ sed -i '' -e '/^REFUSE /d' /etc/portsnap.conf
21
+ sed -i '' -e '/^PermitRootLogin /d' /etc/ssh/sshd_config
22
+
23
+ # set vagrant shell to bash
24
+ pw usermod vagrant -s /usr/local/bin/bash
25
+
26
+ # cleanup
27
+ sudo pkg clean -y
28
+ rm -rf \
29
+ /var/db/freebsd-update/* \
30
+ /var/cache/pkg/* \
31
+ /etc/ssh/ssh_host_key* \
32
+ /usr/src \
33
+ /var/log/* \
34
+ /var/tmp/* \
35
+ /tmp/*
36
+ dd if=/dev/zero of=filler bs=1M || rm filler
37
+
38
+ shutdown -p now
@@ -0,0 +1,71 @@
1
+ Veewee::Session.declare({
2
+ :cpu_count => '1',
3
+ :memory_size => '512',
4
+ :disk_size => '8192',
5
+ :disk_format => 'VDI',
6
+ :hostiocache => 'off',
7
+ :os_type_id => 'OpenBSD_64',
8
+ :iso_file => 'OpenBSD-5.5-amd64.iso',
9
+ :iso_src => 'https://www.mirrorservice.org/pub/OpenBSD/5.5/amd64/install55.iso',
10
+ :iso_sha256 => 'cc465ce3f8397883e91c6e1a8a98b1b3507a338984bbfe8978050c5f8fdcaf3f',
11
+ :iso_download_timeout => '1000',
12
+ :boot_wait => '50',
13
+ :boot_cmd_sequence => [
14
+ 'I<Enter>', # I - install
15
+ 'us<Enter>', # set the keyboard
16
+ 'OpenBSD55-x64<Enter>', # set the hostname
17
+ '<Enter>', # Which nic to config ? [em0]
18
+ '<Enter>', # do you want dhcp ? [dhcp]
19
+ '<Wait>' * 5,
20
+ 'none<Enter>', # IPV6 for em0 ? [none]
21
+ 'done<Enter>', # Which other nic do you wish to configure [done]
22
+ 'vagrant<Enter>', # Pw for root account
23
+ 'vagrant<Enter>',
24
+ 'yes<Enter>', # Start sshd by default ? [yes]
25
+ 'no<Enter>', # Start ntpd by default ? [yes]
26
+ 'no<Enter>', # Do you want the X window system [yes]
27
+ 'vagrant<Enter>', # Setup a user ?
28
+ 'vagrant<Enter>', # Full username
29
+ 'vagrant<Enter>', # Pw for this user
30
+ 'vagrant<Enter>',
31
+ 'no<Enter>', # Do you want to disable sshd for root ? [yes]
32
+ 'GB<Enter>', # What timezone are you in ?
33
+ '<Enter>', # Available disks [sd0]
34
+ '<Enter>', # Use DUIDs rather than device names in fstab ? [yes]
35
+ 'W<Enter>', # Use (W)whole disk or (E)edit MBR ? [whole]
36
+ 'A<Enter>', # Use (A)auto layout ... ? [a]
37
+ '<Wait>' * 70,
38
+ 'cd<Enter>', # location of the sets [cd]
39
+ '<Enter>', # Available cd-roms : cd0
40
+ '<Enter>', # Pathname to sets ? [5.5/amd64]
41
+ '-game55.tgz<Enter>', # Remove games and X
42
+ '-xbase55.tgz<Enter>',
43
+ '-xetc55.tgz<Enter>',
44
+ '-xshare55.tgz<Enter>',
45
+ '-xfont55.tgz<Enter>',
46
+ '-xserv55.tgz<Enter>',
47
+ 'done<Enter>',
48
+ '<Wait>',
49
+ 'yes<Enter>', # CD does not contain SHA256.sig (5.5) Continue without verification?
50
+ 'done<Enter>', # Done installing ?
51
+ '<Wait>' * 6,
52
+ 'yes<Enter><Wait>', # Time appears wrong. Set to ...? [yes]
53
+ '<Wait>' * 6,
54
+ 'reboot<Enter>',
55
+ '<Wait>' * 6,
56
+ ],
57
+ :kickstart_port => '7122',
58
+ :kickstart_timeout => '300',
59
+ :kickstart_file => '',
60
+ :ssh_login_timeout => '10000',
61
+ :ssh_user => 'root',
62
+ :ssh_password => 'vagrant',
63
+ :ssh_key => '',
64
+ :ssh_host_port => '7222',
65
+ :ssh_guest_port => '22',
66
+ :sudo_cmd => "sh '%f'",
67
+ :shutdown_cmd => '/sbin/halt -p',
68
+ :postinstall_files => %w[../openbsd-postinstall.sh],
69
+ :postinstall_timeout => '10000',
70
+ :skip_iso_transfer => true,
71
+ })
@@ -0,0 +1,71 @@
1
+ Veewee::Session.declare({
2
+ :cpu_count => '1',
3
+ :memory_size => '512',
4
+ :disk_size => '8192',
5
+ :disk_format => 'VDI',
6
+ :hostiocache => 'off',
7
+ :os_type_id => 'OpenBSD',
8
+ :iso_file => 'OpenBSD-5.5-i386.iso',
9
+ :iso_src => 'https://www.mirrorservice.org/pub/OpenBSD/5.5/i386/install55.iso',
10
+ :iso_sha256 => '43798eb4f459b58062167c24337230e96c78b01887a4be40d89279df379f3565',
11
+ :iso_download_timeout => '1000',
12
+ :boot_wait => '50',
13
+ :boot_cmd_sequence => [
14
+ 'I<Enter>', # I - install
15
+ 'us<Enter>', # set the keyboard
16
+ 'OpenBSD55-x32<Enter>', # set the hostname
17
+ '<Enter>', # Which nic to config ? [em0]
18
+ '<Enter>', # do you want dhcp ? [dhcp]
19
+ '<Wait>' * 5,
20
+ 'none<Enter>', # IPV6 for em0 ? [none]
21
+ 'done<Enter>', # Which other nic do you wish to configure [done]
22
+ 'vagrant<Enter>', # Pw for root account
23
+ 'vagrant<Enter>',
24
+ 'yes<Enter>', # Start sshd by default ? [yes]
25
+ 'no<Enter>', # Start ntpd by default ? [yes]
26
+ 'no<Enter>', # Do you want the X window system [yes]
27
+ 'vagrant<Enter>', # Setup a user ?
28
+ 'vagrant<Enter>', # Full username
29
+ 'vagrant<Enter>', # Pw for this user
30
+ 'vagrant<Enter>',
31
+ 'no<Enter>', # Do you want to disable sshd for root ? [yes]
32
+ 'GB<Enter>', # What timezone are you in ?
33
+ '<Enter>', # Available disks [sd0]
34
+ '<Enter>', # Use DUIDs rather than device names in fstab ? [yes]
35
+ 'W<Enter>', # Use (W)whole disk or (E)edit MBR ? [whole]
36
+ 'A<Enter>', # Use (A)auto layout ... ? [a]
37
+ '<Wait>' * 70,
38
+ 'cd<Enter>', # location of the sets [cd]
39
+ '<Enter>', # Available cd-roms : cd0
40
+ '<Enter>', # Pathname to sets ? [5.5/i386]
41
+ '-game55.tgz<Enter>', # Remove games and X
42
+ '-xbase55.tgz<Enter>',
43
+ '-xetc55.tgz<Enter>',
44
+ '-xshare55.tgz<Enter>',
45
+ '-xfont55.tgz<Enter>',
46
+ '-xserv55.tgz<Enter>',
47
+ 'done<Enter>',
48
+ '<Wait>',
49
+ 'yes<Enter>', # CD does not contain SHA256.sig (5.5) Continue without verification?
50
+ 'done<Enter>', # Done installing ?
51
+ '<Wait>' * 6,
52
+ 'yes<Enter><Wait>', # Time appears wrong. Set to ...? [yes]
53
+ '<Wait>' * 6,
54
+ 'reboot<Enter>',
55
+ '<Wait>' * 6,
56
+ ],
57
+ :kickstart_port => '7122',
58
+ :kickstart_timeout => '300',
59
+ :kickstart_file => '',
60
+ :ssh_login_timeout => '10000',
61
+ :ssh_user => 'root',
62
+ :ssh_password => 'vagrant',
63
+ :ssh_key => '',
64
+ :ssh_host_port => '7222',
65
+ :ssh_guest_port => '22',
66
+ :sudo_cmd => "sh '%f'",
67
+ :shutdown_cmd => '/sbin/halt -p',
68
+ :postinstall_files => %w[../openbsd-postinstall.sh],
69
+ :postinstall_timeout => '10000',
70
+ :skip_iso_transfer => true,
71
+ })
@@ -0,0 +1,29 @@
1
+ set -ex
2
+
3
+ date > /etc/vagrant_box_build_time
4
+
5
+ # set pkg path for users
6
+ export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/
7
+ echo "export PKG_PATH=$PKG_PATH" >> /root/.profile
8
+ echo "export PKG_PATH=$PKG_PATH" >> /home/vagrant/.profile
9
+
10
+ # install bash and wget
11
+ pkg_add bash wget
12
+
13
+ # set vagrant shell to bash
14
+ usermod -s /usr/local/bin/bash vagrant
15
+
16
+ # sudo
17
+ echo "# Uncomment to allow people in group wheel to run all commands without a password" >> /etc/sudoers
18
+ echo "%wheel ALL=(ALL) NOPASSWD: SETENV: ALL" >> /etc/sudoers
19
+
20
+ # setup the vagrant key
21
+ mkdir -p /home/vagrant/.ssh
22
+ chmod 700 /home/vagrant/.ssh
23
+ wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
24
+ chmod 600 /home/vagrant/.ssh/authorized_keys
25
+ chown -R vagrant.vagrant /home/vagrant/.ssh
26
+
27
+ perl -pi -e 's/(?<=:maxproc-(?:max|cur)=)\d+(?=:)/1024/' -- /etc/login.conf
28
+
29
+ /sbin/halt -p
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86-darwin'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86_64-darwin'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'amd64-freebsd'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86-freebsd'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86-linux'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86_64-linux'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86-openbsd'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ eval "gem_platform = 'x86_64-openbsd'; #{File.read('image_optim_pack.gemspec')}"
@@ -0,0 +1,41 @@
1
+ # encoding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'image_optim_pack'
5
+ s.version = '0.5.0'
6
+ s.summary = %q{Precompiled binaries for image_optim: advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegtran, optipng, pngcrush, pngquant}
7
+ s.homepage = "http://github.com/toy/#{s.name}"
8
+ s.authors = ['Ivan Kuchin']
9
+ s.license = 'MIT'
10
+
11
+ s.rubyforge_project = s.name
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ if defined?(gem_platform)
15
+ s.platform = gem_platform
16
+
17
+ vendor_dir = {
18
+ 'x86-linux' => 'linux-i686',
19
+ 'x86_64-openbsd' => 'openbsd-amd64',
20
+ }[gem_platform] || begin
21
+ gem_platform.sub(/^x86-/, 'i386-').split('-').reverse.join('-')
22
+ end
23
+ vendor_path = File.join('vendor', vendor_dir)
24
+ fail "#{vendor_path} is not a dir" unless File.directory?(vendor_path)
25
+ s.files.reject! do |path|
26
+ parts = path.split('/')
27
+ parts[0] == 'vendor' && parts[1] != vendor_dir
28
+ end
29
+ end
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = %w[lib]
33
+
34
+ s.add_dependency 'image_optim', '~> 0.19'
35
+ s.add_dependency 'fspath', '>= 2.1', '< 4'
36
+
37
+ s.add_development_dependency 'rspec', '~> 3.0'
38
+ if RUBY_VERSION >= '2.0'
39
+ s.add_development_dependency 'rubocop', '~> 0.47'
40
+ end
41
+ end
@@ -0,0 +1,117 @@
1
+ require 'fspath'
2
+ require 'image_optim/bin_resolver/bin'
3
+
4
+ class ImageOptim
5
+ # Handle selection of directory with binaries most suitable for current
6
+ # operating system and architecture
7
+ module Pack
8
+ # Path to binary, last two parts are expect to be os/arch
9
+ class Path
10
+ # Path provided to initialize as FSPath
11
+ attr_reader :path
12
+
13
+ # Intended os
14
+ attr_reader :os
15
+
16
+ # Inteded architecture
17
+ attr_reader :arch
18
+
19
+ # Receive path, use last part for arch and last but one part for os
20
+ def initialize(path)
21
+ @path = FSPath(path)
22
+ @os, @arch = @path.basename.to_s.split('-', 2)
23
+ end
24
+
25
+ # Return path converted to string
26
+ def to_s
27
+ path.to_s
28
+ end
29
+
30
+ # Cached array of BinResolver::Bin instances for each bin
31
+ def bins
32
+ @bins ||= bin_paths.map do |bin_path|
33
+ BinResolver::Bin.new(bin_path.basename.to_s, bin_path.to_s)
34
+ end
35
+ end
36
+
37
+ # Return true if all bins can execute and return version
38
+ def all_bins_working?
39
+ bins.all?(&:version)
40
+ end
41
+
42
+ # Return true if all bins can't execute and return version
43
+ def all_bins_failing?
44
+ bins.none?(&:version)
45
+ end
46
+
47
+ # List of bins which can execute and return version
48
+ def working_bins
49
+ bins.select(&:version)
50
+ end
51
+
52
+ # List of bins which can't execute and return version
53
+ def failing_bins
54
+ bins.reject(&:version)
55
+ end
56
+
57
+ private
58
+
59
+ # All children except those starting with 'lib'
60
+ def bin_paths
61
+ path.children.reject{ |child| child.basename.to_s =~ /^lib/ }
62
+ end
63
+ end
64
+
65
+ # downcased `uname -s`
66
+ OS = begin
67
+ `uname -s`.strip.downcase
68
+ rescue Errno::ENOENT
69
+ 'unknown'
70
+ end
71
+
72
+ # downcased `uname -m`
73
+ ARCH = begin
74
+ `uname -m`.strip.downcase
75
+ rescue Errno::ENOENT
76
+ 'unknown'
77
+ end
78
+
79
+ # Path to vendor at root of image_optim_pack
80
+ VENDOR_PATH = FSPath('../../../vendor').expand_path(__FILE__)
81
+
82
+ # List of paths
83
+ PATHS = VENDOR_PATH.glob('*-*').map{ |path| Path.new(path) }
84
+
85
+ class << self
86
+ # Return path to directory with binaries
87
+ # Yields debug messages if block given
88
+ def path
89
+ ordered_by_os_arch_match.find do |path|
90
+ yield "image_optim_pack: #{debug_message(path)}" if block_given?
91
+ path.all_bins_working?
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ # Order by match of os and architecture
98
+ def ordered_by_os_arch_match
99
+ PATHS.sort_by do |path|
100
+ [path.os == OS ? 0 : 1, path.arch == ARCH ? 0 : 1]
101
+ end
102
+ end
103
+
104
+ # Messages based on success of getting versions of bins
105
+ def debug_message(path)
106
+ case
107
+ when path.all_bins_working?
108
+ "all bins from #{path} worked"
109
+ when path.all_bins_failing?
110
+ "all bins from #{path} failed"
111
+ else
112
+ "#{path.failing_bins.map(&:name).join(', ')} from #{path} failed"
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1 @@
1
+ require 'image_optim/pack'
data/script/livecheck ADDED
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Get latest version of tools
4
+
5
+ require 'yaml'
6
+ require 'uri'
7
+ require 'net/http'
8
+ require 'rubygems/version'
9
+
10
+ # Compare versions including libjpeg ones (9b <=> 9)
11
+ class Version
12
+ include Comparable
13
+
14
+ attr_reader :string, :parsed
15
+ alias_method :to_s, :string
16
+
17
+ def initialize(string)
18
+ @string = string
19
+ @parsed = begin
20
+ Gem::Version.new(string)
21
+ rescue ArgumentError
22
+ nil
23
+ end
24
+ end
25
+
26
+ def <=>(other)
27
+ if parsed && other.parsed
28
+ parsed <=> other.parsed
29
+ else
30
+ string <=> other.string
31
+ end
32
+ end
33
+ end
34
+
35
+ bare = ARGV.delete('--bare')
36
+
37
+ unless [1, 2].include?(ARGV.length)
38
+ abort 'expected project name and optional current version'
39
+ end
40
+
41
+ def version(string)
42
+ Version.new(string)
43
+ end
44
+
45
+ def get(url)
46
+ uri = URI(url)
47
+
48
+ http = Net::HTTP.new(uri.host, uri.port)
49
+ http.use_ssl = (uri.scheme == 'https')
50
+
51
+ request = Net::HTTP::Get.new(uri.request_uri)
52
+ http.request(request).body
53
+ end
54
+
55
+ name = ARGV[0].downcase
56
+ config = YAML.load(DATA)[name]
57
+ abort "Livecheck for #{name} was not defined" unless config
58
+
59
+ url = config['url']
60
+ version_regex = Regexp.new(config['regexp'])
61
+ current_version = ARGV[1] && version(ARGV[1])
62
+
63
+ data = get(url)
64
+ versions = data.scan(version_regex).uniq.map{ |match| version(match[0]) }
65
+ abort "No versions found for #{name} in data:\n#{data}" if versions.empty?
66
+
67
+ latest_version = versions.max
68
+ case
69
+ when bare
70
+ print latest_version
71
+ when current_version
72
+ if latest_version != current_version
73
+ sign = latest_version > current_version ? '>' : '<'
74
+ puts "#{name} #{latest_version} #{sign} #{current_version}"
75
+ end
76
+ else
77
+ puts "#{name} #{latest_version}"
78
+ end
79
+
80
+ __END__
81
+ advancecomp:
82
+ url: https://github.com/amadvance/advancecomp/releases.atom
83
+ regexp: /amadvance/advancecomp/releases/tag/v(\d+(?:\.\d+)*)
84
+ gifsicle:
85
+ url: https://www.lcdf.org/gifsicle/
86
+ regexp: gifsicle-(\d+(?:\.\d+)*)\.tar\.gz
87
+ jhead:
88
+ url: http://www.sentex.net/~mwandel/jhead/
89
+ regexp: jhead-(\d+(?:\.\d+)*)
90
+ jpegoptim:
91
+ url: https://www.kokkonen.net/tjko/src/
92
+ regexp: jpegoptim-(\d+(?:\.\d+)*)
93
+ jpegarchive:
94
+ url: https://github.com/danielgtaylor/jpeg-archive/releases.atom
95
+ regexp: <title>JPEG-Archive (\d+(?:\.\d+)*)</title>
96
+ libjpeg:
97
+ url: http://www.ijg.org/files/
98
+ regexp: jpegsrc.v(.*?).tar.gz
99
+ libmozjpeg:
100
+ url: https://github.com/mozilla/mozjpeg/releases.atom
101
+ regexp: <title>mozjpeg v(\d+(?:\.\d+)*)</title>
102
+ libpng:
103
+ url: https://sourceforge.net/projects/libpng/rss
104
+ regexp: /libpng\d*/(\d+(?:\.\d+)*)/
105
+ libz:
106
+ url: https://sourceforge.net/projects/libpng/rss?path=/zlib
107
+ regexp: /zlib/(\d+(?:\.\d+)*)/
108
+ optipng:
109
+ url: https://sourceforge.net/projects/optipng/rss
110
+ regexp: /OptiPNG/optipng-(\d+(?:\.\d+)*)/
111
+ pngcrush:
112
+ url: https://sourceforge.net/projects/pmt/rss?path=/pngcrush
113
+ regexp: /pngcrush/(\d+(?:\.\d+)*)/
114
+ pngquant:
115
+ url: https://github.com/pornel/pngquant/releases.atom
116
+ regexp: /pornel/pngquant/releases/tag/(\d+(?:\.\d+)*)
data/script/run ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Build tools on Mac OS X host and in all vms
4
+
5
+ set -e
6
+
7
+ MAKE_TASK='all -j'
8
+
9
+ filters=()
10
+ for arg in "$@"; do
11
+ if [[ "$arg" =~ ^([A-Z_]+)=(.*)$ ]]; then
12
+ eval "$(printf %q=%q "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")"
13
+ else
14
+ filters+=($arg)
15
+ fi
16
+ done
17
+ filters=$(IFS='|'; echo "${filters[*]}")
18
+
19
+ passes-filter() {
20
+ [[ '' = "$filters" ]] || [[ "$1" =~ $filters ]]
21
+ }
22
+
23
+ header() {
24
+ printf '\033[1;7m######## %s ########\033[0m\n' "$1"
25
+ }
26
+
27
+ if [[ `uname -s` != 'Darwin' ]]; then
28
+ echo 'expected to run on Mac OS X'
29
+ exit 1
30
+ fi
31
+
32
+ for arch in i386 x86_64; do
33
+ passes-filter "darwin-$arch" || continue
34
+ header "darwin-$arch"
35
+
36
+ make $MAKE_TASK ARCH=$arch
37
+ done
38
+
39
+ for vm in $(perl -pe "s/.*?'(.+?-.+?)'\s+=>\s+'.+?\/.+?'.*|.*/\$1/" Vagrantfile); do
40
+ passes-filter "$vm" || continue
41
+ header "$vm"
42
+
43
+ [[ -n "$NO_UP" ]] || vagrant up $vm
44
+
45
+ # create ssh config
46
+ ssh_config=.vagrant/ssh_config.$vm
47
+ vagrant ssh-config $vm > $ssh_config
48
+
49
+ # rsync needed files to the box
50
+ mkdir -p vendor/$vm
51
+ rsync -e "ssh -F $ssh_config" -aR --del Makefile download vendor/$vm $vm:/vagrant
52
+
53
+ # sync time and run make
54
+ ssh -F $ssh_config $vm "
55
+ set -e
56
+
57
+ sudo ntpdate pool.ntp.org
58
+
59
+ cd /vagrant
60
+ if make -v 2>&1 | grep -q GNU\ Make; then
61
+ make $MAKE_TASK
62
+ else
63
+ gmake $MAKE_TASK
64
+ fi
65
+ "
66
+
67
+ # rsync files in vendor from the box
68
+ rsync -e "ssh -F $ssh_config" -aR --del $vm:/vagrant/./vendor/$vm .
69
+
70
+ [[ -n "$NO_HALT" ]] || vagrant halt $vm
71
+ done