mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Prep for new run syntax.
This commit is contained in:
128
run
128
run
@@ -8,8 +8,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if [ -z "$DEV_ENV" ]; then
|
if [ -z "$DEV_ENV" ]; then
|
||||||
echo "env var DEV_ENV needs to be present"
|
echo "env var DEV_ENV needs to be present"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if i just did DEV_ENV=$(pwd) ./run then this is needed for the rest of the
|
# if i just did DEV_ENV=$(pwd) ./run then this is needed for the rest of the
|
||||||
@@ -21,62 +21,108 @@ dry_run="0"
|
|||||||
uninstall="0"
|
uninstall="0"
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
echo "ARG: \"$1\""
|
echo "ARG: \"$1\""
|
||||||
|
|
||||||
# Handle a --dry or --dry-run argument
|
# TODO: Fix some of these arguments, should we add a '--grep' option, should '[un]install' be args / not options?
|
||||||
if [[ "$1" =~ ^--dry ]]; then
|
# Handle a --dry or --dry-run argument
|
||||||
dry_run="1"
|
if [[ "$1" =~ ^--dry ]]; then
|
||||||
# Handle an --uninstall argument
|
dry_run="1"
|
||||||
elif [[ "$1" =~ ^--u ]]; then
|
# Handle an --uninstall argument
|
||||||
uninstall="1"
|
elif [[ "$1" =~ ^--u ]]; then
|
||||||
# Handle an --install argument (default)
|
uninstall="1"
|
||||||
elif [[ ! "$1" =~ ^--i ]]; then
|
# Handle an --install argument (default)
|
||||||
grep="$1"
|
elif [[ ! "$1" =~ ^--i ]]; then
|
||||||
fi
|
grep="$1"
|
||||||
shift
|
else
|
||||||
|
grep="$1"
|
||||||
|
fi
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# TODO: Setup proper logging using '$SCRIPTS/hypr/logging'
|
||||||
log() {
|
log() {
|
||||||
if [[ $dry_run == "1" ]]; then
|
if [[ $dry_run == "1" ]]; then
|
||||||
echo "[DRY_RUN]: $1"
|
echo "[DRY_RUN]: $1"
|
||||||
else
|
else
|
||||||
echo "$1"
|
echo "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: Remove.
|
||||||
run() {
|
run() {
|
||||||
local script=$1
|
local script=$1
|
||||||
local flag=$2
|
local flag=$2
|
||||||
log "running script: $script $flag"
|
log "running script: $script $flag"
|
||||||
|
|
||||||
local actual_flags="-S --noconfirm"
|
local actual_flags="-S --noconfirm"
|
||||||
|
|
||||||
if [[ $flag == "--uninstall" ]]; then
|
if [[ $flag == "--uninstall" ]]; then
|
||||||
actual_flags="-Rns"
|
actual_flags="-Rns"
|
||||||
fi
|
fi
|
||||||
log "ok, here's the actual script:: $s $actual_flags"
|
log "ok, here's the actual script:: $s $actual_flags"
|
||||||
|
|
||||||
if [[ $dry_run == "0" ]]; then
|
if [[ $dry_run == "0" ]]; then
|
||||||
$script $actual_flags
|
$script $actual_flags
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install() {
|
||||||
|
local file line pkg
|
||||||
|
|
||||||
|
file=${1:-""}
|
||||||
|
# Early out if the file is not readable.
|
||||||
|
[[ ! -r $file ]] && exit 1
|
||||||
|
|
||||||
|
# Loop over lines in the file and install the packages.
|
||||||
|
while read -r line; do
|
||||||
|
# Skip lines that begin with '#' (comments)
|
||||||
|
if [[ ! $line =~ ^# ]]; then
|
||||||
|
# Remove any inline comments.
|
||||||
|
pkg=${line%% \#*}
|
||||||
|
# TODO: We should log something here??
|
||||||
|
[[ $dry_run == "0" ]] && yay -S --noconfirm --needed "$pkg"
|
||||||
|
fi
|
||||||
|
done <"$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
uninstall() {
|
||||||
|
local file line pkg
|
||||||
|
|
||||||
|
file=${1:-""}
|
||||||
|
# Early out if the file is not readable.
|
||||||
|
[[ ! -r $file ]] && exit 1
|
||||||
|
|
||||||
|
# Loop over lines in the file and uninstall the packages.
|
||||||
|
while read -r line; do
|
||||||
|
# Skip lines that begin with '#' (comments)
|
||||||
|
if [[ ! $line =~ ^# ]]; then
|
||||||
|
# Remove any inline comments.
|
||||||
|
pkg=${line%% \#*}
|
||||||
|
# TODO: We should log something here??
|
||||||
|
[[ $dry_run == "0" ]] && yay -Rns "$pkg"
|
||||||
|
fi
|
||||||
|
done <"$file"
|
||||||
|
}
|
||||||
|
|
||||||
############################## MAIN ##############################
|
############################## MAIN ##############################
|
||||||
|
|
||||||
log "RUN: env: $env -- grep: $grep"
|
log "RUN: -- grep: $grep"
|
||||||
|
|
||||||
runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable)
|
#runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -type f) # TODO: keep
|
||||||
|
runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) # TODO: remove.
|
||||||
|
|
||||||
for s in $runs_dir; do
|
for s in $runs_dir; do
|
||||||
if basename $s | grep -vq "$grep"; then
|
if basename $s | grep -vq "$grep"; then
|
||||||
log "grep \"$grep\" filtered out $s"
|
log "grep \"$grep\" filtered out $s"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $uninstall == "1" ]]; then
|
if [[ $uninstall == "1" ]]; then
|
||||||
run $s --uninstall
|
# TODO: Use function instead.
|
||||||
else
|
run $s --uninstall
|
||||||
run $s --install
|
else
|
||||||
fi
|
# TODO: Use function instead.
|
||||||
|
run $s --install
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
9
runs/before/yay
Executable file
9
runs/before/yay
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if ! command -v yay >/dev/null 2>&1; then
|
||||||
|
sudo pacman -S --noconfirm --needed git base-devel
|
||||||
|
git clone https://aur.archlinux.org/yay.git ~/yay
|
||||||
|
cd ~/yay
|
||||||
|
makepkg -si
|
||||||
|
rm -rf ~/yay
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user