From a05c86aa03127e938212134e373433b6dcc7312a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 15 Oct 2024 11:09:46 -0500 Subject: minor modifications - error and exit if run as root - move logs and stats files into $source_dir (on ~/.local/src/) - remove git install function as it's unused - disabled dotfiles - change shell to zsh - install vscode :p - install snore via the AUR rather than through git - tell distrobox to export emacs, gparted, meld, and vscode - comment cleanup --- arch-distrobox | 126 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/arch-distrobox b/arch-distrobox index 77ffe19..bcc7eca 100755 --- a/arch-distrobox +++ b/arch-distrobox @@ -4,14 +4,14 @@ # Commentary # +# This script sets up an Arch Linux distrobox setup for software development. +# # There are two levels of errors: # * CRASH: Issues that will halt forward progress, aborting this script. # * ERROR: Issues not serious enough to halt the script. # Both are printed on screen and in the $logfile. # Stderr is also printed to the $logfile for all relevant info. # -# This script sets up an Arch Linux distrobox setup for software development. -# # # Code # uncomment to stop on any error @@ -25,11 +25,12 @@ dotfiles_repo="https://git.cjennings.net/dotfiles" dotemacs_repo="https://git.cjennings.net/dotemacs.git" dotfiles_home="/home/$username/.dotfiles" -logfile="/home/$username/archdistrobox-$(date +'%Y-%m-%d-%H-%M-%S').log" -source_dir="/home/$username/.local/src" # aur/git source goes here -packages_before="/home/$username/archdistrobox-preexisting-package-list.txt" -packages_after="/home/$username/archdistrobox-post-install-package-list.txt" -archdistrobox_packages="/home/$username/archdistrobox-installed-packages.txt" +# aur/git source directories go here, logs go in base directiory +source_dir="/home/$username/.local/src" +logfile="$source_dir/archdistrobox-$(date +'%Y-%m-%d-%H-%M-%S').log" +packages_before="$source_dir/archdistrobox-preexisting-package-list.txt" +packages_after="/$source_dir/archdistrobox-post-install-package-list.txt" +archdistrobox_packages="$source_dir/archdistrobox-installed-packages.txt" ### Intro intro() { @@ -37,6 +38,15 @@ intro() { STARTTIME=$(date +%s) errors_encountered=0 + # Check that we're not root; error and exit if we are + if [ $(id -u) -eq 0 ]; then + echo "Please do not run this script as root or using sudo!" + exit 1 + fi + + # on fresh distrobox, $source_dir may not exist yet + [ -d "$source_dir" ] || mkdir "$source_dir" ] + # begin with a clean logfile [ -f "$logfile" ] && rm -f "$logfile" touch "$logfile" @@ -109,23 +119,6 @@ pacman_install() { fi } -# Git Install -git_install() { - prog_name="$(basename "$1" .git)" - build_dir="$source_dir/$prog_name" - action="building & installing $prog_name from source" - display "task" "$action" - - if ! (git clone --depth 1 "$1" "$build_dir" >> "$logfile" 2>&1); then - error "error" "cloning source code for $prog_name" "$?" - (cd "$build_dir" && git pull --force origin master >> "$logfile" 2>&1) || \ - error "error" "pulling source code for $prog_name" "$?" - fi - - (cd "$build_dir" && make install >> "$logfile" 2>&1) || \ - error "error" "building $prog_name from source code" "$?" -} - # AUR Install aur_install() { action="installing $1 via the AUR" && display "task" "$action" @@ -150,59 +143,54 @@ pip_install() { ### Prerequisites prerequisites() { # why these software packages are 'required' - # linux-firmware - ensuring hardware can be detected properly # base_devel - required tools to compile - # ca_certificates - for validation of keyrings, etc. # coreutils - comparing package lists # curl - to transfer source code # git - tools required to work with git source respositories # go - required to build yay, the aur installer - # ntp - must communicate with other servers in synchronized manner # python - required for python pip installs - # stow - places the dotfiles (see: https://bit.ly/41GmysO) + # stow - places dotfiles (see: https://bit.ly/41GmysO) # tar - extract unix archives # vi - should things go wrong, we'll need an editor # zsh - we need a shell interpreter for yay; this one's mine display "title" "Prerequisites" - display "subtitle" "Bootstrapping" - + # display "subtitle" "Bootstrapping" # action="refreshing the package cache" && display "task" "$action" # (pacman -Syu --noconfirm >> "$logfile" 2>&1) || error "crash" "$action" "$?" display "subtitle" "Required Software" - for software in base-devel coreutils curl git go ntp openssh python \ + for software in base-devel coreutils curl git go python \ stow tar vi zsh; do pacman_install "$software" done - - display "subtitle" "Creating Build/Install Directories" - - action="creating a directory to build/install software from git/AUR." - (mkdir -p $source_dir) || \ - error "crash" "creating the directory $source_dir" - } ### User Customizations -user_customizations() { - action="User Customizations" && display "title" "$action" +# user_customizations() { +# Change cjennings's shell to zsh +chsh -s $(which zsh) - action="cloning dotfiles" && display "task" "$action" - (git clone --depth 1 $dotfiles_repo "$dotfiles_home" \ - >> "$logfile" 2>&1) || error "error" "$action" "$?" +# Pull relevant dotfiles and put them in their proper place - action="moving dotfiles into place" && display "task" "$action" - (cd "$dotfiles_home" && stow --no-folding --adopt * \ - >> "$logfile" 2>&1 ) || error "error" "$action" "$?" - action="restoring dotfile versions" && display "task" "$action" - (cd "$dotfiles_home" && git restore . \ - >> "$logfile" 2>&1 ) || error "error" "$action" "$?" +# ----------------------------------------------------- +# action="User Customizations" && display "title" "$action" -} +# action="cloning dotfiles" && display "task" "$action" +# (git clone --depth 1 $dotfiles_repo "$dotfiles_home" \ +# >> "$logfile" 2>&1) || error "error" "$action" "$?" + +# action="moving dotfiles into place" && display "task" "$action" +# (cd "$dotfiles_home" && stow --no-folding --adopt * \ +# >> "$logfile" 2>&1 ) || error "error" "$action" "$?" + +# action="restoring dotfile versions" && display "task" "$action" +# (cd "$dotfiles_home" && git restore . \ +# >> "$logfile" 2>&1 ) || error "error" "$action" "$?" +# } ### AUR Installer aur_installer () { @@ -374,7 +362,7 @@ developer_workstation () { pacman_install yt-dlp # video download action="setting up emacs configuration files" && display "task" "$action" - (sudo -u "$username" git clone --recurse-submodules $dotemacs_repo /home/$username/.emacs.d >> \ + (git clone --recurse-submodules $dotemacs_repo "/home/$username/.emacs.d" >> \ "$logfile" 2>&1) || error "error" "$action" "$?" action="Android Utilities" && display "subtitle" "$action" @@ -404,6 +392,7 @@ supplemental_software() { # pacman installs pacman_install aria2 # fast downloader + pacman_install code # visual studio code pacman_install dash # posix compliant /bin/sh pacman_install dfc # better display of available space on mounted filesystems pacman_install docx2txt # recovers text from docx files @@ -438,13 +427,24 @@ supplemental_software() { aur_install hfsprogs # file system tools for Mac OS aur_install mcomix # image viewer for comic books aur_install nsxiv # image viewer - aur_install shell-gpt # gpt in your terminal + aur_install shell-gpt # gpt in your terminal + aur_install snore-git # sleep with feedback aur_install tageditor # metadata editor for mkv, webm and related video files aur_install zsh-fast-syntax-highlighting-git # Optimized and extended zsh-syntax-highlighting # git installs git_install https://github.com/clamiax/snore.git # sleep with feedback +} +### Distrobox Exports +distrobox_exports() { + for software in emacs \ + filezilla \ + gparted \ + meld \ + code ; do + distrobox-export --app "$software" + done } ### Outro @@ -475,15 +475,17 @@ outro() { } ### Installation Steps -intro # take initial stats - -prerequisites # install software required to install software -user_customizations # dotfiles -aur_installer # install yay (comment out if using zfsarch install first) -environment_tools # commonly used applications -developer_workstation # development tools and utilities -supplemental_software # everything else - -outro # take end stats; show summary +intro + +prerequisites +# user_customizations +aur_installer +environment_tools +developer_workstation +# create section to separate emacs + dependencies +supplemental_software +distrobox_exports + +outro exit 0 -- cgit v1.2.3