Last active
February 14, 2017 14:26
-
-
Save dgodd/53ae83b5894d4241b9af26eec0db805f to your computer and use it in GitHub Desktop.
Create a tar file with all of the missing package files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open3' | |
## To Use | |
## mkdir /tmp/dpkgtar | |
## cd /tmp/dpkgtar | |
## docker run -w /dpkgtar -v /tmp/dpkgtar:/dpkgtar -it cloudfoundry/cflinuxfs2 bash | |
## curl https://gist.githubusercontent.com/dgodd/53ae83b5894d4241b9af26eec0db805f/raw/e00e7ee66281578ed49d84464614b4b298cb02f0/dpkgtar.rb -o /dpkgtar/dpkgtar.rb | |
## ruby ./dpkgtar.rb [PACKAGES] ## eg. ghostscript libcupsfilters1 libcupsimage2 libgs9 libgs9-common libijs-0.35 libjbig2dec0 libpaper-utils libpaper1 poppler-data | |
## | |
## Then copy dpkgfiles.tgz to your app, and make extracting it the first thing the start command does. | |
packages = ARGV | |
_, status = Open3.capture2(*(%w(apt-get update))) | |
raise "Could not update packages" unless status.success? | |
_, status = Open3.capture2(*(%w(apt-get -fy install) + packages)) | |
raise "Could not install packages" unless status.success? | |
files, status = Open3.capture2('dpkg-query', '-L', *packages) | |
raise "Could not find files" unless status.success? | |
files = files.split(/\n/) | |
files = files.reject{ |n| n =~ %r{/doc/} || n =~ %r{/man/} } | |
files = files.select { |n| File.file?(n) } | |
# files.sort.each { |n| puts n } | |
files, status = Open3.capture2('tar', '-zcf', 'dpkgfiles.tgz', *files) | |
raise "Could not tar files" unless status.success? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment