summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2013-11-05 20:47:12 +0000
committerRichard Maw <richard.maw@gmail.com>2013-11-05 20:48:00 +0000
commit2c852a412d923cf71b7747e91696f94ca711ae20 (patch)
treee6cdc56dff3d2bef457fe4ec248c394cc4900d0b
parentb249e5de5119f25e872f5af4f93a810271339bbf (diff)
downloadtar-clone-2c852a412d923cf71b7747e91696f94ca711ae20.tar.bz2
Tidy up to be more useful as a stand-alone tool
-rw-r--r--.gitmodules3
-rw-r--r--Makefile4
m---------lua-archive0
-rwxr-xr-xtar-clone15
-rwxr-xr-xtar-clone.lua (renamed from tarjoin.lua)0
-rwxr-xr-xtarjoin.sh22
6 files changed, 22 insertions, 22 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..ecb5639
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "lua-archive"]
+ path = lua-archive
+ url = https://github.com/brimworks/lua-archive.git
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3a62f44
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+lua-archive/archive.so:
+ cd lua-archive &&\
+ cmake -DLUA_CPATH:string=/usr/local/lib/lua/5.1 &&\
+ make
diff --git a/lua-archive b/lua-archive
new file mode 160000
+Subproject 042b4be1425c11bb9b051609c8ccab68921cefc
diff --git a/tar-clone b/tar-clone
new file mode 100755
index 0000000..7787f96
--- /dev/null
+++ b/tar-clone
@@ -0,0 +1,15 @@
+#!/bin/sh
+# A wrapper to make tar-clone.lua behave like a normal git clone
+# and deal with library paths, so lua-archive does not need to be
+# installed
+
+LUA=lua5.1
+CURDIR=$(readlink -f "$(dirname "$0")")
+LUA_CPATH="$CURDIR/lua-archive/?.so;$($LUA -e'print(package.cpath)')"
+export LUA_CPATH
+
+SOURCE="$1"
+TARGET="$2"
+$LUA "$CURDIR/tar-clone.lua" "$SOURCE" "$TARGET" | tar x
+cd "$TARGET"
+git reset --hard HEAD
diff --git a/tarjoin.lua b/tar-clone.lua
index f89ad26..f89ad26 100755
--- a/tarjoin.lua
+++ b/tar-clone.lua
diff --git a/tarjoin.sh b/tarjoin.sh
deleted file mode 100755
index 481feef..0000000
--- a/tarjoin.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-# CPIO passed through env, so busybox CPIO can be used
-CPIO=${CPIO-cpio}
-REPO=$(readlink -f "${1-foo.bar.baz}")
-APPEND=$(readlink -f "${2-append}")
-OUTDIR="${3-baz}"
-export TMPDIR=`pwd`/tmp
-tmp=`mktemp -d`
-trap 'rm -rf "$tmp"' INT TERM EXIT
-
-cd "$tmp"
-{
- mkdir -p "$OUTDIR/.git" >&2
- find "$OUTDIR"
- rmdir "$OUTDIR/.git" >&2
- ln -sf "$REPO" "$OUTDIR/.git" >&2
- find "$OUTDIR/.git/qux"
- rm "$OUTDIR/.git"
- ln -sf "$APPEND" "$OUTDIR/.git" >&2
- find "$OUTDIR/.git/zip"
-} | ($CPIO -oHnewc)