From 877bdb13b510d0232aea1e4cad63e569ef29d0e6 Mon Sep 17 00:00:00 2001 From: Braxton Householder Date: Mon, 24 Feb 2020 09:36:48 -0700 Subject: [PATCH] Applying original repos PR 158 https://github.com/krobertson/deb-s3/pull/158 --- lib/deb/s3/package.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/deb/s3/package.rb b/lib/deb/s3/package.rb index 3d6630c..7dcb5db 100644 --- a/lib/deb/s3/package.rb +++ b/lib/deb/s3/package.rb @@ -59,16 +59,22 @@ def extract_control(package) if system("which dpkg > /dev/null 2>&1") `dpkg -f #{package}` else + # use ar to determine control file name (control.ext) + package_files = `ar t #{package}` + control_file = package_files.split("\n").select do |file| + file.start_with?("control.") + end.first + # ar fails to find the control.tar.gz tarball within the .deb # on Mac OS. Try using ar to list the control file, if found, # use ar to extract, otherwise attempt with tar which works on OS X. - extract_control_tarball_cmd = "ar p #{package} control.tar.gz" + extract_control_tarball_cmd = "ar p #{package} #{control_file}" begin - safesystem("ar t #{package} control.tar.gz &> /dev/null") + safesystem("ar t #{package} #{control_file} &> /dev/null") rescue SafeSystemError warn "Failed to find control data in .deb with ar, trying tar." - extract_control_tarball_cmd = "tar zxf #{package} --to-stdout control.tar.gz" + extract_control_tarball_cmd = "tar zxf #{package} --to-stdout #{control_file}" end Dir.mktmpdir do |path|