Skip to content

Commit

Permalink
dot: Move print_error_logs into a script
Browse files Browse the repository at this point in the history
  • Loading branch information
OmeGak committed Jun 5, 2015
1 parent 4e81cd9 commit 99a74da
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
30 changes: 30 additions & 0 deletions .dot/bin/plogs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Pretty print error report for failed topics

source $DOT/functions/join

function print_error_logs() {
msg="There were some errors in: ${failing_topics[@]}"
pprint fail "${msg}"
joined_topics=$(join \| ${failing_topics[@]})
error_logs=$(find -E -L /tmp -maxdepth 1 -regex ".*(${joined_topics})${logfile_suffix}")
for logfile in ${error_logs}; do pprint error "${logfile}"; done
}

function usage() {
echo "usage: $0 logsuffix topic1 [topic2 ...]"
echo " logsuffix: suffix of the install log file to be listed"
echo " topic1, ...: list of topics that failed to install"
}

if [[ $# < 2 ]]; then
usage
exit 1
fi

logfile_suffix=$1; shift
failing_topics=("$@")

print_error_logs ${logfile_suffix} "${failing_topics}"
pprint flush
exit 0
15 changes: 7 additions & 8 deletions .dot/install
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/env bash
#
# Run all topic installers.

pprint intro 'Running installers'
# Run all topic installers

# Init environment
source $HOME/.dotfiles/.dot/util/env

pprint intro 'Running installers'

# Prepare logs
logfile_suffix='.install.dot.log'
find -L /tmp -maxdepth 1 -name *$logfile_suffix | while read logfile; do rm "$logfile"; done
logsuffix='.install.dot.log'
find -L /tmp -maxdepth 1 -name *$logsuffix | while read logfile; do rm "$logfile"; done

# Find and run install scripts
for installer in `find $DOT -maxdepth 2 -name install.sh`; do
topic=`basename $(dirname $installer)`
export DOT_TOPIC_LOGFILE_SUFFIX=$topic$logfile_suffix
export DOT_TOPIC_LOGFILE_SUFFIX=$topic$logsuffix
pprint info "Installing stuff for $topic..."
sh -c "${installer}"
[[ $? == 0 ]] && pprint ok "All is done"
Expand All @@ -24,7 +23,7 @@ done

# Show summary
if [[ $errors ]]; then
print_error_logs $errors $logfile_suffix
plogs ${logsuffix} ${errors[@]}
else
pprint success "Everything installed like a charm!"
fi
Expand Down
13 changes: 6 additions & 7 deletions .dot/install-deps
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/usr/bin/env bash
#
# Checks and install dependencies for the install step.

pprint intro 'Checking dependencies'

# Init environment
source $HOME/.dotfiles/.dot/util/env

pprint intro 'Checking dependencies'

# Prepare logs
logfile_suffix='.install.dep.dot.log'
find -L /tmp -maxdepth 1 -name *$logfile_suffix | while read logfile; do rm "$logfile"; done
logsuffix='.install.dep.dot.log'
find -L /tmp -maxdepth 1 -name *$logsuffix | while read logfile; do rm "$logfile"; done

# TODO: define order of dependencies (python depends on homebrew)
# Find and run dependency install scripts
for script in `find $DOT -maxdepth 2 -name install.dep.sh`; do
topic=`basename $(dirname ${script})`
export DOT_TOPIC_LOGFILE_SUFFIX=$topic$logfile_suffix
export DOT_TOPIC_LOGFILE_SUFFIX=$topic$logsuffix
pprint info "Checking dependencies from $topic..."
sh -c "$script"
[[ $? == 0 ]] && pprint ok "All is ready"
Expand All @@ -25,7 +24,7 @@ done

# Show summary
if [[ $errors ]]; then
print_error_logs $errors $logfile_suffix
plogs ${logsuffix} ${errors[@]}
else
pprint success "All dependencies are ready"
fi
Expand Down
1 change: 0 additions & 1 deletion .dot/util/env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

export DOT=$HOME/.dotfiles
export PATH="$DOT/.dot/bin:$DOT/bin:$PATH"
source $DOT/.dot/util/print_error_logs
13 changes: 0 additions & 13 deletions .dot/util/print_error_logs

This file was deleted.

0 comments on commit 99a74da

Please sign in to comment.