Merge pull request #3 from pyr0ball/develop

[New Stable Version] v2.3.4 - Fixes Dependency Resolution on Ubuntu
This commit is contained in:
Alan Weinstock 2023-06-15 03:09:23 -07:00 committed by GitHub
commit 6f39d9fb44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 125 additions and 51 deletions

2
PRbL

@ -1 +1 @@
Subproject commit c03ad9e03328fe3f915b5995fc754e64b17c515d Subproject commit 2fac6ba3a335a89acc07287928446bd6b92169d1

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# CodeDog Bootstrap installer script # CodeDog Bootstrap installer script
# To run this script without cloning or downloading anything:
# bash <(curl -ks 'https://github.com/pyr0ball/PRbL-bashrc/raw/main/extras/Slipstream.install')
# Bash expansions to get the name and location of this script when run # Bash expansions to get the name and location of this script when run
scriptname="${BASH_SOURCE[0]##*/}" scriptname="${BASH_SOURCE[0]##*/}"
rundir="${BASH_SOURCE[0]%/*}" rundir="${BASH_SOURCE[0]%/*}"
@ -12,7 +13,17 @@ else
if [ -f ${rundir}/functions ] ; then if [ -f ${rundir}/functions ] ; then
source ${rundir}/functions source ${rundir}/functions
else else
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') # Iterate through get commands and fall back on next if unavailable
if command -v curl >/dev/null 2>&1; then
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v wget >/dev/null 2>&1; then
source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v fetch >/dev/null 2>&1; then
source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
else
echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions."
exit 1
fi
fi fi
fi fi
@ -56,12 +67,12 @@ check-deps(){
done done
pybin=$(which python3) pybin=$(which python3)
if [ -z $pybin ] ; then if [ -z $pybin ] ; then
run sudo apt-get install -y python3 python3-pip run install-packages python3 python3-pip
# TODO: make a universal package install function # TODO: make a universal package install function
fi fi
pipbin=$(which pip3) pipbin=$(which pip3)
if [ -z $pipbin ] ; then if [ -z $pipbin ] ; then
run sudo apt-get install -y python3-pip run install-packages python3-pip
fi fi
for pkg in ${pip_packages[@]} ; do for pkg in ${pip_packages[@]} ; do
pippkg_installed=$(pip list | grep -F $pkg ; echo $?) pippkg_installed=$(pip list | grep -F $pkg ; echo $?)
@ -87,29 +98,32 @@ check-deps(){
} }
install-deps(){ install-deps(){
logger echo "Installing packages $sys_packages" logger echo "Installing packages: $sys_packages"
for _package in $sys_packages ; do for _package in ${sys_packages[@]} ; do
run sudo apt-get install -y $_package run install-packages $_package
done done
if [ -f ${rundir}/requirements.txt ] ; then if [ -f ${rundir}/requirements.txt ] ; then
pip install -y ${rundir}/requirements.txt pip install -y ${rundir}/requirements.txt
else else
if [ ! -z $pip_packages ] ; then if [ ! -z $pip_packages ] ; then
pip install -y ${pip_packages[@]} pip install ${pip_packages[@]}
fi fi
fi fi
for _package in $prbl_packages ; do for _package in $prbl_packages ; do
if [ -f ${rundir}/$_package ] ; then if [ -f ${rundir}/$_package ] ; then
if [[ $dry_run != true ]] ; then if [[ $dry_run != true ]] ; then
bash "${rundir}/$_package -i" boxline "running extra $extra"
run "${rundir}/$_package -i"
else else
bash "${rundir}/$_package -D" dry_run=false
run "${rundir}/$_package -D"
dry_run=true
fi fi
else else
if [[ $dry_run != true ]] ; then if [[ $dry_run != true ]] ; then
run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/master/extras/$_package -i run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/main/extras/$_package -i
else else
run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/master/extras/$_package -D run-from-url https://raw.githubusercontent.com/pyr0ball/PRbL-bashrc/main/extras/$_package -D
fi fi
fi fi
done done
@ -141,9 +155,9 @@ install(){
if ! check-deps ; then if ! check-deps ; then
warn "Some of the utilities needed by this install are missing" warn "Some of the utilities needed by this install are missing"
boxtop boxtop
logger echo -e "Missing utilities:" logger boxline "Missing utilities:"
for bin in ${bins_missing[@]} ; do for bin in ${bins_missing[@]} ; do
logger echo -e "${bins_missing[$bin]}" logger boxline "$bin"
done done
boxbottom boxbottom
boxborder "Would you like to install them? (this will require root password)" boxborder "Would you like to install them? (this will require root password)"

59
extras/golang.install Normal file → Executable file
View file

@ -6,6 +6,7 @@ scriptname="${BASH_SOURCE[0]##*/}"
script_title="${grn}Go${blu}la${red}n${ylw}g${dfl}" script_title="${grn}Go${blu}la${red}n${ylw}g${dfl}"
rundir="${BASH_SOURCE[0]%/*}" rundir="${BASH_SOURCE[0]%/*}"
sys_arch=$(uname -m) sys_arch=$(uname -m)
req_go_ver="1.19"
golang_bashrc="# Golang system path setup golang_bashrc="# Golang system path setup
export PATH=\$PATH:/usr/local/go/bin export PATH=\$PATH:/usr/local/go/bin
@ -15,7 +16,21 @@ export PATH=\$PATH:/usr/local/go/bin
if [ ! -z $prbl_functions ] ; then if [ ! -z $prbl_functions ] ; then
source $prbl_functions source $prbl_functions
else else
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') if [ -f ${rundir}/functions ] ; then
source ${rundir}/functions
else
# Iterate through get commands and fall back on next if unavailable
if command -v curl >/dev/null 2>&1; then
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v wget >/dev/null 2>&1; then
source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v fetch >/dev/null 2>&1; then
source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
else
echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions."
exit 1
fi
fi
fi fi
logfile="${rundir}/${pretty_date}_${scriptname}.log" logfile="${rundir}/${pretty_date}_${scriptname}.log"
@ -63,6 +78,17 @@ check-deps(){
fi fi
} }
check-go(){
if [[ -x /usr/bin/go ]] ; then
# TODO: Add version checking rather than just whether the binary is executible
#inst_go_ver=$(/usr/bin/go version | awl {'print $3'} | cut -c 3-)
#if [[ $(vercomp )]]
return 0
else
return 1
fi
}
install-deps(){ install-deps(){
logger echo "Installing packages $sys_packages" logger echo "Installing packages $sys_packages"
run "for $_package in $sys_packages ; do sudo apt-get install -y $_package ; done" run "for $_package in $sys_packages ; do sudo apt-get install -y $_package ; done"
@ -93,22 +119,45 @@ dry-run-report(){
} }
install(){ install(){
local _golang_html=$(curl -ks "https://go.dev/dl/" | grep linux-amd64 | grep 1.19 | head -n 1) if check-go ; then
boxline "golang already installed!"
return 0
fi
if ! check-deps ; then
warn "Some of the utilities needed by this script are missing"
boxlinelog "Missing utilities:"
boxlinelog "${bins_missing[@]}"
boxlinelog "Would you like to install them? (this will require root password)"
utilsmissing_menu=(
"$(boxline "${green_check} Yes")"
"$(boxline "${red_x} No")"
)
case `select_opt "${utilsmissing_menu[@]}"` in
0) boxlinelog "${grn}Installing dependencies...${dfl}"
install-deps
;;
1) warn "Dependent Utilities missing: $bins_missing" ;;
esac
fi
local _golang_html=$(/usr/bin/curl -ks "https://go.dev/dl/" | grep $sys_arch | grep $req_go_ver | head -n 1)
local golang_current=$(strip-html-tags "$_golang_html") local golang_current=$(strip-html-tags "$_golang_html")
#golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') #golang_current=$(echo "$golang_current" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX` export tmp_dir=`mktemp -d /tmp/selfextract.XXXXXX`
logger boxborder "Pulling golang v$req_go_ver for installation"
run wget "https://go.dev/dl/${golang_current}" -O $tmp_dir/$golang_current run wget "https://go.dev/dl/${golang_current}" -O $tmp_dir/$golang_current
run sudo rm -rf /usr/local/go run sudo rm -rf /usr/local/go
run sudo tar -C /usr/local -xzf $tmp_dir/$golang_current run sudo tar -C /usr/local -xzf $tmp_dir/$golang_current
if [ ! -f $HOME/.bashrc.d/11-golang.bashrc ] ; then if [ ! -f $HOME/.bashrc.d/11-golang.bashrc ] ; then
run echo -e "$codedog_bashrc" >> $HOME/.bashrc.d/11-golang.bashrc && \ run echo -e "$codedog_bashrc" >> $HOME/.bashrc.d/11-golang.bashrc && \
boxborder ".bashrc.d/11-golang.bashrc installed..." logger boxborder ".bashrc.d/11-golang.bashrc installed..."
fi fi
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
if [ ! -f /usr/bin/go ] ; then if [ ! -x /usr/bin/go ] ; then
run sudo ln -s /usr/local/go/bin/go /usr/bin/go && \ run sudo ln -s /usr/local/go/bin/go /usr/bin/go && \
boxborder "golang symlink created at /usr/bin/go" logger boxborder "golang symlink created at /usr/bin/go"
fi fi
return 0
} }
# Function for displaying the usage of this script # Function for displaying the usage of this script

View file

@ -4,26 +4,34 @@
################################################################### ###################################################################
# initial vars # initial vars
VERSION=2.3.3 VERSION=2.3.4
scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION" scripttitle="Pyr0ball's Reductive Bash Library Installer - v$VERSION"
# Bash expansions to get the name and location of this script when run # Bash expansions to get the name and location of this script when run
scriptname="${BASH_SOURCE[0]##*/}" scriptname="${BASH_SOURCE[0]##*/}"
rundir="${BASH_SOURCE[0]%/*}" rundir="${BASH_SOURCE[0]%/*}"
# Source PRbL functions from installer directory
# Source PRbL Functions locally or retrieve from online # Source PRbL Functions locally or retrieve from online
# TODO: Add version check to this
if [ ! -z $prbl_functions ] ; then if [ ! -z $prbl_functions ] ; then
source $prbl_functions source $prbl_functions
else else
if [ -f ${rundir}/functions ] ; then if [ -f ${rundir}/functions ] ; then
source ${rundir}/functions source ${rundir}/functions
else else
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') # Iterate through get commands and fall back on next if unavailable
if command -v curl >/dev/null 2>&1; then
source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v wget >/dev/null 2>&1; then
source <(wget -qO- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
elif command -v fetch >/dev/null 2>&1; then
source <(fetch -qo- 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions')
else
echo "Error: curl, wget, and fetch commands are not available. Please install one to retrieve PRbL functions."
exit 1
fi fi
fi fi
fi
rundir_absolute=$(pushd $rundir ; pwd ; popd) rundir_absolute=$(pushd $rundir ; pwd ; popd)
escape_dir=$(printf %q "${rundir_absolute}") escape_dir=$(printf %q "${rundir_absolute}")
logfile="${rundir}/${pretty_date}_${scriptname}.log" logfile="${rundir}/${pretty_date}_${scriptname}.log"
@ -196,14 +204,14 @@ install-functions(){
if [ -f ${rundir}/PRbL/functions ] ; then if [ -f ${rundir}/PRbL/functions ] ; then
install-file ${rundir}/PRbL/functions ${installdir} install-file ${rundir}/PRbL/functions ${installdir}
else else
curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions' > ${rundir}/functions curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/main/functions' > ${rundir}/functions
install-file ${rundir}/functions ${installdir} install-file ${rundir}/functions ${installdir}
fi fi
} }
take-backup(){ take-backup(){
name="$1" name="$1"
if [[ $update_run != true ]] ; then # if [[ $update_run != true ]] ; then
# Check if a backup file or symbolic link already exists # Check if a backup file or symbolic link already exists
if [[ -e "$name.bak" || -L "$name.bak" ]]; then if [[ -e "$name.bak" || -L "$name.bak" ]]; then
run boxline " $name.bak backup already exists" run boxline " $name.bak backup already exists"
@ -219,11 +227,11 @@ take-backup(){
# Copy the file to the backup file with preservation of file attributes # Copy the file to the backup file with preservation of file attributes
run cp -p "$name" "$backup_name" run cp -p "$name" "$backup_name"
# Add the original file to the list of backup files # Add the original file to the list of backup files
backup_files+=("$name") run boxline " $name.bak backup already exists"
# Log the original file name to the backup file list file # Log the original file name to the backup file list file
run echo "$name" >> "$rundir/backup_files.list" run echo "$name" >> "$rundir/backup_files.list"
fi fi
fi # fi
} }
restore-backup(){ restore-backup(){
@ -232,7 +240,7 @@ restore-backup(){
run cp "$file".bak $file run cp "$file".bak $file
run echo "$file is restored" run echo "$file is restored"
done done
backup_files=() run boxline " $name.bak backup already exists"
if [ -f $rundir/backup_files.list ] ; then if [ -f $rundir/backup_files.list ] ; then
run rm $rundir/backup_files.list run rm $rundir/backup_files.list
fi fi
@ -292,14 +300,17 @@ install-deps(){
} }
install-extras(){ install-extras(){
_extras=() _extras=($(ls ${escape_dir}/extras/ | grep -v 'log$'))
extra_installs=$(ls ${escape_dir}/extras/) # extra_installs=$(ls ${escape_dir}/extras/)
for file in $extra_installs ; do # for file in $extra_installs ; do
_extras+=("$file") # _extras+=("$file")
done # done
boxborder "Which extras should be installed?" boxborder "Which extras should be installed?"
multiselect result _extras "false" for each in {1..${#_extras[@]}} ; do
preselect+=("false")
done
multiselect result _extras preselect
# For each extra, compare input choice and apply installs # For each extra, compare input choice and apply installs
idx=0 idx=0
@ -307,12 +318,15 @@ install-extras(){
# If the selected user is set to true # If the selected user is set to true
if [[ "${result[idx]}" == "true" ]] ; then if [[ "${result[idx]}" == "true" ]] ; then
if [[ $dry_run != true ]] ; then if [[ $dry_run != true ]] ; then
boxline "running extra $extra"
run "${escape_dir}/extras/$extra -i" run "${escape_dir}/extras/$extra -i"
else else
dry_run=false dry_run=false
run "${escape_dir}/extras/$extra -D" run "${escape_dir}/extras/$extra -D"
dry_run=true dry_run=true
fi fi
# else
# echo "index for $extra is ${result[idx]}"
fi fi
done done
} }
@ -339,15 +353,6 @@ userinstall(){
# Create install directory under user's home directory # Create install directory under user's home directory
run mkdir -p ${installdir} run mkdir -p ${installdir}
# Check if functions already exist, and check if functions are out of date
if [ -f ${installdir}/functions ] ; then
# if functions are out of date, remove before installing new version
local installerfrev=$(cat ${rundir}/functions | grep functionsrev )
if [[ $(vercomp ${installerfrev##*=} $installer_functionsrev ) == 2 ]] ; then
run rm ${installdir}/functions
fi
fi
# Copy functions first # Copy functions first
install-functions install-functions
@ -359,11 +364,17 @@ userinstall(){
warn "Some of the utilities needed by this script are missing" warn "Some of the utilities needed by this script are missing"
boxlinelog "Missing utilities:" boxlinelog "Missing utilities:"
boxlinelog "${bins_missing[@]}" boxlinelog "${bins_missing[@]}"
boxlinelog "After this installer completes, run:" boxlinelog "Would you like to install them? (this will require root password)"
boxseparator utilsmissing_menu=(
echo -en "\n${lbl}sudo apt install -y ${bins_missing[@]}\n${dfl}" "$(boxline "${green_check} Yes")"
boxborder "Press 'Enter' key when ready to proceed" "$(boxline "${red_x} No")"
read proceed )
case `select_opt "${utilsmissing_menu[@]}"` in
0) boxlinelog "${grn}Installing dependencies...${dfl}"
install-deps
;;
1) warn "Dependent Utilities missing: $bins_missing" ;;
esac
fi fi
# Check for and parse the installed vim version # Check for and parse the installed vim version
@ -513,7 +524,7 @@ update(){
run git stash -m "$pretty_date stashing changes before update to latest" run git stash -m "$pretty_date stashing changes before update to latest"
run git fetch && run git pull --recurse-submodules run git fetch && run git pull --recurse-submodules
pushd PRbL pushd PRbL
run git checkout master run git checkout main
run git pull run git pull
popd popd
install install