annotate clean_repository_tarball.sh @ 12:6b7d31026d1c draft

Uploaded
author petr-novak
date Tue, 04 Feb 2020 08:38:22 -0500
parents d397f5a85464
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
1 #!/bin/bash
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
2 containsElement () {
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
3 local e match="$1"
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
4 shift
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
5 for e; do [[ "$e" == "$match" ]] && return 0; done
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
6 return 1
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
7 }
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
8 ARCHIVE_GZ=../re_utilities.tar.gz
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
9 TMP_TAR=`mktemp`
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
10 echo $TMP_TAR
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
11 ARCHIVE_GZ_CLEAN=../re_utilities_clean.tar.gz
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
12 zcat $ARCHIVE_GZ > $TMP_TAR
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
13 ARCHIVE_FILE_LIST=`tar -tz -f ../re_utilities.tar.gz`
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
14 ls -l $TMP_TAR
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
15 GIT_LIST=`git ls-files`
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
16
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
17 for FILE in $ARCHIVE_FILE_LIST
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
18 do
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
19 containsElement $FILE ${GIT_LIST[@]}
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
20 if [ $? != 0 ]
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
21 then
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
22 echo "Deleting ${FILE}"
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
23 tar --delete -f $TMP_TAR $FILE
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
24 fi
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
25 done
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
26 ls -l $TMP_TAR
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
27 echo "compressing.."
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
28 gzip -c $TMP_TAR > $ARCHIVE_GZ_CLEAN
d397f5a85464 Uploaded
petr-novak
parents:
diff changeset
29 echo "output in ${ARCHIVE_GZ_CLEAN}"