1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore: refactor tools/create-tarballs.sh to deduplicate code

This commit is contained in:
Zetok Zalbavar 2018-09-30 22:08:22 +01:00
parent 39dc6dacb8
commit 8edbe9f888
No known key found for this signature in database
GPG Key ID: C953D3880212068A

View File

@ -15,16 +15,16 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Create a `lzip` and a `gzip` archive and make a detached GPG signature for them. # Create `lzip` and `gzip` archives and make detached GPG signatures for them.
# #
# When tag name is supplied, it's used to create archive. If there is no tag # When tag name is supplied, it's used to create archives. If there is no tag
# name supplied, latest tag is used. # name supplied, latest tag is used.
# Requires: # Requires:
# * GPG # * GPG
# * git # * git
# * lzip
# * gzip # * gzip
# * lzip
# usage: # usage:
# ./$script [$tag_name] # ./$script [$tag_name]
@ -34,33 +34,28 @@
set -eu -o pipefail set -eu -o pipefail
archives_from_tag() { archive() {
git archive --format=tar "$@" \ git archive --format=tar "${@%%.tar.*}" \
| lzip --best \ | "${@##*.tar.}"ip --best \
> "$@".tar.lz > "$@"
echo "$@.tar.lz archive has been created." echo "$@ archive has been created."
git archive --format=tar "$@" \
| gzip --best \
> "$@".tar.gz
echo "$@.tar.gz archive has been created."
} }
sign_archives() { sign_archive() {
gpg \ gpg \
--armor \ --armor \
--detach-sign \ --detach-sign \
"$@".tar.lz "$@"
echo "$@.tar.lz.asc signature has been created." echo "$@.asc signature has been created."
gpg \
--armor \
--detach-sign \
"$@".tar.gz
echo "$@.tar.gz.asc signature has been created."
} }
create_and_sign() { create_and_sign() {
archives_from_tag "$@" local archives=("$@".tar.{l,g}z)
sign_archives "$@" for a in "${archives[@]}"
do
archive "$a"
sign_archive "$a"
done
} }
get_tag() { get_tag() {