summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-05-30 02:16:39 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-05-30 02:16:39 -0400
commit2d14c67c743b7cf456bf0a2d7650e24fcbbca261 (patch)
treec247eea818d37e980a3eedba4ec1df6134a01845
parenta116f3f2bdebc24d16743c53cd738f62a56f4787 (diff)
allow subdirectories in tarballs to be specified as the extra component
-rw-r--r--Makefile22
-rwxr-xr-xutils/file2base6
-rwxr-xr-xutils/file2extra6
-rwxr-xr-xutils/file2url7
-rwxr-xr-xutils/spec2file6
5 files changed, 23 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index bceb9a1..c1e3dfa 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,14 @@ build/download/tar/%: .tokens/network
extract: PHONY $(foreach package,$(packages),build/extract/$(shell utils/spec2file '$($(package))'))
-build/extract/git/%:
+# This is a little gross because to get the dependencies right for
+# `git` and `tar`, we need to do a bit more complex processing of
+# `%`/`$*`. We could do that with `.SECONDEXPANSION:`, but that is a
+# whole can of worms. Instead, we use a foreach loop to loop over all
+# possibilities. `svn` doesn't have this issue, because, unlike `git`
+# and `tar`, it's `extra` component is present in `build/download`.
+
+build/extract/git/%: # magic for loop
gitref='$(shell utils/file2extra 'git/$*'|cut -d/ -f1)' && \
gitdir=build/extract/'$(shell utils/file2base 'git/$*')'/$${gitref} && \
rm -rf "$$gitdir" && \
@@ -53,21 +60,24 @@ build/extract/git/%:
( cd "$$gitdir" && git checkout "$$gitref" ); \
} || rm -rf "$$gitdir"
touch '$@'
-$(foreach package,$(packages),$(if $(filter git|%,$($(package))),$(eval \
- build/extract/$(shell utils/spec2file '$($(package))'): \
- build/download/$(shell utils/file2base "$$(utils/spec2file '$($(package))')") \
-)))
build/extract/svn/%: build/download/svn/%
rm -rf '$@'
mkdir -p '$(@D)'
cp -a '$<' '$@'
-build/extract/tar/%: build/download/tar/%
+
+build/extract/tar/%: # magic for loop
rm -rf '$@'
mkdir -p '$@'
cd '$@' && bsdtar --strip-components 1 -xf '$(top)/$<'
cd '$@' && git init && git add . && git commit -q -m 'extracted $(shell utils/file2url 'tar/$*')' # XXX
+
+$(foreach package,$(packages),$(if $(filter-out svn|%,$($(package))),$(eval \
+ build/extract/$(shell utils/spec2file '$($(package))'): \
+ build/download/$(shell utils/file2base "$$(utils/spec2file '$($(package))')") \
+)))
+
# place (patch) ################################################################
place: PHONY $(addprefix,build/compile/,$(packages))
diff --git a/utils/file2base b/utils/file2base
index 17951e0..616bbbf 100755
--- a/utils/file2base
+++ b/utils/file2base
@@ -1,9 +1,5 @@
#!/usr/bin/env bash
IFS=/ read -r type url extra <<<"$*"
-case "$type" in
- git) :;;
- svn) :;;
- tar) url=${url}/${extra};;
-esac
+
echo "${type}/${url}"
diff --git a/utils/file2extra b/utils/file2extra
index 972e5df..1aa588e 100755
--- a/utils/file2extra
+++ b/utils/file2extra
@@ -1,9 +1,5 @@
#!/usr/bin/env bash
IFS=/ read -r type url extra <<<"$*"
-case "$type" in
- git) :;;
- svn) :;;
- tar) extra='';;
-esac
+
echo "${extra}"
diff --git a/utils/file2url b/utils/file2url
index 83f1360..ce0795e 100755
--- a/utils/file2url
+++ b/utils/file2url
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
IFS=/ read -r type url extra <<<"$*"
-case "$type" in
- git|svn) url=${url//^2F//};;
- tar) [[ -z $extra ]] || url=$url/$extra;;
-esac
+
+url=${url//^2F//}
url=${url//^3A/:}
url=${url//^5E/^}
+
echo "${url}"
diff --git a/utils/spec2file b/utils/spec2file
index 2fb1168..e59c5f2 100755
--- a/utils/spec2file
+++ b/utils/spec2file
@@ -1,12 +1,10 @@
#!/usr/bin/env bash
IFS='|' read -r type url extra <<<"$*"
+
url=${url//^/^5E}
url=${url//:/^3A}
-case "$type" in
- git|svn) url=${url//\//^2F};;
- tar) :;;
-esac
+url=${url//\//^2F}
if [[ -z $extra ]]; then
echo "${type}/${url}"