Browse Source

Keep zips of versions.

master
poikilos 5 years ago
committed by Jacob Gustafson
parent
commit
e1e1cf8d24
  1. 56
      webapp/versionize.sh

56
webapp/versionize.sh

@ -1,6 +1,17 @@
#!/usr/bin/bash #!/usr/bin/bash
if [ -z "$1" ]; then if [ -z "$original_src_path" ]; then
original_src_path="$1"
fi
if [ -z "$original_src_path" ]; then
if [ -f "linux-minetest-kit.zip" ]; then
original_src_path="linux-minetest-kit.zip"
echo "* no script argument, so using linux-minetest-kit.zip"
else
echo "* original_src_path (linux-minetest-kit.zip) not detected"
fi
fi
if [ -z "$original_src_path" ]; then
echo "You must specify a zip file path OR directory path." echo "You must specify a zip file path OR directory path."
exit 1 exit 1
fi fi
@ -13,19 +24,21 @@ customDie() {
exit 1 exit 1
} }
destroy_msg="" destroy_msg=""
# src_path: extracted name (always linux-mintetest-kit unless source is
# archive, in which case src_path is detected)
src_path="linux-minetest-kit" src_path="linux-minetest-kit"
versions_path="$HOME/git/EnlivenMinetest/webapp/minetest-versions" versions_path="$HOME/git/EnlivenMinetest/webapp/minetest-versions"
if [ ! -d "$versions_path" ]; then if [ ! -d "$versions_path" ]; then
mkdir -p "$versions_path" || customDie "mkdir $versions_path FAILED" mkdir -p "$versions_path" || customDie "mkdir $versions_path FAILED"
fi fi
src_name="" src_name=""
try_path="`pwd`/$1" try_path="`pwd`/$original_src_path"
if [ -f "$1" ]; then if [ -f "$original_src_path" ]; then
echo "* detected file param..." echo "* detected file param..."
elif [ -d "$1" ]; then elif [ -d "$original_src_path" ]; then
echo "* detected directory param..." echo "* detected directory param..."
else else
customDie "$1 is not a file or directory." customDie "$original_src_path is not a file or directory."
fi fi
cd /tmp || customDie "cannot cd to /tmp" cd /tmp || customDie "cannot cd to /tmp"
if [ -d versionize ]; then if [ -d versionize ]; then
@ -33,16 +46,17 @@ if [ -d versionize ]; then
fi fi
mkdir versionize || customDie "cannot create /tmp/versionize" mkdir versionize || customDie "cannot create /tmp/versionize"
cd /tmp/versionize || customDie "cannot cd /tmp/versionize" cd /tmp/versionize || customDie "cannot cd /tmp/versionize"
if [ -f "$1" ]; then src_archive=
if [ -f "$original_src_path" ]; then
echo "* detected full path..." echo "* detected full path..."
try_path="$1" try_path="$original_src_path"
elif [ -d "$1" ]; then src_archive="$original_src_path"
elif [ -d "$original_src_path" ]; then
echo "* detected full path..." echo "* detected full path..."
try_path="$1" try_path="$original_src_path"
fi fi
if [ -f "$try_path" ]; then if [ -f "$try_path" ]; then
# if [ ! -d "$src_path" ]; then
unzip "$try_path" unzip "$try_path"
src_name="`ls`" src_name="`ls`"
if [ ! -d "$src_name" ]; then if [ ! -d "$src_name" ]; then
@ -77,6 +91,28 @@ echo "version=$version"
# dest_path="$versions_path/$src_name-$version" # dest_path="$versions_path/$src_name-$version"
dest_path="$versions_path/linux-minetest-kit-$version" dest_path="$versions_path/linux-minetest-kit-$version"
echo "dest_path=$dest_path" echo "dest_path=$dest_path"
if [ ! -z "$src_archive" ]; then
# The effectiveness of any bash extension extraction is debatable--
# see
# <https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash>
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
dst_archive="$versions_path/$filename-$version.$extension"
if [ -f "$src_archive" ]; then
mv "$src_archive" "$dst_archive" || customDie "Cannot mv '$src_archive' '$dst_archive'"
echo "* moved archive to '$dst_archive'"
echo
echo
else
echo "* ERROR: '$src_archive' is not accessible from `pwd`--"
echo " skipping:"
echo " mv '$src_archive' '$dst_archive'"
echo
echo
fi
fi
if [ -d "$dest_path" ]; then if [ -d "$dest_path" ]; then
echo echo
echo "There is nothing to do. Directory $dest_path exists." echo "There is nothing to do. Directory $dest_path exists."

Loading…
Cancel
Save