mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 12:27:01 +08:00
install.sh: autodep, improve note (#22)
* install.sh: --auto * ci: test --auto * ci: remove dep when test --auto * debug * ok. improve the install notes
This commit is contained in:
parent
5b00add073
commit
6dce3cfa18
40
.github/workflows/test.yml
vendored
40
.github/workflows/test.yml
vendored
|
@ -9,8 +9,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt-get update
|
||||||
sudo apt install -y git python3 python3-pip zsh curl inetutils-ping
|
sudo apt-get install -y git python3 python3-pip zsh curl inetutils-ping
|
||||||
sudo pip3 install requests
|
sudo pip3 install requests
|
||||||
|
|
||||||
- name: checkout repo
|
- name: checkout repo
|
||||||
|
@ -22,8 +22,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
rev=`git rev-parse HEAD`
|
rev=`git rev-parse HEAD`
|
||||||
pwd
|
pwd
|
||||||
export DFS_NO_COMPILE=1 DFS_DEV=1
|
export DFS_NO_COMPILE=1
|
||||||
./install.sh
|
./install.sh -d
|
||||||
test `git rev-parse HEAD` = "$rev"
|
test `git rev-parse HEAD` = "$rev"
|
||||||
|
|
||||||
- name: antigen build
|
- name: antigen build
|
||||||
|
@ -70,8 +70,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
rev=`git rev-parse HEAD`
|
rev=`git rev-parse HEAD`
|
||||||
pwd
|
pwd
|
||||||
export DFS_NO_COMPILE=1 DFS_DEV=1
|
export DFS_NO_COMPILE=1
|
||||||
./install.sh
|
./install.sh -d
|
||||||
test `git rev-parse HEAD` = "$rev"
|
test `git rev-parse HEAD` = "$rev"
|
||||||
|
|
||||||
- name: antigen build
|
- name: antigen build
|
||||||
|
@ -98,3 +98,31 @@ jobs:
|
||||||
- name: run tests
|
- name: run tests
|
||||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
run: source tools/test.zsh
|
run: source tools/test.zsh
|
||||||
|
|
||||||
|
test-autodep:
|
||||||
|
name: test of auto-install dependencies
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: remove dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get -y remove curl vim
|
||||||
|
|
||||||
|
- name: checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: install dfs
|
||||||
|
run: |
|
||||||
|
rev=`git rev-parse HEAD`
|
||||||
|
export DFS_NO_COMPILE=1
|
||||||
|
./install.sh -d -a
|
||||||
|
test `git rev-parse HEAD` = "$rev"
|
||||||
|
|
||||||
|
- name: antigen build with DFS_NO_WALL
|
||||||
|
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||||
|
env:
|
||||||
|
DFS_NO_WALL: 1
|
||||||
|
run: |
|
||||||
|
echo $SHELL
|
||||||
|
antigen list
|
||||||
|
|
51
install.sh
51
install.sh
|
@ -26,9 +26,47 @@ declare -a HOME_SYMLINKS_DST
|
||||||
HOME_SYMLINKS_SRC[0]=".ssh/authorized_keys2"
|
HOME_SYMLINKS_SRC[0]=".ssh/authorized_keys2"
|
||||||
HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2"
|
HOME_SYMLINKS_DST[0]=".ssh/authorized_keys2"
|
||||||
|
|
||||||
|
install_dependencies()
|
||||||
|
{
|
||||||
|
fmt_note "installing dependencies ..."
|
||||||
|
case $(get_os_type) in
|
||||||
|
"linux" )
|
||||||
|
case $(get_linux_dist) in
|
||||||
|
"ubuntu"|"debian" )
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y git zsh bash tmux vim python3 python3-pip curl inetutils-ping
|
||||||
|
;;
|
||||||
|
"alpine" )
|
||||||
|
$SUDO apk update
|
||||||
|
$SUDO apk add zsh bash git tmux vim curl python3 py3-pip fzf iputils coreutils
|
||||||
|
;;
|
||||||
|
* ) fmt_error "dfs auto-install is not implemented on linux distribution: $(get_linux_dist)"
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"macos" )
|
||||||
|
$SUDO brew update
|
||||||
|
$SUDO brew install git python3 zsh curl tmux vim
|
||||||
|
;;
|
||||||
|
"msys" )
|
||||||
|
pacman -Syu
|
||||||
|
pacman -S tmux git zsh bash curl vim python3 python3-pip
|
||||||
|
SUDO=""
|
||||||
|
;;
|
||||||
|
* ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_type)"
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ -x $(command -v pip3) ]]; then
|
||||||
|
$SUDO pip3 install requests
|
||||||
|
elif [[ -x $(command -v pip) ]]; then
|
||||||
|
$SUDO pip install requests
|
||||||
|
else
|
||||||
|
fmt_error "pip3 and pip not found. is pip correctly installed?"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
preinstall_check()
|
preinstall_check()
|
||||||
{
|
{
|
||||||
|
fmt_note "checking requirements ..."
|
||||||
mandatory_commands=( "git" "zsh" "curl" "ping" )
|
mandatory_commands=( "git" "zsh" "curl" "ping" )
|
||||||
optional_commands=( "python3" "vim" "tmux" )
|
optional_commands=( "python3" "vim" "tmux" )
|
||||||
for i in "${mandatory_commands[@]}"; do
|
for i in "${mandatory_commands[@]}"; do
|
||||||
|
@ -53,10 +91,11 @@ preinstall_check()
|
||||||
|
|
||||||
install_file_content()
|
install_file_content()
|
||||||
{
|
{
|
||||||
|
fmt_note "installing file content ..."
|
||||||
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
|
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
|
||||||
local filename="$HOME/${HOME_FILES_PATH[$i]}"
|
local filename="$HOME/${HOME_FILES_PATH[$i]}"
|
||||||
local content=${HOME_FILES_CONTENT[$i]}
|
local content=${HOME_FILES_CONTENT[$i]}
|
||||||
fmt_note "installing \"$content\" into \"$filename\" ..."
|
fmt_info "installing \"$content\" into \"$filename\" ..."
|
||||||
mkdir -p $(dirname "$filename")
|
mkdir -p $(dirname "$filename")
|
||||||
if [ ! -f "$filename" ]; then
|
if [ ! -f "$filename" ]; then
|
||||||
touch $filename
|
touch $filename
|
||||||
|
@ -67,10 +106,11 @@ install_file_content()
|
||||||
|
|
||||||
uninstall_file_content()
|
uninstall_file_content()
|
||||||
{
|
{
|
||||||
|
fmt_note "uninstalling file content ..."
|
||||||
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
|
for ((i=0; i<${#HOME_FILES_PATH[@]}; i++)); do
|
||||||
local filename="$HOME/${HOME_FILES_PATH[$i]}"
|
local filename="$HOME/${HOME_FILES_PATH[$i]}"
|
||||||
local content=${HOME_FILES_CONTENT[$i]}
|
local content=${HOME_FILES_CONTENT[$i]}
|
||||||
fmt_note "removing \"$content\" from \"$filename\" ..."
|
fmt_info "removing \"$content\" from \"$filename\" ..."
|
||||||
if [ -f "$filename" ]; then
|
if [ -f "$filename" ]; then
|
||||||
grep -vxF -- "$content" "$filename" | tee "$filename"
|
grep -vxF -- "$content" "$filename" | tee "$filename"
|
||||||
fi
|
fi
|
||||||
|
@ -79,10 +119,11 @@ uninstall_file_content()
|
||||||
|
|
||||||
install_symlink()
|
install_symlink()
|
||||||
{
|
{
|
||||||
|
fmt_note "installing symlinks ..."
|
||||||
for ((i=0; i<${#HOME_SYMLINKS_SRC[@]}; i++)); do
|
for ((i=0; i<${#HOME_SYMLINKS_SRC[@]}; i++)); do
|
||||||
local src="$DOTFILES/${HOME_SYMLINKS_SRC[$i]}"
|
local src="$DOTFILES/${HOME_SYMLINKS_SRC[$i]}"
|
||||||
local dst="$HOME/${HOME_SYMLINKS_DST[$i]}"
|
local dst="$HOME/${HOME_SYMLINKS_DST[$i]}"
|
||||||
fmt_note "creating symlink \"$dst\" --> \"$src\" ..."
|
fmt_info "creating symlink \"$dst\" --> \"$src\" ..."
|
||||||
if [ ! -f "$src" ]; then
|
if [ ! -f "$src" ]; then
|
||||||
fmt_error "\"$src\" does not exist! aborting this job ..."
|
fmt_error "\"$src\" does not exist! aborting this job ..."
|
||||||
continue
|
continue
|
||||||
|
@ -110,13 +151,14 @@ install_symlink()
|
||||||
|
|
||||||
uninstall_symlink()
|
uninstall_symlink()
|
||||||
{
|
{
|
||||||
|
fmt_note "uninstalling symlinks ..."
|
||||||
local src
|
local src
|
||||||
for src in "${!HOME_SYMLINKS[@]}"; do
|
for src in "${!HOME_SYMLINKS[@]}"; do
|
||||||
local dst=${HOME_SYMLINKS[$src]}
|
local dst=${HOME_SYMLINKS[$src]}
|
||||||
src="$DOTFILES/$src"
|
src="$DOTFILES/$src"
|
||||||
dst="$HOME/$dst"
|
dst="$HOME/$dst"
|
||||||
if [ "$(readlink $dst)" -ef "$src" ]; then
|
if [ "$(readlink $dst)" -ef "$src" ]; then
|
||||||
fmt_note "removing symlink \"$dst\" ..."
|
fmt_info "removing symlink \"$dst\" ..."
|
||||||
echo ----------
|
echo ----------
|
||||||
stat $dst
|
stat $dst
|
||||||
echo ----------
|
echo ----------
|
||||||
|
@ -214,6 +256,7 @@ while [[ $# > 0 ]]; do
|
||||||
-r ) BIN=uninstall ;;
|
-r ) BIN=uninstall ;;
|
||||||
-q ) export DFS_QUIET=1 ;;
|
-q ) export DFS_QUIET=1 ;;
|
||||||
-d ) export DFS_DEV=1 ;;
|
-d ) export DFS_DEV=1 ;;
|
||||||
|
-a|--auto ) install_dependencies ;;
|
||||||
* ) fmt_warning "unknown command \"$1\". available: -i, -r, -q, -d"; exit 1 ;;
|
* ) fmt_warning "unknown command \"$1\". available: -i, -r, -q, -d"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -14,7 +14,7 @@ apk_add()
|
||||||
apk update
|
apk update
|
||||||
|
|
||||||
# mass installation
|
# mass installation
|
||||||
apk add zsh git tmux vim curl wget bash python3 htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils
|
apk add zsh git tmux vim curl wget bash python3 py3-pip htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db coreutils
|
||||||
#for i in {fzf,ripgrep}; do apk add $i -y; done
|
#for i in {fzf,ripgrep}; do apk add $i -y; done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user