diff options
author | kylo252 <[email protected]> | 2022-10-31 16:27:12 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-31 16:27:12 +0100 |
commit | 74ad56ff68f9853a3cdb6004bf01162911bcadd6 (patch) | |
tree | acc38539db66a6d8dba7ca2d6e3f273ff6a3b125 /utils | |
parent | 3d6338e16ee7f03de3de303e2de6d5ec5e37ba93 (diff) |
refactor(installer): skip unstable headless update (#3338)
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ci/verify_plugins.lua | 15 | ||||
-rwxr-xr-x | utils/installer/install.sh | 62 |
2 files changed, 37 insertions, 40 deletions
diff --git a/utils/ci/verify_plugins.lua b/utils/ci/verify_plugins.lua index cecb01db..d009cbda 100644 --- a/utils/ci/verify_plugins.lua +++ b/utils/ci/verify_plugins.lua @@ -26,6 +26,20 @@ end local is_directory = require("lvim.utils").is_directory -- see packer.init() local packdir = join_paths(get_runtime_dir(), "site", "pack", "packer") + +local verify_packer = function() + if not is_directory(packdir) then + io.write "Packer not installed!" + os.exit(1) + end + local status_ok, packer = pcall(require, "packer") + if status_ok and packer then + return + end + io.write "Packer not installed!" + os.exit(1) +end + local packer_config = { opt_dir = join_paths(packdir, "opt"), start_dir = join_paths(packdir, "start") } local is_optional = function(spec) return spec.opt or spec.event or spec.cmd or spec.module @@ -130,5 +144,6 @@ local function verify_core_plugins(verbose) end) end +verify_packer() verify_core_plugins() vim.cmd "q" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 87f60fd4..872d8403 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -eo pipefail +OS="$(uname -s)" + #Set branch to master unless specified by the user declare -x LV_BRANCH="${LV_BRANCH:-"master"}" declare -xr LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" @@ -32,6 +34,7 @@ declare -a __lvim_dirs=( "$LUNARVIM_CONFIG_DIR" "$LUNARVIM_RUNTIME_DIR" "$LUNARVIM_CACHE_DIR" + "$LUNARVIM_BASE_DIR" ) declare -a __npm_deps=( @@ -135,14 +138,12 @@ function main() { fi fi - backup_old_config + remove_old_cache_files verify_lvim_dirs if [ "$ARGS_LOCAL" -eq 1 ]; then link_local_lvim - elif [ -d "$LUNARVIM_BASE_DIR" ]; then - validate_lunarvim_files else clone_lvim fi @@ -156,7 +157,6 @@ function main() { } function detect_platform() { - OS="$(uname -s)" case "$OS" in Linux) if [ -f "/etc/arch-release" ] || [ -f "/etc/artix-release" ]; then @@ -219,15 +219,6 @@ function verify_core_plugins() { echo "Verification complete!" } -function validate_lunarvim_files() { - local verify_version_cmd='if v:errmsg != "" | cquit | else | quit | endif' - if ! "$INSTALL_PREFIX/bin/lvim" --headless -c 'LvimUpdate' -c "$verify_version_cmd" &>/dev/null; then - msg "Removing old installation files" - rm -rf "$LUNARVIM_BASE_DIR" - clone_lvim - fi -} - function validate_install_prefix() { local prefix="$1" case $PATH in @@ -353,43 +344,37 @@ function install_rust_deps() { echo "All Rust dependencies are successfully installed" } -function verify_lvim_dirs() { - if [ "$ARGS_OVERWRITE" -eq 1 ]; then - for dir in "${__lvim_dirs[@]}"; do - [ -d "$dir" ] && rm -rf "$dir" - done - fi - - for dir in "${__lvim_dirs[@]}"; do - mkdir -p "$dir" - done -} - -function backup_old_config() { - local src="$LUNARVIM_CONFIG_DIR" +function __backup_dir() { + local src="$1" if [ ! -d "$src" ]; then return fi mkdir -p "$src.old" - touch "$src/ignore" msg "Backing up old $src to $src.old" if command -v rsync &>/dev/null; then - rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$src"/ "$src.old" + rsync --archive --quiet --backup --partial --copy-links --cvs-exclude "$src"/ "$src.old" else - OS="$(uname -s)" case "$OS" in - Linux | *BSD) - cp -r "$src/"* "$src.old/." - ;; Darwin) cp -R "$src/"* "$src.old/." ;; *) - echo "OS $OS is not currently supported." + cp -r "$src/"* "$src.old/." ;; esac fi - msg "Backup operation complete" +} + +function verify_lvim_dirs() { + for dir in "${__lvim_dirs[@]}"; do + if [ -d "$dir" ]; then + if [ "$ARGS_OVERWRITE" -eq 0 ]; then + __backup_dir "$dir" + fi + rm -rf "$dir" + fi + mkdir -p "$dir" + done } function clone_lvim() { @@ -406,8 +391,8 @@ function link_local_lvim() { # Detect whether it's a symlink or a folder if [ -d "$LUNARVIM_BASE_DIR" ]; then - echo "Removing old installation files" - rm -rf "$LUNARVIM_BASE_DIR" + msg "Moving old files to ${LUNARVIM_BASE_DIR}.old" + mv "$LUNARVIM_BASE_DIR" "${LUNARVIM_BASE_DIR}".old fi echo " - $BASEDIR -> $LUNARVIM_BASE_DIR" @@ -433,8 +418,6 @@ function remove_old_cache_files() { function setup_lvim() { - remove_old_cache_files - msg "Installing LunarVim shim" setup_shim @@ -456,7 +439,6 @@ function setup_lvim() { } function create_desktop_file() { - OS="$(uname -s)" # TODO: Any other OSes that use desktop files? ([ "$OS" != "Linux" ] || ! command -v xdg-desktop-menu &>/dev/null) && return echo "Creating desktop file" |