Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X compatibility #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions zerkenv
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ get_cache_or_s3() {
}

update_cache() {
local module found modules="$@" local_modules=$(ls_cache) remote_modules
local module found local_modules=$(ls_cache) remote_modules
remote_modules=$(ls_s3)
if [ $# -eq 0 ]; then
modules=$(sort <(echo "$remote_modules") <(echo "$local_modules") |uniq -d)
fi
for module in $modules; do
for module in "$@"; do
found=$(sort <(echo "$module") <(echo "$remote_modules") |uniq -d)
if ! not_private $module; then
warn "* $module is private so cannot be updated from S3"
Expand All @@ -373,6 +373,7 @@ update_cache() {

rm_cache() {
local module file

for module in "$@"; do
file=$(cache_file $module)
if [ -f "$file" ]; then
Expand Down Expand Up @@ -401,18 +402,22 @@ resolve_dependencies_impl() {
local deps module ZERKENV_DEPENDENCIES

for module in "$@"; do
. <(get_cache_or_s3 $module)
ZERKENV_MODULE_TEMP=$(mktemp)
get_cache_or_s3 $module > $ZERKENV_MODULE_TEMP
source $ZERKENV_MODULE_TEMP
rm $ZERKENV_MODULE_TEMP

for dep in $module $ZERKENV_DEPENDENCIES; do
deps="$deps $dep $module"
done
ZERKENV_DEPENDENCIES=
done

echo "$deps" |tsort
echo "$deps" |tsort | sort
}

resolve_dependencies() {
local i deps prev=$(for i in "$@"; do echo $i; done)
local i deps prev=$(for i in "$@"; do echo $i; done | sort)

export ZERKENV_RESOLVING_DEPENDENCIES=true
while true; do
Expand Down Expand Up @@ -453,10 +458,11 @@ install_bash() {
cat <<'EOT' |envsubst '$prog $name'
$name() {
local OPTIND OPTARG o newshell=false
while getopts "hn" o; do
while getopts "hnv" o; do
case "${o}" in
h) echo "USAGE: $name [-hn] <module>..." ; return ;;
n) newshell=true ;;
v) set -xf ;;
?) return 1 ;;
esac
done
Expand All @@ -465,7 +471,10 @@ $name() {
if $newshell; then
eval "( $name $* ; exec $BASH )"
else
. <(colors=true $prog -d "$@")
local ZERKENV_TEMPFILE=$(mktemp)
colors=true $prog -d "$@" > $ZERKENV_TEMPFILE
. $ZERKENV_TEMPFILE
rm $ZERKENV_TEMPFILE
fi
}
_$prog() {
Expand Down Expand Up @@ -512,7 +521,7 @@ opt_update_cache=false
opt_delete_cache=false
opt_delete_s3=false

while getopts "cdhi:lruw:W:x:X:" o; do
while getopts "cdhi:lruw:W:x:X:v" o; do
case "${o}" in
c) opt_completions=true ; break ;;
d) opt_resolve_deps=true ; break ;;
Expand All @@ -525,6 +534,7 @@ while getopts "cdhi:lruw:W:x:X:" o; do
W) put_s3 $OPTARG ; exit $? ;;
x) opt_delete_cache=true ; : $((OPTIND--)) ; break ;;
X) opt_delete_s3=true ; : $((OPTIND--)) ; break ;;
v) set -xv ; break ;;
?) exit 1 ;;
esac
done
Expand Down