Add project-tools #142

Merged
Francesco Siddi merged 26 commits from ZedDB/blender-studio-pipeline:project-helper-tools into main 2023-08-31 20:33:04 +02:00
2 changed files with 0 additions and 138 deletions
Showing only changes of commit bc38424401 - Show all commits

View File

@ -1,72 +0,0 @@
#!/bin/bash
# Get all archived sha hashes to use as ID numbers
ARCHIVE_DIR=../../shared/pets/artifacts/blender/previous/
cd $ARCHIVE_DIR
# TODO only rollbacks for one OS version
OS=linux
# Create an array with the available builds/files
available_builds=($(ls -t *$OS*.sha256))
installed_build=$(cd ../ && ls *$OS*.sha256)
echo $installed_build
echo -e "Available builds:\n"
valid_ids=()
ITER=0
for file in ${available_builds[@]}; do
file_date=$(stat -c '%y' $file)
# Cutoff the the date string to only show "date hours:min"
file_date=${file_date:0:19}
if [ $file == $installed_build ]; then
printf "\e[1mID:\e[0m \e[100m%3s " $ITER
printf "(%s)" "$file_date"
printf " <current>\e[0m"
else
printf "\e[1mID:\e[0m %3s " $ITER
printf "(%s)" "$file_date"
fi
valid_ids+=($ITER)
echo
ITER=$(expr $ITER + 1)
done
echo -e "\n"
choosen_blend_id=-1
prompt="Select which Blender build number to switch to. (press ENTER to confirm): "
while read -rp "$prompt" num && [[ "$num" ]]; do
# Check if "num" is a valid number.
[[ "$num" != *[[:digit:]]* ]] &&
{ echo "You need to choose a number!"; continue; }
if [[ ! " ${valid_ids[*]} " =~ " ${num} " ]]; then
# whatever you want to do when array doesn't contain value
echo "$num is not an available ID!"
continue
fi
choosen_blend_id=$num
break
done
((choosen_blend_id < 0)) && exit 0
choose_file=${available_builds[$choosen_blend_id]::-7}
# Remove the build we are replacing
rm ../*$OS*
# Copy over the choosen build
cp $choose_file* ../

View File

@ -1,66 +0,0 @@
#!/bin/bash
# TODO error out if blender is not installed locally already and there is no blender to download on shared
cur_dir=$(pwd)
cd ../../local
DOWNLOAD_DIR=../shared/pets
update_addons() {
zip_name="main.zip"
# Check if we have the latest addons from shared
if [ -f $zip_name.sha256 ]; then
shasum=$(cat $zip_name.sha256)
pushd $DOWNLOAD_DIR/addons
echo $shasum | sha256sum --check - && echo addons already at the latest version && popd && return 0
popd
fi
rm -fr ./scripts/*
extract_folder="blender-studio-pipeline/scripts-blender/addons"
# Record the extracted content
# Remove the first 5 lines, remove the last two lines, and extract the fourth column
unzip -l $DOWNLOAD_DIR/addons/$zip_name "$extract_folder/*" | tail -n +5 | head -n -2 | awk '{ print $4 }' > $zip_name.contents
unzip $DOWNLOAD_DIR/addons/$zip_name "$extract_folder/*" -d "./scripts"
mv ./scripts/$extract_folder ./scripts/
rm -fr ./scripts/blender-studio-pipeline
cp $DOWNLOAD_DIR/addons/$zip_name.sha256 .
}
update_blender() {
os=linux
# Ensure the os folder exists
mkdir -p blender/$os
if [ -f blender/$os.sha256 ]; then
shasum=$(cat blender/$os.sha256)
pushd $DOWNLOAD_DIR/artifacts/blender
echo $shasum *$os*.tar.xz | sha256sum --check - && echo blender already at the latest version && popd && return 0
popd
fi
rm -fr blender/$os/*
echo Extracting Blender
tar xf $DOWNLOAD_DIR/artifacts/blender/*$os*.tar.xz --directory blender/$os/ --strip-components=1 --checkpoint=.1000
cp $DOWNLOAD_DIR/artifacts/blender/*$os*.sha256 blender/$os.sha256
}
update_addons
update_blender
os=linux
cd blender/$os
export BLENDER_USER_CONFIG=../../config
export BLENDER_USER_SCRIPTS=../../scripts
# Actually launch Blender
./blender