Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some work on the install script #68

Merged
merged 39 commits into from
Jan 23, 2023
Merged
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1e6ca0e
install all base dependencies at once in a function
amtoine Dec 18, 2022
b1f35cc
curl config files and clone the dotfiles at the end
amtoine Dec 18, 2022
9699a5a
synchronize the database of `pacman`
amtoine Dec 18, 2022
737413e
fetch the dotfiles branches to have local copies
amtoine Dec 18, 2022
bdf2345
clone the dotfiles in `GHQ_ROOT`
amtoine Dec 18, 2022
9d6cb56
move PKGBUILDs inside a function and clean them
amtoine Dec 18, 2022
b58c6ef
refactor the rest inside functions
amtoine Dec 18, 2022
ceeee65
add missing system activations
amtoine Dec 18, 2022
6bf4098
refactor the "raw" github URL into constants
amtoine Dec 18, 2022
1425838
refactor the paths for the pulled files in constants
amtoine Dec 18, 2022
61178e5
refactor the path to the dmenu repo
amtoine Dec 18, 2022
8237dd7
refactor pkgbuilds paths and URLs into constants
amtoine Dec 18, 2022
d0c8616
put the pkgbuilds in a list and iterate over them
amtoine Dec 18, 2022
4ac4260
refactor the system services in a list and iterate
amtoine Dec 18, 2022
0f6726d
refactor the base dependencies in a list as well
amtoine Dec 18, 2022
8c0812a
refactor the path to the dotfiles in constants
amtoine Dec 18, 2022
e46bb21
install pacman, rust and python dependencies
amtoine Dec 18, 2022
842a8da
fix a typo in the name of the constants
amtoine Dec 19, 2022
269df77
fix the name of pkgbuilds' "clean" script
amtoine Dec 19, 2022
24a1b0f
pull the files in the functions directly
amtoine Dec 19, 2022
31a8bdc
remove `dmenu`'s local copy if already there
amtoine Dec 19, 2022
f25476e
install the system files
amtoine Dec 19, 2022
3c1c63f
checkout onto `REVISION` at the end
amtoine Dec 19, 2022
32c939e
echo_and_run all the commands
amtoine Dec 19, 2022
b705e84
exit if a command fails
amtoine Dec 19, 2022
22ed77b
do not forget to exit the subshells
amtoine Dec 19, 2022
4b73095
add better "echo" messages
amtoine Dec 19, 2022
e64e8ef
add some colors to the end message
amtoine Dec 19, 2022
e4da24a
do not ask confirmation for PKGBUILDs and dmenu
amtoine Dec 19, 2022
c98aeda
make directories before `curl`ing system files
amtoine Dec 19, 2022
53d25b2
fix the exit from subshell
amtoine Dec 19, 2022
6719df1
fix the blacklist in `pacman` packages
amtoine Dec 19, 2022
c50fd5d
remove `dtos-core-repo` from `pacman`, it is broken
amtoine Dec 19, 2022
d07c75b
install dependencies manually for now
amtoine Dec 19, 2022
1bcc2e0
do not forget to exit out from the subshells
amtoine Dec 19, 2022
5a3715a
Revert "remove `dtos-core-repo` from `pacman`, it is broken"
amtoine Dec 19, 2022
b7fc147
do not try to echo_and_run the cfg alias
amtoine Dec 19, 2022
4d1a98b
Merge commit '96fb4e4' into feature/install.sh/a-bunch-of-improvements
amtoine Jan 11, 2023
2515989
fix the URLs to download actual files, not HTML
amtoine Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 172 additions & 42 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,182 @@
#* ATXR: https://github.com/atxr atxr#6214 3B25AF716B608D41AB86C3D20E55E4B1DE5B2C8B
#*

# Update
sudo pacman -S archlinux-keyring
sudo pacman -Syu

# Install tools for building dependencies
sudo pacman -S git nushell cargo feh

# Clone dotfiles
git clone --bare https://github.com/goatfiles/dotfiles $HOME/.dotfiles
cfg="/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
$cfg reset --hard
$cfg config --local status.showUntrackedFiles no
$cfg config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

# Clean and clone pkgbuilds
if [[ -d /tmp/pkgbuilds ]]; then sudo rm -r /tmp/pkgbuilds; fi
git clone https://github.com/goatfiles/pkgbuilds /tmp/pkgbuilds

