diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-06-06 08:17:18 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-06-06 08:17:18 -0300 |
commit | 515bdd658d91020c73f82b70ff001015b359adc0 (patch) | |
tree | e7c62578e2ef61bf7c9a46de91d92d37620553fe /bin/archive | |
download | bookup-515bdd658d91020c73f82b70ff001015b359adc0.tar.gz bookup-515bdd658d91020c73f82b70ff001015b359adc0.tar.bz2 |
Initial import
Diffstat (limited to 'bin/archive')
-rwxr-xr-x | bin/archive | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/archive b/bin/archive new file mode 100755 index 0000000..5b71ec8 --- /dev/null +++ b/bin/archive @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Archiver +# + +# Parameters +BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`" +DIRNAME="`dirname $0`" +BASEDIR="$DIRNAME/.." +#ARCHIVE="$BASEDIR/archive" +ARCHIVE="archive" +REVISION="`git describe --tags 2> /dev/null || git log -1 --format=oneline | cut -d ' ' -f 1`" +REVFILE="$BASEDIR/compiled/revision" + +# Make sure the archive folder exist +mkdir -p $ARCHIVE + +# Check for previous build +if [ ! -e "$REVFILE" ]; then + echo "# $BASENAME: skipping: revision file not found" + exit +else + OLD_REVISION="`cat $REVFILE`" +fi + +# Check for non-null revision +if [ -z "$OLD_REVISION" ]; then + echo "# $BASENAME: skipping: old revision is null" + exit +fi + +# Check if it's a tag +if git tag | grep -q "^${OLD_REVISION}"; then + # Check if archive does not exists + if [ ! -d "$ARCHIVE/$OLD_REVISION" ]; then + echo "# $BASENAME: archiving $OLD_REVISION..." + cp -alf compiled $ARCHIVE/$OLD_REVISION + else + echo "# $BASENAME: revision $OLD_REVISION already archived" + fi +else + echo "# $BASENAME: not archiving: revision $OLD_REVISION is not a tag" +fi |