This repository has been archived by the owner on Jan 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
/
gen-origtar
executable file
·55 lines (48 loc) · 2.33 KB
/
gen-origtar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# This file is part of telegram-purple
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
#
# Copyright Matthias Jentsch, Ben Wiederhake 2016
set -e
# -- Cleanup possibly left-over artifacts
rm -f bin/tgl.tar bin/commit.h.tar bin/result.tar bin/result.tar.gz
# Very old artifact
rm -f bin/tgl_tl-parser.tar
# Setup
mkdir -p bin
# -- Create parts
# Abuse the "bin" dir for temporary files.
( cd tgl && git archive --prefix=telegram-purple/tgl/ --output=../bin/tgl.tar HEAD )
git archive --prefix=telegram-purple/ --output=bin/result.tar HEAD
# This is a lot of options. Here's why.
# --sort --mtime --owner --group => be reproducible (same commit produces binarily identical files)
# --transform => be in the same "tar-folder" as the rest
# (absence of --numeric-ids) => have identical behavior as git-archive
# --mode=664 => have identical behavior as git-archive
# http://www.gelato.unsw.edu.au/archives/git/0701/36326.html
# This is hacky. TODO: Find a better way to unify permissions.
tar --sort=name --mtime="1970-01-01 00:00Z" --owner=root --group=root --transform s%^%telegram-purple/% --mode=664 -cf bin/commit.h.tar commit.h
# -- Concatenate it all
tar --concatenate -f bin/result.tar bin/tgl.tar
tar --concatenate -f bin/result.tar bin/commit.h.tar
gzip -n bin/result.tar
# -- Determine name and move
TARNAME="telegram-purple_`git describe --tags | sed s/^v// `.orig.tar.gz"
# "mv -f" means "overwrite, if necessary"
echo mv -f bin/result.tar.gz $TARNAME
mv -f bin/result.tar.gz $TARNAME
# -- Cleanup (never fail)
rm -f bin/tgl.tar bin/commit.h.tar bin/result.tar bin/result.tar.gz || true