-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(install): clean up conditions and remove manual installs
- Loading branch information
Showing
5 changed files
with
150 additions
and
281 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
#!/bin/sh | ||
|
||
_summarize_custom() { | ||
if test -n "$_CUSTOM"; then | ||
print "$esc_green==>$esc_reset The following installations will be run:" | ||
eval "set -- $_CUSTOM" | ||
for try_run_install__fn in "$@"; do | ||
try_run_install__package_name="$(parse_field "$try_run_install__fn" package_name)" | ||
if test -z "$_CUSTOM"; then | ||
return | ||
fi | ||
|
||
if test -z "$try_run_install__package_name"; then | ||
try_run_install__package_name="$(parse_field "$try_run_install__fn" fn)" | ||
fi | ||
print "$esc_green==>$esc_reset The following installations will be run:" | ||
eval "set -- $_CUSTOM" | ||
for try_run_install__fn in "$@"; do | ||
try_run_install__package_name="$(parse_field "$try_run_install__fn" package_name)" | ||
|
||
print " $esc_blue-$esc_reset $try_run_install__package_name" | ||
done | ||
fi | ||
if test -z "$try_run_install__package_name"; then | ||
try_run_install__package_name="$(parse_field "$try_run_install__fn" fn)" | ||
fi | ||
|
||
print " $esc_blue-$esc_reset $try_run_install__package_name" | ||
done | ||
} | ||
|
||
_run_custom() { | ||
if test -n "$_CUSTOM"; then | ||
step "Performing custom installations..." | ||
eval "set -- $_CUSTOM" | ||
for try_run_install__custom in "$@"; do | ||
try_run_install__fn="$(parse_field "$try_run_install__custom" fn)" | ||
"$try_run_install__fn" | ||
done | ||
if test -z "$_CUSTOM"; then | ||
return | ||
fi | ||
|
||
step "Performing custom installations..." | ||
eval "set -- $_CUSTOM" | ||
for try_run_install__custom in "$@"; do | ||
try_run_install__fn="$(parse_field "$try_run_install__custom" fn)" | ||
"$try_run_install__fn" | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,83 @@ | ||
#!/bin/sh | ||
|
||
_prepare_packages() { | ||
if ! _has_skip package || test -n "$_INDICATED"; then | ||
for try_run_install__package_path in "$HOME/$DOTFILES/packages"/*.sh; do | ||
try_run_install__package=$(basename "$try_run_install__package_path") | ||
try_run_install__package=${try_run_install__package%.sh} | ||
if ! test -d "$HOME/$DOTFILES/packages"; then | ||
warn "No package found" | ||
return | ||
fi | ||
|
||
print_inline "$esc_yellow==>$esc_reset Checking package $try_run_install__package..." | ||
if _has_skip package && test -z "$_INDICATED"; then | ||
return | ||
fi | ||
|
||
# Skip requested packages | ||
if (_has_skip package || _has_skip "$try_run_install__package") && ! _has_indicate "$try_run_install__package"; then | ||
continue | ||
fi | ||
for try_run_install__package_path in "$HOME/$DOTFILES/packages"/*.sh; do | ||
try_run_install__package=$(basename "$try_run_install__package_path") | ||
try_run_install__package=${try_run_install__package%.sh} | ||
|
||
# Package could be loaded from the dependency list | ||
if has_package "$try_run_install__package"; then | ||
continue | ||
fi | ||
print_inline "$esc_yellow==>$esc_reset Checking package $try_run_install__package..." | ||
|
||
_RUNNING="$try_run_install__package" | ||
_FULFILLED="" | ||
# Add package to the loaded list (prevent dependency cycle) | ||
_LOADED=$(_add_to_list "$_LOADED" "$_RUNNING") | ||
. "$try_run_install__package_path" | ||
# Skip requested packages | ||
if (_has_skip package || _has_skip "$try_run_install__package") && ! _has_indicate "$try_run_install__package"; then | ||
continue | ||
fi | ||
|
||
# Remove optional packages from the loaded list | ||
if test "$_FULFILLED" = "optional"; then | ||
try_run_install__new_loaded="" | ||
eval "set -- $_LOADED" | ||
for try_run_install__loaded_package in "$@"; do | ||
if test "$try_run_install__loaded_package" = "$_RUNNING"; then | ||
continue | ||
fi | ||
try_run_install__new_loaded=$(_add_to_list "$try_run_install__new_loaded" "$try_run_install__loaded_package") | ||
done | ||
_LOADED="$try_run_install__new_loaded" | ||
fi | ||
done | ||
fi | ||
# Package could be loaded from the dependency list | ||
if has_package "$try_run_install__package"; then | ||
continue | ||
fi | ||
|
||
_RUNNING="$try_run_install__package" | ||
_FULFILLED="" | ||
# Add package to the loaded list (prevent dependency cycle) | ||
_LOADED=$(_add_to_list "$_LOADED" "$_RUNNING") | ||
. "$try_run_install__package_path" | ||
|
||
# Remove optional packages from the loaded list | ||
if test "$_FULFILLED" = "optional"; then | ||
try_run_install__new_loaded="" | ||
eval "set -- $_LOADED" | ||
for try_run_install__loaded_package in "$@"; do | ||
if test "$try_run_install__loaded_package" = "$_RUNNING"; then | ||
continue | ||
fi | ||
try_run_install__new_loaded=$(_add_to_list "$try_run_install__new_loaded" "$try_run_install__loaded_package") | ||
done | ||
_LOADED="$try_run_install__new_loaded" | ||
fi | ||
done | ||
} | ||
|
||
_summarize_packages() { | ||
if test -n "$_PACKAGES"; then | ||
print "$esc_green==>$esc_reset The following packages will be installed:" | ||
eval "set -- $_PACKAGES" | ||
for try_run_install__package in "$@"; do | ||
try_run_install__manager_name="$(parse_field "$try_run_install__package" manager_name)" | ||
try_run_install__package_name="$(parse_field "$try_run_install__package" package_name)" | ||
if test -z "$try_run_install__manager_name"; then | ||
try_run_install__manager_name="$(parse_field "$try_run_install__package" manager)" | ||
fi | ||
if test -z "$_PACKAGES"; then | ||
return | ||
fi | ||
|
||
if test -z "$try_run_install__package_name"; then | ||
try_run_install__package_name="$(parse_field "$try_run_install__package" package)" | ||
fi | ||
print "$esc_green==>$esc_reset The following packages will be installed:" | ||
eval "set -- $_PACKAGES" | ||
for try_run_install__package in "$@"; do | ||
try_run_install__manager_name="$(parse_field "$try_run_install__package" manager_name)" | ||
try_run_install__package_name="$(parse_field "$try_run_install__package" package_name)" | ||
if test -z "$try_run_install__manager_name"; then | ||
try_run_install__manager_name="$(parse_field "$try_run_install__package" manager)" | ||
fi | ||
|
||
if test -n "$try_run_install__manager_name"; then | ||
try_run_install__manager_name=" ${esc_blue}via$esc_reset $try_run_install__manager_name" | ||
fi | ||
if test -z "$try_run_install__package_name"; then | ||
try_run_install__package_name="$(parse_field "$try_run_install__package" package)" | ||
fi | ||
|
||
print " $esc_blue-$esc_reset $try_run_install__package_name$try_run_install__manager_name" | ||
done | ||
fi | ||
if test -n "$try_run_install__manager_name"; then | ||
try_run_install__manager_name=" ${esc_blue}via$esc_reset $try_run_install__manager_name" | ||
fi | ||
|
||
print " $esc_blue-$esc_reset $try_run_install__package_name$try_run_install__manager_name" | ||
done | ||
} | ||
|
||
_run_packages() { | ||
if test -n "$_PACKAGES"; then | ||
eval "set -- $_PACKAGES" | ||
install_packages "$@" | ||
if test -z "$_PACKAGES"; then | ||
return | ||
fi | ||
|
||
eval "set -- $_PACKAGES" | ||
install_packages "$@" | ||
} |
Oops, something went wrong.