# Build pkgbuilds
(
cd /tmp/pkgbuilds
./install.sh x86_64/paru
./install.sh x86_64/amtoine-scripts-git/
./install.sh x86_64/amtoine-sounds-git/
./install.sh x86_64/amtoine-wallpapers-git/
./install.sh x86_64/amtoine-applications-git/
./install.sh x86_64/amtoine-icons-git/
./install.sh x86_64/junnunkarim-wallpapers-git
./install.sh x86_64/mut-ex-wallpapers-git

BASE_DEPENDENCIES=(
archlinux-keyring
base-devel
git
vim
nushell
cargo
sddm
bspwm
sxhkd
alacritty
cronie
blueman
bluez
bluez-utils
bluez-libs
bluez-plugins
)

RAW_DOTFILES="https://raw.githubusercontent.com/goatfiles/dotfiles"
REVISION="main"

LOCAL_PKGS_FILE="/tmp/pkgs.toml"

REMOTE_DMENU="https://github.com/bakkeby/dmenu-flexipatch"
LOCAL_DMENU_DIR="/tmp/dmenu"

REMOTE_PKGBUILDS="https://github.com/goatfiles/pkgbuilds"
LOCAL_PKGBUILDS_DIR="/tmp/pkgbuilds"

PKGBUILDS=(
paru
amtoine-scripts-git
amtoine marked this conversation as resolved.
Show resolved Hide resolved
amtoine-sounds-git
amtoine-wallpapers-git
amtoine-applications-git
amtoine-icons-git
junnunkarim-wallpapers-git
mut-ex-wallpapers-git
)

# Install dependencies
nu -c 'paru -S (open $"($env.HOME)/pkgs.toml" | get pkgs.pacman.explicit.package | find --invert --regex "amtoine|wallpapers")'
SYSTEM_FILES=(
etc/pacman.conf
etc/pacman.d/mirrorlist
etc/sddm.conf
usr/share/sddm/themes/sugar-candy/theme.conf
var/spool/cron/user
)

# Install dmenu-flexipatch
git clone https://github.com/bakkeby/dmenu-flexipatch /tmp/dmenu
cp $HOME/.config/dmenu-flexipatch/patches.h /tmp/dmenu
(
cd /tmp/dmenu
sudo make clean install
SYSTEM_SERVICES=(
sddm
NetworkManager
cronie
bluetooth
)

# Activate useful system
sudo systemctl enable sddm
sudo systemctl enable NetworkManager
REMOTE_DOTFILES="https://github.com/goatfiles/dotfiles"
LOCAL_DOTFILES_DIR="$HOME/.local/share/ghq/github.com/goatfiles/dotfiles"


echo_and_run () {
echo -e "\e[93m== running following command ==================\e[0m"
echo -e "\e[93m$@\e[0m"

eval "$@" || {
echo -e "\e[91m== an error occured... terminating... =========\e[0m"
echo -e "\e[91m'$@' failed...\e[0m"
echo -e "\e[91mcurrent pwd: $(pwd)\e[0m"
exit 1
}
}


install_base () {
echo_and_run sudo pacman --noconfirm -Syyu "${BASE_DEPENDENCIES[@]}"
}


synchronize_database () {
echo_and_run sudo pacman -Fy
}


install_pkgbuilds () {
# Clean and clone pkgbuilds
[ -d "$LOCAL_PKGBUILDS_DIR" ] && echo_and_run sudo rm -r "$LOCAL_PKGBUILDS_DIR"
echo_and_run git clone "$REMOTE_PKGBUILDS" "$LOCAL_PKGBUILDS_DIR"

# Build pkgbuilds
(
echo_and_run cd "$LOCAL_PKGBUILDS_DIR"
for pkgbuild in "${PKGBUILDS[@]}"; do
echo_and_run ./cleanup.sh
yes | echo_and_run ./install.sh "x86_64/$pkgbuild/PKGBUILD" || exit 1
done
echo_and_run ./cleanup.sh
)
[ "$?" -ne 0 ] && exit 1
}


install_dependencies () {
echo_and_run curl -fLo "$LOCAL_PKGS_FILE" "$RAW_DOTFILES/$REVISION/pkgs.toml"

pacman_deps=$(nu -c "\
open $LOCAL_PKGS_FILE \
| get pkgs.pacman.explicit.package \
| find --invert --regex 'goat-.*-git'\
")
rust_deps=$(nu -c "\
open $LOCAL_PKGS_FILE \
| get pkgs.rust.cargo.package \
")
python_deps=$(nu -c "\
open $LOCAL_PKGS_FILE \
| get pkgs.python.pip.package \
")

echo_and_run paru -S $pacman_deps
echo_and_run cargo install $rust_deps
echo_and_run pip install $python_deps
}


install_dmenu () {
[ -d "$LOCAL_DMENU_DIR" ] && echo_and_run sudo rm -r "$LOCAL_DMENU_DIR"
echo_and_run git clone "$REMOTE_DMENU" "$LOCAL_DMENU_DIR"

echo_and_run curl -fLo "$LOCAL_DMENU_DIR/patches.h" "$RAW_DOTFILES/$REVISION/.config/dmenu-flexipatch/patches.h"

(
echo_and_run cd "$LOCAL_DMENU_DIR"
yes | echo_and_run sudo make clean install || exit 1
)
[ "$?" -ne 0 ] && exit 1
}


install_system_files () {
for file in "${SYSTEM_FILES[@]}"; do
echo_and_run sudo mkdir -p "/$(dirname "$file")"
echo_and_run sudo curl -fLo "/$file" "$RAW_DOTFILES/$REVISION/.system/$file"
done
}


activate_system () {
for service in "${SYSTEM_SERVICES[@]}"; do
echo_and_run sudo systemctl enable "$service"
done
}


pull_dotfiles () {
echo_and_run git clone --bare "$REMOTE_DOTFILES" "$LOCAL_DOTFILES_DIR"
cfg="/usr/bin/git --git-dir=$LOCAL_DOTFILES_DIR --work-tree=$HOME"
echo_and_run $cfg reset --hard
echo_and_run $cfg config --local status.showUntrackedFiles no
echo_and_run $cfg config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
echo_and_run $cfg fetch
echo_and_run $cfg checkout "$REVISION"
}


install_base
synchronize_database

install_pkgbuilds
#install_dependencies
install_dmenu

install_system_files
activate_system

pull_dotfiles

# Greet
echo 'Installation completed! Please reboot your computer.'
echo -e "\e[92mInstallation completed! Please reboot your computer\e[0m."