From d1ebf46fce52b17c3ae12fdb820f2daeffd967c3 Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Thu, 14 Jan 2010 11:33:03 +0100 Subject: [PATCH] collect_project: handle .tar.bz2 and .tar chroot files Signed-off-by: Gordon Hecker --- generic/e2lib.lua | 19 +++++++++++++++++++ local/e2build.lua | 21 ++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/generic/e2lib.lua b/generic/e2lib.lua index b09bc40..c55bb17 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -644,6 +644,25 @@ function e2lib.tartype(path) return c end +--- translate filename suffixes to valid tartypes for e2-su-2.2 +-- @filename string: filename +-- @return string: tartype, or nil on failure +-- @return an error object on failure +function e2lib.tartype_by_suffix(filename) + local tartype + if filename:match("tgz$") or filename:match("tar.gz$") then + tartype = "tar.gz" + elseif filename:match("tar.bz2$") then + tartype = "tar.bz2" + elseif filename:match("tar$") then + tartype = "tar" + else + e = new_error("unknown suffix for filename: %s", filename) + return false, e + end + return tartype +end + -- generates a command to unpack an archive file -- physpath is the current location and filename to be unpacked later -- virtpath is the location and name of the file at the time of unpacking diff --git a/local/e2build.lua b/local/e2build.lua index eee7587..7322c7a 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -274,15 +274,9 @@ function e2build.setup_chroot(info, r, return_flags) end end local tartype - if path:match("tgz$") or path:match("tar.gz$") then - tartype = "tar.gz" - elseif path:match("tar.bz2$") then - tartype = "tar.bz2" - elseif path:match("tar$") then - tartype = "tar" - else - e:append("unknown archive type for chroot file: %s", path) - return false, e + tartype, re = e2lib.tartype_by_suffix(path) + if not tartype then + return false, e:cat(re) end -- e2-su extract_tar_2_3 local args = string.format("extract_tar_2_3 '%s' '%s' '%s'", @@ -1037,10 +1031,15 @@ function e2build.collect_project(info, r, return_flags) "\tsha1sum -c '%s'\n", e2lib.basename(checksum_file))) end + local tartype + tartype, re = e2lib.tartype_by_suffix(file.location) + if not tartype then + return false, e:cat(re) + end makefile:write(string.format( "\te2-su-2.2 extract_tar_2_3 $(chroot_base) ".. - "\"tar.gz\" '%s'\n", - e2lib.basename(file.location))) + "\"%s\" '%s'\n", + tartype, e2lib.basename(file.location))) end makefile:close() end -- 2.39.5