413
by Martin Pitt
re-add merge-tarballs |
1 |
#!/bin/sh -e
|
2 |
||
3 |
# this is part of langpack-o-matic, by Martin Pitt <martin.pitt@canonical.com>
|
|
4 |
#
|
|
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
5 |
# (C) 2005-2015 Canonical Ltd.
|
413
by Martin Pitt
re-add merge-tarballs |
6 |
#
|
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
7 |
# Merge multiple translation tarballs.
|
413
by Martin Pitt
re-add merge-tarballs |
8 |
|
543.1.2
by Łukasz 'sil2100' Zemczak
Fix a few small issues, make it finally work. |
9 |
[ $# -lt 3 ] && { |
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
10 |
echo "Usage: $0 <input tarball 1> <input tarball 2> ... <input tarball n> <output tarball>" >&2 |
413
by Martin Pitt
re-add merge-tarballs |
11 |
exit 1 |
12 |
}
|
|
13 |
||
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
14 |
TD=$(mktemp -d) |
15 |
# initial trap for script interruption
|
|
16 |
trap "rm -rf $TD" 0 1 2 3 13 15 |
|
17 |
||
18 |
# extract the first tarball - all others will be merged sequentially into that one
|
|
19 |
tar -C $TD -xz < "$1" |
|
20 |
shift 1 |
|
21 |
TOPD="$TD/$(ls "$TD")" |
|
543.1.3
by Łukasz 'sil2100' Zemczak
Try to deal with the issues rised by Martin |
22 |
cp "$TOPD/mapping.txt" "$TOPD/mapping.txt.merged" |
543.1.2
by Łukasz 'sil2100' Zemczak
Fix a few small issues, make it finally work. |
23 |
MAIN=`pwd` |
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
24 |
|
543.1.3
by Łukasz 'sil2100' Zemczak
Try to deal with the issues rised by Martin |
25 |
TS=$(mktemp -d) |
26 |
trap "rm -rf $TD $TS" 0 1 2 3 13 15 |
|
27 |
||
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
28 |
while [ "$#" != "1" ]; do |
543.1.4
by Łukasz 'sil2100' Zemczak
Fix indent |
29 |
tar -C $TS -xz < "$1" |
30 |
TOPS="$TS/$(ls "$TS")" |
|
31 |
||
32 |
# copy PO and POT files
|
|
33 |
cd "$TOPS" |
|
34 |
find \( -name "*.po" -o -name "*.pot" \) -exec install -D -m 644 '{}' "$TOPD/{}" \; |
|
35 |
||
36 |
# timestamp
|
|
37 |
cp "$TOPS/timestamp.txt" "$TOPD" |
|
38 |
||
39 |
# append domain maps
|
|
559
by Łukasz 'sil2100' Zemczak
Fix merging the domain maps and actually merge them. |
40 |
cat "$TOPS/mapping.txt" >> "$TOPD/mapping.txt.merged" |
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
41 |
|
543.1.4
by Łukasz 'sil2100' Zemczak
Fix indent |
42 |
shift 1 |
43 |
cd $MAIN |
|
543.1.3
by Łukasz 'sil2100' Zemczak
Try to deal with the issues rised by Martin |
44 |
rm -rf $TS/*
|
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
45 |
done
|
46 |
||
543.1.3
by Łukasz 'sil2100' Zemczak
Try to deal with the issues rised by Martin |
47 |
# merge the domain maps
|
48 |
sort -u "$TOPD/mapping.txt.merged" > "$TOPD/mapping.txt" |
|
559
by Łukasz 'sil2100' Zemczak
Fix merging the domain maps and actually merge them. |
49 |
rm "$TOPD/mapping.txt.merged" |
543.1.3
by Łukasz 'sil2100' Zemczak
Try to deal with the issues rised by Martin |
50 |
|
51 |
rmdir $TS
|
|
52 |
||
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
53 |
if echo "$1" | grep -q '^/'; then |
413
by Martin Pitt
re-add merge-tarballs |
54 |
# absolute path
|
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
55 |
OUT="$1" |
413
by Martin Pitt
re-add merge-tarballs |
56 |
else
|
57 |
# relative path
|
|
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
58 |
OUT="$(pwd)/$1" |
413
by Martin Pitt
re-add merge-tarballs |
59 |
fi
|
60 |
||
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
61 |
cd "$TD" |
413
by Martin Pitt
re-add merge-tarballs |
62 |
tar c . | gzip -9 > "$OUT" |
543.1.1
by Łukasz 'sil2100' Zemczak
First batch of changes to make the merge-tarballs accept more than 2 tarballs. |
63 |