]> git.e2factory.org Git - e2factory.git/commitdiff
collect_project: handle .tar.bz2 and .tar chroot files
authorGordon Hecker <gh@emlix.com>
Thu, 14 Jan 2010 10:33:03 +0000 (11:33 +0100)
committerGordon Hecker <gh@emlix.com>
Fri, 12 Feb 2010 09:51:57 +0000 (10:51 +0100)
Signed-off-by: Gordon Hecker <gh@emlix.com>
generic/e2lib.lua
local/e2build.lua

index b09bc401ef2baf32555c071af402edbb0135086f..c55bb17987774cfbb75c631bdf04e4740f30dda3 100644 (file)
@@ -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
index eee75870724f2e6c28083b54866d966381d9a39c..7322c7a579a07d085273cde709bb73370977b209 100644 (file)
@@ -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 <path> <tartype> <file>
        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