diff options
-rw-r--r-- | Makefile | 22 | ||||
-rwxr-xr-x | utils/file2base | 6 | ||||
-rwxr-xr-x | utils/file2extra | 6 | ||||
-rwxr-xr-x | utils/file2url | 7 | ||||
-rwxr-xr-x | utils/spec2file | 6 |
5 files changed, 23 insertions, 24 deletions
@@ -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}" |