bootstrap: Fix initial package installation to work
This commit is contained in:
parent
6a0745dedb
commit
d56d0148f6
4 changed files with 135 additions and 28 deletions
12
README.md
12
README.md
|
@ -22,11 +22,17 @@ The current dotfiles are geared toward wayland for which the setup looks similar
|
||||||
|
|
||||||
The dotfiles use `GNU stow` to link themselves in the home directory. You can clone this repository anywhere (though I have mine in `~/.dotfiles` as it seemed most logical for me).
|
The dotfiles use `GNU stow` to link themselves in the home directory. You can clone this repository anywhere (though I have mine in `~/.dotfiles` as it seemed most logical for me).
|
||||||
|
|
||||||
I would recommend doing a `git clone --recursive` for this repository, since it contains git [submodules](https://nering.dev/2016/git-submodules-vs-subtrees/), which will then automatically get pulled in as well. Of course, you can do it non-recursively and then just pull those modules selectively which you actually want.
|
I would recommend doing an initial `git clone --recursive` for this repository, since it contains git [submodules](https://nering.dev/2016/git-submodules-vs-subtrees/), which will then automatically get pulled in as well.
|
||||||
|
Of course, you can do it non-recursively and then just pull those modules selectively which you actually want.
|
||||||
|
|
||||||
Once in the repository directory, when you then run `./install.sh` it will install many of the packages I use (though they are probably slightly out-of-date) and link the dotfiles into the home directory.
|
Once in the repository directory, when you then run `./install.sh` it will install many of the packages I use (though they are probably slightly out-of-date) and link the dotfiles into the home directory.
|
||||||
If you do not want to install any packages, but only link the dotfiles run `stow -S */` from the main repository directory.
|
I would mostly recommend this on fresh machines or a test machine first - it *will* link my personal dotfiles and, if you allow it, *will* install quite a few packages.
|
||||||
Since dotfiles management is based on `stow`, it will not overwrite anything already in the home directory (though you can force it to if you really want, using `stow --override='.*'` -- I do not recommend this).
|
By default it will ask your consent for some steps -- use `./install.sh -f` to force yes to everything.
|
||||||
|
|
||||||
|
The dotfile installation procedure is based on `stow`, it will *not overwrite* anything already in the home directory (though you can force it to if you really want, using `stow --override='.*'` -- I do not recommend this).
|
||||||
|
|
||||||
|
> **NOTE**
|
||||||
|
> The same non-destructive installation procedure does *not* apply to the package installation and system setting file linking, where it can potentially overwrite or remove existing files.
|
||||||
|
|
||||||
After all files are linked and you open a new shell session, the `dotlink` alias will allow you to re-link all dotfiles from anywhere on the system.[^1]
|
After all files are linked and you open a new shell session, the `dotlink` alias will allow you to re-link all dotfiles from anywhere on the system.[^1]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
# DESCRIPTION: Display usage information for this script.
|
# DESCRIPTION: Display usage information for this script.
|
||||||
# PARAMETERS: see usage function
|
# PARAMETERS: see usage function
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
packages="${BOOTSTRAP_PACKAGES:-packages.txt}"
|
PKG_TSV_FILE=${PKG_TSV_FILE:-bootstrap/packages.tsv}
|
||||||
|
packages_repo="${BOOTSTRAP_PACKAGES:-$(grep -e ' R ' "$PKG_TSV_FILE" | cut -f1 -d' ' )}"
|
||||||
|
packages_aur="${BOOTSTRAP_PACKAGES_AUR:-$(grep -e ' A ' "$PKG_TSV_FILE" | cut -f1 -d' ' )}"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local cmd=""
|
local cmd=""
|
||||||
|
@ -60,27 +62,16 @@ update_repos() {
|
||||||
install_packages() {
|
install_packages() {
|
||||||
unattended="$1"
|
unattended="$1"
|
||||||
if "$unattended"; then
|
if "$unattended"; then
|
||||||
yay -Squ --noconfirm --needed - <"$packages"
|
echo "$packages_repo" "$packages_aur" | yay -Squ --noconfirm --needed -
|
||||||
else
|
else
|
||||||
yay -Su --needed - <"$packages"
|
echo "$packages_repo" | yay -Squ --needed -
|
||||||
fi
|
echo "$packages_aur" | yay -S --needed -
|
||||||
}
|
|
||||||
|
|
||||||
check_consent() {
|
|
||||||
echo "This will take a while and install many packages. Proceed [y/N]?"
|
|
||||||
read -r yes
|
|
||||||
if [[ "$yes" != y* ]]; then
|
|
||||||
echo "Exiting."
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
unattended=$1
|
unattended=$1
|
||||||
echo "Beginning package bootstrap ..............................................."
|
echo "Beginning package bootstrap ..............................................."
|
||||||
if ! "$unattended"; then
|
|
||||||
check_consent
|
|
||||||
fi
|
|
||||||
echo "Installing yay ............................................................"
|
echo "Installing yay ............................................................"
|
||||||
install_yay
|
install_yay
|
||||||
echo "Installing apps ..........................................................."
|
echo "Installing apps ..........................................................."
|
||||||
|
|
100
bootstrap/system-packages/etc/pacman.conf
Normal file
100
bootstrap/system-packages/etc/pacman.conf
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
#
|
||||||
|
# /etc/pacman.conf
|
||||||
|
#
|
||||||
|
# See the pacman.conf(5) manpage for option and repository directives
|
||||||
|
|
||||||
|
#
|
||||||
|
# GENERAL OPTIONS
|
||||||
|
#
|
||||||
|
[options]
|
||||||
|
# The following paths are commented out with their default values listed.
|
||||||
|
# If you wish to use different paths, uncomment and update the paths.
|
||||||
|
#RootDir = /
|
||||||
|
#DBPath = /var/lib/pacman/
|
||||||
|
#CacheDir = /var/cache/pacman/pkg/
|
||||||
|
#LogFile = /var/log/pacman.log
|
||||||
|
#GPGDir = /etc/pacman.d/gnupg/
|
||||||
|
#HookDir = /etc/pacman.d/hooks/
|
||||||
|
HoldPkg = pacman glibc
|
||||||
|
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
|
||||||
|
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
|
||||||
|
#CleanMethod = KeepInstalled
|
||||||
|
Architecture = auto
|
||||||
|
|
||||||
|
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
|
||||||
|
#IgnorePkg =
|
||||||
|
#IgnoreGroup =
|
||||||
|
|
||||||
|
#NoUpgrade =
|
||||||
|
#NoExtract =
|
||||||
|
|
||||||
|
# Misc options
|
||||||
|
UseSyslog
|
||||||
|
Color
|
||||||
|
#NoProgressBar
|
||||||
|
CheckSpace
|
||||||
|
VerbosePkgLists
|
||||||
|
ParallelDownloads = 5
|
||||||
|
|
||||||
|
# By default, pacman accepts packages signed by keys that its local keyring
|
||||||
|
# trusts (see pacman-key and its man page), as well as unsigned packages.
|
||||||
|
SigLevel = Required DatabaseOptional
|
||||||
|
LocalFileSigLevel = Optional
|
||||||
|
#RemoteFileSigLevel = Required
|
||||||
|
|
||||||
|
# NOTE: You must run `pacman-key --init` before first using pacman; the local
|
||||||
|
# keyring can then be populated with the keys of all official Arch Linux
|
||||||
|
# packagers with `pacman-key --populate archlinux`.
|
||||||
|
|
||||||
|
#
|
||||||
|
# REPOSITORIES
|
||||||
|
# - can be defined here or included from another file
|
||||||
|
# - pacman will search repositories in the order defined here
|
||||||
|
# - local/custom mirrors can be added here or in separate files
|
||||||
|
# - repositories listed first will take precedence when packages
|
||||||
|
# have identical names, regardless of version number
|
||||||
|
# - URLs will have $repo replaced by the name of the current repo
|
||||||
|
# - URLs will have $arch replaced by the name of the architecture
|
||||||
|
#
|
||||||
|
# Repository entries are of the format:
|
||||||
|
# [repo-name]
|
||||||
|
# Server = ServerName
|
||||||
|
# Include = IncludePath
|
||||||
|
#
|
||||||
|
# The header [repo-name] is crucial - it must be present and
|
||||||
|
# uncommented to enable the repo.
|
||||||
|
#
|
||||||
|
|
||||||
|
# The testing repositories are disabled by default. To enable, uncomment the
|
||||||
|
# repo name header and Include lines. You can add preferred servers immediately
|
||||||
|
# after the header, and they will be used before the default mirrors.
|
||||||
|
|
||||||
|
#[testing]
|
||||||
|
#Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
[core]
|
||||||
|
Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
[extra]
|
||||||
|
Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
#[community-testing]
|
||||||
|
#Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
[community]
|
||||||
|
Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
# If you want to run 32 bit applications on your x86_64 system,
|
||||||
|
# enable the multilib repositories as required here.
|
||||||
|
|
||||||
|
#[multilib-testing]
|
||||||
|
#Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
[multilib]
|
||||||
|
Include = /etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
# An example of a custom package repository. See the pacman manpage for
|
||||||
|
# tips on creating your own repositories.
|
||||||
|
#[custom]
|
||||||
|
#SigLevel = Optional TrustAll
|
||||||
|
#Server = file:///home/custompkgs
|
30
install.sh
30
install.sh
|
@ -43,13 +43,12 @@ check_consent() {
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
[[ "$1" == "y" ]] && default_consent="[Y/n]" || default_consent="[y/N]"
|
[[ "$1" == "y" ]] && default_consent="[Y/n]" || default_consent="[y/N]"
|
||||||
printf "%s %s " "$2" "$default_consent"
|
printf "%b %b " "$2" "$default_consent"
|
||||||
read -r answer
|
read -r answer
|
||||||
if [[ "$1" == "n" ]] && [[ "$answer" != y* ]]; then
|
if [[ "$1" == "n" ]] && [[ "$answer" != y* ]]; then
|
||||||
printf "%s\n" "$3"
|
printf "%s\n" "$3"
|
||||||
false
|
false
|
||||||
elif [[ "$1" == "y" ]] && [[ "$answer" == n* ]]; then
|
elif [[ "$1" == "y" ]] && [[ "$answer" == n* ]]; then
|
||||||
echo second
|
|
||||||
printf "%s\n" "$3"
|
printf "%s\n" "$3"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
|
@ -59,7 +58,7 @@ check_consent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_question() {
|
entry_question() {
|
||||||
check_consent n "This will take a while, install many packages and link dotfiles all over the place. Proceed?" "Aborting." || exit
|
check_consent n "This will take a while and install many packages and link dotfiles all over the place depending on your selections.\nYou need to be in the base directory of the dotfiles repository.\nProceed?" "Aborting." || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_git_hooks() {
|
enable_git_hooks() {
|
||||||
|
@ -80,21 +79,30 @@ stow_dotfiles() {
|
||||||
echo "Linked dotfiles."
|
echo "Linked dotfiles."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_elevated() {
|
||||||
|
if command -v doas >/dev/null 2>&1; then
|
||||||
|
doas "$@"
|
||||||
|
elif command -v sudo >/dev/null 2>&1; then
|
||||||
|
sudo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
stow_system_packages() {
|
stow_system_packages() {
|
||||||
check_consent n "Link system settings as well? This will require sudo access." "Not touching system files." || return
|
check_consent n "Link system settings files? This will require sudo access and may overwrite existing files." "Not touching system files." || return
|
||||||
sudo stow --dir="$bootstrap_dir" --target="/" -R system-packages/
|
if [ -e "/etc/pacman.conf" ]; then
|
||||||
|
check_consent n "Found an existing pacman.conf file, installation will error if it exists. Remove file?" && run_elevated rm "/etc/pacman.conf"
|
||||||
|
fi
|
||||||
|
run_elevated stow --dir="$bootstrap_dir" --target="/" -R system-packages/
|
||||||
echo "Linked system files."
|
echo "Linked system files."
|
||||||
}
|
}
|
||||||
|
|
||||||
install_packages() {
|
install_packages() {
|
||||||
check_consent n "Install pre-designated packages? This will take a while." "Not installing packages." || return
|
check_consent n "Install pre-designated packages? This will take a while, install a lot of packages and require super user privileges." "Not installing packages." || return
|
||||||
export BOOTSTRAP_PACKAGES="bootstrap/packages.txt"
|
|
||||||
if ! "$UNATTENDED"; then
|
if ! "$UNATTENDED"; then
|
||||||
"$bootstrap_dir"/install_packages.sh
|
"$bootstrap_dir"/install_packages.sh
|
||||||
else
|
else
|
||||||
"$bootstrap_dir"/install_packages.sh -f
|
"$bootstrap_dir"/install_packages.sh -f
|
||||||
fi
|
fi
|
||||||
unset BOOTSTRAP_PACKAGES
|
|
||||||
echo "Installed packages."
|
echo "Installed packages."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +112,14 @@ install() {
|
||||||
entry_question
|
entry_question
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "====================== BEGINNING INSTALLATION ============================="
|
echo "====================== BEGINNING SYSTEM FILE MANAGEMENT ============================="
|
||||||
|
stow_system_packages
|
||||||
|
|
||||||
|
echo "====================== BEGINNING PACKAGE INSTALLATION ============================="
|
||||||
install_packages
|
install_packages
|
||||||
|
|
||||||
echo "=================== BEGINNING DOTFILE MANAGEMENT =========================="
|
echo "=================== BEGINNING DOTFILE MANAGEMENT =========================="
|
||||||
stow_dotfiles
|
stow_dotfiles
|
||||||
stow_system_packages
|
|
||||||
|
|
||||||
echo "================== ENABLING GIT REPOSITORY HOOKS =========================="
|
echo "================== ENABLING GIT REPOSITORY HOOKS =========================="
|
||||||
enable_git_hooks
|
enable_git_hooks
|
||||||
|
|
Loading…
Reference in a new issue