From acfa29c106e43aba8a55e8c3ce9d6d65110cce72 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Mon, 4 Aug 2014 14:14:52 +0200
Subject: [PATCH 2/4] Use dpkg-deb instead of manually extracting the deb
 packages

There is no point in accessing the .deb files manually, we are assuming
dpkg-deb, dpkg and apt to be around anyway.

This automatically gives support for the latest deb(5) format.
---
 functions | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/functions b/functions
index 1e1f885..3fe312f 100644
--- a/functions
+++ b/functions
@@ -43,12 +43,7 @@ extract () { (
     p="$(($p + 1))"
     progress "$p" "$#" "Extracting packages"
     info "Extracting $pkg..."
-    if ar -t ./$pkg | grep -q data.tar.gz
-    then
-	ar -p ./$pkg data.tar.gz | zcat | tar -xf -
-    else
-	ar -p ./$pkg data.tar.xz | xzcat | tar -xf -
-    fi
+    dpkg-deb --extract ./$pkg .
   done
   sync
 ); }
@@ -74,11 +69,7 @@ apt_debfor () {
 x_feign_install () {
         local pkg="$1"
         local deb="$(debfor $pkg)"
-        local ver="$(
-            ar -p "$TARGET/$deb" control.tar.gz | zcat |
-                tar -O -xf - control ./control 2>/dev/null |
-                sed -ne 's/^Version: *//Ip' | head -n 1
-        )"
+        local ver="$(dpkg-deb --field "$TARGET/$deb" Version)"
  
         mkdir -p "$TARGET/var/lib/dpkg/info"
  
-- 
2.0.1.570.gc6b0718

