2015-12-20 17:57:51 -02:00
|
|
|
function __omf.packages.install.success
|
|
|
|
echo (omf::em)"✔ $argv successfully installed."(omf::off)
|
|
|
|
end
|
2015-08-29 19:24:15 -03:00
|
|
|
|
2015-12-20 17:57:51 -02:00
|
|
|
function __omf.packages.install.error
|
2016-12-17 20:26:46 -06:00
|
|
|
echo (omf::err)"Could not install $argv."(omf::off) >&2
|
2015-12-20 17:57:51 -02:00
|
|
|
end
|
|
|
|
|
|
|
|
function __omf.packages.install.error.already
|
2016-12-17 20:26:46 -06:00
|
|
|
echo (omf::err)"Error: $argv already installed."(omf::off) >&2
|
2015-12-20 17:57:51 -02:00
|
|
|
end
|
|
|
|
|
|
|
|
function omf.packages.install -a name_or_url
|
2017-02-04 21:49:39 -06:00
|
|
|
if set -l props (omf.index.stat $name_or_url type repository)
|
|
|
|
set package_type $props[1]
|
2015-09-03 19:49:01 +01:00
|
|
|
set name $name_or_url
|
2017-02-04 21:49:39 -06:00
|
|
|
set url $props[2]
|
2015-08-27 14:05:19 -06:00
|
|
|
else
|
2015-12-20 17:57:51 -02:00
|
|
|
set name (omf.packages.name $name_or_url)
|
2015-09-03 19:49:01 +01:00
|
|
|
set url $name_or_url
|
2015-08-27 14:05:19 -06:00
|
|
|
end
|
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
if contains -- $name (omf.packages.list)
|
|
|
|
__omf.packages.install.error.already "$name_or_url"
|
2016-08-29 22:18:27 -05:00
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
2016-07-18 17:57:54 -05:00
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
echo (omf::dim)"Installing package $name"(omf::off)
|
2016-07-18 17:57:54 -05:00
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
set -l install_dir $OMF_PATH/pkg/$name
|
2015-09-03 19:49:01 +01:00
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
# Clone the package repository.
|
|
|
|
if not omf.repo.clone $url $install_dir
|
|
|
|
__omf.packages.install.error "$name"
|
|
|
|
return $OMF_UNKNOWN_ERR
|
|
|
|
end
|
|
|
|
|
|
|
|
# If we don't know the package type yet, check if the package is a theme.
|
|
|
|
if not set -q package_type
|
|
|
|
echo $url | grep -q theme-
|
|
|
|
and set package_type theme
|
|
|
|
or set package_type plugin
|
|
|
|
end
|
2016-08-29 22:18:27 -05:00
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
# If the package is a theme, move it to the themes directory.
|
|
|
|
if test $package_type = theme
|
|
|
|
test -d $OMF_PATH/themes
|
|
|
|
or command mkdir -p $OMF_PATH/themes
|
|
|
|
|
|
|
|
command mv $install_dir $OMF_PATH/themes/$name
|
|
|
|
set install_dir $OMF_PATH/themes/$name
|
|
|
|
|
|
|
|
omf.bundle.add theme $name_or_url
|
2016-08-29 22:18:27 -05:00
|
|
|
else
|
2017-02-04 21:49:39 -06:00
|
|
|
omf.bundle.add package $name_or_url
|
|
|
|
end
|
|
|
|
|
|
|
|
omf.bundle.install $install_dir/bundle
|
|
|
|
|
|
|
|
# Run the install hook.
|
|
|
|
if not omf.packages.run_hook $install_dir install
|
|
|
|
__omf.packages.install.error "$name"
|
2016-08-29 22:18:27 -05:00
|
|
|
return $OMF_UNKNOWN_ERR
|
2015-08-27 14:05:19 -06:00
|
|
|
end
|
2015-10-04 19:36:41 -03:00
|
|
|
|
2017-02-04 21:49:39 -06:00
|
|
|
__omf.packages.install.success "$name"
|
|
|
|
|
2015-10-04 19:36:41 -03:00
|
|
|
return 0
|
2015-08-27 14:05:19 -06:00
|
|
|
end
|