2015-12-21 03:57:51 +08:00
|
|
|
function __omf.packages.install.success
|
|
|
|
echo (omf::em)"✔ $argv successfully installed."(omf::off)
|
|
|
|
end
|
2015-08-30 06:24:15 +08:00
|
|
|
|
2015-12-21 03:57:51 +08:00
|
|
|
function __omf.packages.install.error
|
|
|
|
echo (omf::err)"Could not install $argv."(omf::off) 1^&2
|
|
|
|
end
|
|
|
|
|
|
|
|
function __omf.packages.install.error.already
|
|
|
|
echo (omf::err)"Error: $argv already installed."(omf::off) 1^&2
|
|
|
|
end
|
|
|
|
|
|
|
|
function omf.packages.install -a name_or_url
|
2015-08-30 06:24:15 +08:00
|
|
|
|
2015-09-04 02:49:01 +08:00
|
|
|
if test \( -e $OMF_PATH/db/themes/$name_or_url \) -o (echo $name_or_url | grep theme-)
|
|
|
|
set install_type "theme"
|
|
|
|
set parent_path "themes"
|
|
|
|
else
|
|
|
|
set install_type "package"
|
|
|
|
set parent_path "pkg"
|
2015-08-28 04:05:19 +08:00
|
|
|
end
|
2015-08-29 00:08:40 +08:00
|
|
|
|
2015-08-28 04:05:19 +08:00
|
|
|
if test -e $OMF_PATH/db/$parent_path/$name_or_url
|
2015-09-04 02:49:01 +08:00
|
|
|
set name $name_or_url
|
2015-12-26 00:02:44 +08:00
|
|
|
set url (cat $OMF_PATH/db/$parent_path/$name)
|
2015-08-28 04:05:19 +08:00
|
|
|
else
|
2015-12-21 03:57:51 +08:00
|
|
|
set name (omf.packages.name $name_or_url)
|
2015-09-04 02:49:01 +08:00
|
|
|
set url $name_or_url
|
2015-08-28 04:05:19 +08:00
|
|
|
end
|
|
|
|
|
2015-09-04 02:49:01 +08:00
|
|
|
if test -e $OMF_PATH/$parent_path/$name
|
|
|
|
if test "$install_type" = theme
|
2015-12-21 03:57:51 +08:00
|
|
|
omf.theme.set $name
|
2015-09-04 02:49:01 +08:00
|
|
|
else
|
2015-12-21 03:57:51 +08:00
|
|
|
__omf.packages.install.error.already "$install_type $name_or_url"
|
2015-09-04 02:49:01 +08:00
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
2015-08-28 04:05:19 +08:00
|
|
|
else
|
2015-09-04 02:49:01 +08:00
|
|
|
echo (omf::dim)"Installing $install_type $name"(omf::off)
|
|
|
|
|
|
|
|
if omf.repo.clone $url $OMF_PATH/$parent_path/$name
|
2015-11-02 07:05:52 +08:00
|
|
|
omf.bundle.install $OMF_PATH/$parent_path/$name/bundle
|
2015-09-08 06:34:11 +08:00
|
|
|
omf.bundle.add $install_type $name_or_url
|
2015-12-21 03:57:51 +08:00
|
|
|
__omf.packages.install.success "$install_type $name"
|
2015-09-04 02:49:01 +08:00
|
|
|
|
|
|
|
if test "$install_type" = theme
|
2015-12-21 03:57:51 +08:00
|
|
|
omf.theme.set $name
|
2015-09-04 02:49:01 +08:00
|
|
|
end
|
2015-08-30 06:24:15 +08:00
|
|
|
else
|
2015-12-21 03:57:51 +08:00
|
|
|
__omf.packages.install.error "$install_type $name"
|
2015-10-05 06:36:41 +08:00
|
|
|
return $OMF_UNKNOWN_ERR
|
2015-08-28 04:05:19 +08:00
|
|
|
end
|
|
|
|
end
|
2015-10-05 06:36:41 +08:00
|
|
|
|
|
|
|
return 0
|
2015-08-28 04:05:19 +08:00
|
|
|
end
|