Browse Source

Minor style improvements

master
Pekka Helenius 2 years ago
parent
commit
44272bd3aa
2 changed files with 68 additions and 29 deletions
  1. +35
    -14
      debian_install_nvidia.sh
  2. +33
    -15
      updatewine.sh

+ 35
- 14
debian_install_nvidia.sh View File

@ -214,11 +214,14 @@ COMMANDS=(
function checkCommands() { function checkCommands() {
local COMMANDS_NOTFOUND
local a
if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then
local a=0
a=0
for command in ${@}; do for command in ${@}; do
if [[ ! $(which $command 2>/dev/null) ]]; then if [[ ! $(which $command 2>/dev/null) ]]; then
local COMMANDS_NOTFOUND[$a]=${command}
COMMANDS_NOTFOUND[$a]=${command}
let a++ let a++
fi fi
done done
@ -240,7 +243,9 @@ checkCommands "${COMMANDS[*]}"
function questionresponse() { function questionresponse() {
local response=${1}
local response
response=${1}
read -r -p "" response read -r -p "" response
if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
@ -318,8 +323,11 @@ function pkg_installcheck() {
# Check and install package related dependencies if they are missing # Check and install package related dependencies if they are missing
function pkgdependencies() { function pkgdependencies() {
local a
local b
# Generate a list of missing dependencies # Generate a list of missing dependencies
local a=0
a=0
for p in ${@}; do for p in ${@}; do
if [[ $(pkg_installcheck ${p}) -ne 0 ]]; then if [[ $(pkg_installcheck ${p}) -ne 0 ]]; then
validlist[$a]=${p} validlist[$a]=${p}
@ -340,7 +348,7 @@ function pkgdependencies() {
fi fi
# Install missing dependencies, be informative # Install missing dependencies, be informative
local b=0
b=0
for pkgdep in ${validlist[@]}; do for pkgdep in ${validlist[@]}; do
echo -e "$(( $b + 1 ))/$(( ${#validlist[*]} )) - Installing ${_pkgname} dependency ${pkgdep}" echo -e "$(( $b + 1 ))/$(( ${#validlist[*]} )) - Installing ${_pkgname} dependency ${pkgdep}"
sudo apt install -y ${pkgdep} &> /dev/null sudo apt install -y ${pkgdep} &> /dev/null
@ -383,6 +391,11 @@ function download_files() {
function prepare_deb_sources() { function prepare_deb_sources() {
local oldlib_sed
local lib_sed
local oldlib_files
local i
# Extract debian control files # Extract debian control files
cd ${WORKDIR}/${pkgdir}/ cd ${WORKDIR}/${pkgdir}/
tar xf ${filebases[0]} tar xf ${filebases[0]}
@ -394,17 +407,17 @@ function prepare_deb_sources() {
for oldlib in ${!library_fixes[@]}; do for oldlib in ${!library_fixes[@]}; do
# sed-friendly name # sed-friendly name
local oldlib_sed=$(printf '%s' ${oldlib} | sed 's/\./\\\./g')
oldlib_sed=$(printf '%s' ${oldlib} | sed 's/\./\\\./g')
for lib in ${library_fixes[$oldlib]}; do for lib in ${library_fixes[$oldlib]}; do
# sed-friendly name # sed-friendly name
local lib_sed=$(printf '%s' ${lib} | sed 's/\./\\\./g')
lib_sed=$(printf '%s' ${lib} | sed 's/\./\\\./g')
# Files which have old library files mentioned # Files which have old library files mentioned
local i=0
i=0
for oldlib_file in $(grep -rl "${oldlib}" debian/ | tr '\n' ' '); do for oldlib_file in $(grep -rl "${oldlib}" debian/ | tr '\n' ' '); do
local oldlib_files[$i]=${oldlib_file}
oldlib_files[$i]=${oldlib_file}
let i++ let i++
done done
@ -418,6 +431,9 @@ function prepare_deb_sources() {
function rename_deb_files() { function rename_deb_files() {
local n_new
local IFS
# Remove this suffix # Remove this suffix
sed -i 's/\-no\-compat32//' debian/rules.defs sed -i 's/\-no\-compat32//' debian/rules.defs
@ -431,7 +447,7 @@ function prepare_deb_sources() {
sed -i "s/384/${pkgver_major}/g" debian/templates/control.in sed -i "s/384/${pkgver_major}/g" debian/templates/control.in
############ ############
local IFS=$'\n'
IFS=$'\n'
for n in $(ls debian/ -w 1); do for n in $(ls debian/ -w 1); do
# IMPORTANT! KEEP THIS IF STATEMENT ORDER BELOW!! # IMPORTANT! KEEP THIS IF STATEMENT ORDER BELOW!!
@ -445,7 +461,7 @@ function prepare_deb_sources() {
fi fi
if [[ $(printf '%s' ${n} | grep ${oldver_major}) ]]; then if [[ $(printf '%s' ${n} | grep ${oldver_major}) ]]; then
local n_new=$(printf '%s' ${n} | sed "s/${oldver_major}/${pkgver_major}/")
n_new=$(printf '%s' ${n} | sed "s/${oldver_major}/${pkgver_major}/")
mv debian/${n} debian/${n_new} mv debian/${n} debian/${n_new}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
@ -512,6 +528,9 @@ function compile_nvidia() {
function install_nvidia() { function install_nvidia() {
local oldpkg
local oldpkg_check
for syspkg in ${nvidia_required_packages[@]}; do for syspkg in ${nvidia_required_packages[@]}; do
if [[ $(echo $(dpkg -s ${syspkg} &>/dev/null)$?) -ne 0 ]]; then if [[ $(echo $(dpkg -s ${syspkg} &>/dev/null)$?) -ne 0 ]]; then
echo -e "Installing missing dependency ${syspkg}\n" echo -e "Installing missing dependency ${syspkg}\n"
@ -526,8 +545,8 @@ function install_nvidia() {
cd ${WORKDIR}/compiled_deb cd ${WORKDIR}/compiled_deb
for pkg in ${nvidia_install_packages[@]}; do for pkg in ${nvidia_install_packages[@]}; do
local oldpkg=$(printf '%s' ${pkg} | sed 's/\-[0-9]*$//')
local oldpkg_check=$(dpkg --get-selections | grep ${oldpkg} | awk '{print $1}')
oldpkg=$(printf '%s' ${pkg} | sed 's/\-[0-9]*$//')
oldpkg_check=$(dpkg --get-selections | grep ${oldpkg} | awk '{print $1}')
if [[ $(echo ${oldpkg_check} | wc -w) -eq 1 ]]; then if [[ $(echo ${oldpkg_check} | wc -w) -eq 1 ]]; then
if [[ ! ${oldpkg_check} =~ ^*${pkgver_major}$ ]]; then if [[ ! ${oldpkg_check} =~ ^*${pkgver_major}$ ]]; then
@ -553,9 +572,11 @@ function install_nvidia() {
function install_vulkan() { function install_vulkan() {
local syspkg
# Vulkan loader # Vulkan loader
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
local syspkg=libvulkan1
syspkg=libvulkan1
if [[ $(echo $(dpkg -s ${syspkg} &>/dev/null)$?) -ne 0 ]]; then if [[ $(echo $(dpkg -s ${syspkg} &>/dev/null)$?) -ne 0 ]]; then
sudo apt update && sudo apt install -y ${syspkg} sudo apt update && sudo apt install -y ${syspkg}
fi fi


+ 33
- 15
updatewine.sh View File

@ -72,12 +72,15 @@ SUDO_GROUPS=(
function checkCommands() { function checkCommands() {
local COMMANDS_NOTFOUND
local a
if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then if [[ $(which --help 2>/dev/null) ]] && [[ $(echo --help 2>/dev/null) ]]; then
local a=0
a=0
for command in ${@}; do for command in ${@}; do
if [[ ! $(which $command 2>/dev/null) ]]; then if [[ ! $(which $command 2>/dev/null) ]]; then
local COMMANDS_NOTFOUND[$a]=${command}
COMMANDS_NOTFOUND[$a]=${command}
let a++ let a++
fi fi
done done
@ -244,17 +247,24 @@ function questionresponse() {
function reqsCheck() { function reqsCheck() {
local AVAIL_SPACE=$(df -h -B MB --output=avail . | sed '1d; s/[A-Z]*//g')
local REC_SPACE=8000
local MSG_SPACE="\e[1mWARNING:\e[0m Not sufficient storage space\n\nYou will possibly run out of space while compiling software.\n\
local AVAIL_SPACE
local REC_SPACE
local MSG_SPACE
local AVAIL_RAM
local REC_RAM
local MSG_RAM
AVAIL_SPACE=$(df -h -B MB --output=avail . | sed '1d; s/[A-Z]*//g')
REC_SPACE=8000
MSG_SPACE="\e[1mWARNING:\e[0m Not sufficient storage space\n\nYou will possibly run out of space while compiling software.\n\
The script strongly recommends ~\e[1m$((${REC_SPACE} / 1000)) GB\e[0m at least to compile software successfully but you have only\n\ The script strongly recommends ~\e[1m$((${REC_SPACE} / 1000)) GB\e[0m at least to compile software successfully but you have only\n\
\e[1m${AVAIL_SPACE} MB\e[0m left on the filesystem the script is currently placed at.\n\n\ \e[1m${AVAIL_SPACE} MB\e[0m left on the filesystem the script is currently placed at.\n\n\
Be aware that the script process may fail because of this, especially while compiling Wine Staging.\n\n\ Be aware that the script process may fail because of this, especially while compiling Wine Staging.\n\n\
Do you really want to continue? [Y/n]" Do you really want to continue? [Y/n]"
local AVAIL_RAM=$(( $(grep -oP "(?<=^MemFree:).*[0-9]" /proc/meminfo | sed 's/ //g') / 1024 ))
local REC_RAM=4096
local MSG_RAM="\e[1mWARNING:\e[0m Not sufficient RAM available\n\nCompilation processes will likely fail.\n\
AVAIL_RAM=$(( $(grep -oP "(?<=^MemFree:).*[0-9]" /proc/meminfo | sed 's/ //g') / 1024 ))
REC_RAM=4096
MSG_RAM="\e[1mWARNING:\e[0m Not sufficient RAM available\n\nCompilation processes will likely fail.\n\
The script strongly recommends ~\e[1m${REC_RAM} MB\e[0m at least to compile software successfully but you have only\n\ The script strongly recommends ~\e[1m${REC_RAM} MB\e[0m at least to compile software successfully but you have only\n\
\e[1m${AVAIL_RAM} MB\e[0m left on the computer the script is currently placed at.\n\n\ \e[1m${AVAIL_RAM} MB\e[0m left on the computer the script is currently placed at.\n\n\
Be aware that the script process may fail because of this, especially while compiling DXVK.\n\n\ Be aware that the script process may fail because of this, especially while compiling DXVK.\n\n\
@ -262,19 +272,27 @@ Do you really want to continue? [Y/n]"
function reqs_property() { function reqs_property() {
local avail_prop="${1}"
local req_prop="${2}"
local req_message="${3}"
local req_installtargets="${4}"
local avail_prop
local req_prop
local req_message
local req_installtargets
local req_targetconditions
local fullcondition
local i
avail_prop="${1}"
req_prop="${2}"
req_message="${3}"
req_installtargets="${4}"
local i=0
i=0
for req_installtarget in ${req_installtargets}; do for req_installtarget in ${req_installtargets}; do
req_targetconditions[$i]=$(echo "[[ ! -v ${req_installtarget} ]] ||") req_targetconditions[$i]=$(echo "[[ ! -v ${req_installtarget} ]] ||")
let i++ let i++
done done
local req_targetconditions=($(echo ${req_targetconditions[@]} | sed 's/\(.*\) ||/\1 /'))
local fullcondition="[[ "${avail_prop}" -lt "${req_prop}" ]] && ($(echo ${req_targetconditions[@]}))"
req_targetconditions=($(echo ${req_targetconditions[@]} | sed 's/\(.*\) ||/\1 /'))
fullcondition="[[ "${avail_prop}" -lt "${req_prop}" ]] && ($(echo ${req_targetconditions[@]}))"
if $(eval ${fullcondition}); then if $(eval ${fullcondition}); then
INFO_SEP INFO_SEP


Loading…
Cancel
Save