From 81422ff2821b595b2bc79e1f65f2fbb36319ba91 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Wed, 29 Mar 2017 19:09:38 -0600
Subject: [PATCH] Cleanup tar file method

---
 .gitignore            |  2 ++
 cook.sh               | 39 +++++++++++++++++++++------------------
 recipes/lua/recipe.sh |  3 +--
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore
index bade6d8b3..94e928d68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 build
 repo
+source
+source.tar
 stage
 stage.tar
diff --git a/cook.sh b/cook.sh
index 3ecfa4aee..9a20c173a 100755
--- a/cook.sh
+++ b/cook.sh
@@ -13,7 +13,6 @@ export BINDIR=bin
 export CARGOFLAGS=
 
 set -e
-shopt -s nullglob
 
 function usage {
     echo "cook.sh $1 <op>" >&2
@@ -49,40 +48,44 @@ function op {
             op $1 unfetch
             ;;
         fetch)
-            if [ -z "$GIT" ]
+            if [ -n "$TAR" ]
             then
-                if [ ! -f "$(basename "$SRC")" ]
+                if [ ! -f source.tar ]
                 then
-                    wget "$SRC"
+                    wget "$TAR" -O source.tar
+                fi
+
+                if [ ! -d source ]
+                then
+                    mkdir source
+                    tar xvf source.tar -C source --strip-components 1
                 fi
 
                 rm -rf build
-                tar xvf "$(basename "$SRC")"
-                mv "$DIR" build
-	    else
-                if [ ! -d build ]
+                cp -r source build
+            elif [ -n "$GIT" ]
+            then
+                if [ ! -d source ]
                 then
-                    git clone --recursive "$GIT" build
+                    git clone --recursive "$GIT" source
                 fi
 
-                pushd build > /dev/null
+                pushd source > /dev/null
                 git pull
                 git submodule sync
                 git submodule update --init --recursive
                 popd > /dev/null
-            fi
 
-            for patch in *.patch
-            do
-	        patch -p1 -d build < "$patch"
-            done
+                rm -rf build
+                cp -r source build
+            fi
 
             ;;
         unfetch)
-            rm -rfv build
-            if [ ! -z "$SRC" ]
+            rm -rfv build source
+            if [ -n "$TAR" ]
             then
-                rm -f "$(basename "$SRC")"
+                rm -f source.tar
             fi
             ;;
         version)
diff --git a/recipes/lua/recipe.sh b/recipes/lua/recipe.sh
index bdac657dd..453c9e049 100644
--- a/recipes/lua/recipe.sh
+++ b/recipes/lua/recipe.sh
@@ -1,6 +1,5 @@
 VERSION=5.3.1
-SRC=http://www.lua.org/ftp/lua-$VERSION.tar.gz
-DIR=lua-$VERSION
+TAR=http://www.lua.org/ftp/lua-$VERSION.tar.gz
 
 function recipe_version {
     echo "$VERSION"
-- 
GitLab