-
Notifications
You must be signed in to change notification settings - Fork 16
/
mkdist.sh
executable file
·111 lines (96 loc) · 3.08 KB
/
mkdist.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/bash --
#
# mkdist.sh by [email protected] at Wed Mar 6 09:09:01 CET 2002
# added debian/changelog support at Fri Mar 5 19:37:45 CET 2004
# added libevhdns Makefile.in support at Sun Apr 25 12:24:43 CEST 2010
# based on mkdist.sh of autotrace
#
if test "$1" = --cd; then
MYDIR="${0%/*}"
test "$MYDIR" || MYDIR=.
cd "$MYDIR"
fi
# Get the release version number.
if test -f debian/changelog; then
# PRODUCT_AND_VERSION=$PRODUCT-$VERSION without the -revision number.
# Like this, but we do it without perl, for compile.sh:
# PRODUCT_AND_VERSION="`<debian/changelog perl -ne 'print"$1-$2"if/^(\S+) +[(]([-.\w]+?)(?:-\d+)?[)] +\w+;/;last'`"
PRODUCT_AND_VERSION=
read A B <debian/changelog
case "$B" in \(*\)*) ;; *) B= ; esac
if test "$B"; then
B="${B%%\)*}"; B="${B#\(}" B="${B%%-*}"
PRODUCT_AND_VERSION="$A-$B"
fi
if test "$PRODUCT_AND_VERSION"; then :; else
echo "$0: couldn't determine version from debian/changelog" >&2
exit 4
fi
elif test -f Makefile.in && grep '^product-and-version:' <Makefile.in >/dev/null; then
PRODUCT_AND_VERSION="`make SHELL=/bin/bash -f Makefile.in product-and-version`"
if test "$?" != 0 || test -z "$PRODUCT_AND_VERSION"; then
echo "$0: couldn't determine version from Makefile.in" >&2
exit 7
fi
else
echo "$0: missing: debian/changelog or RELEASE= in Makefile.in" >&2
exit 2
fi
if test "$1" = --getversion; then
echo "${PRODUCT_AND_VERSION##*-}"
exit
fi
echo "Creating distfile in $PWD"
# Get the list of files.
if test -f files; then
FILES="`cat files`"
elif test -d CVS; then
FILES=$( IFS='
'
find -type d -name CVS | while read D; do
F="$D/Entries"
export E="${D%/CVS}/"
E="${E#./}"
perl -ne 'print"$ENV{E}$1\n"if m@^/([^/]+)/[1-9]@' <"$F"
done)
else
echo "$0: missing: files or **/CVS/Entries" >&2
exit 3
fi
FILES="`echo "$FILES" | sort | uniq`"
if test -e "$PRODUCT_AND_VERSION"; then
echo "$0: directory $PRODUCT_AND_VERSION already exists, remove it first" >&2
exit 5
fi
if test $# -gt 0; then
TGZ_NAME="$1.tar.gz"; shift
else
TGZ_NAME="$PRODUCT_AND_VERSION.tar.gz"
fi
set -e # exit on error
rm -f "../$TGZ_NAME"
mkdir "$PRODUCT_AND_VERSION"
(IFS='
'; exec tar -cf- -- $FILES "$@") |
(cd "$PRODUCT_AND_VERSION" && exec tar -xvf-)
# ^^^ tar(1) magically calls mkdir(2) etc.
# vvv Dat: don't include sam2p-.../ in the filenames of the .tar.gz
#(IFS='
#'; cd "$PRODUCT_AND_VERSION" && exec tar -czf "../../$TGZ_NAME" -- $FILES "$@")
# vvv Dat: do include sam2p-.../ in the filenames of the .tar.gz
(IFS='
'; export PRODUCT_AND_VERSION; exec tar -czf "../$TGZ_NAME" -- `echo "$FILES" | perl -pe '$_="$ENV{PRODUCT_AND_VERSION}/$_"'` "$@")
rm -rf "$PRODUCT_AND_VERSION"
set +e
if test -s "../$TGZ_NAME"; then :; else
echo "$0: failed to create distfile: ../$TGZ_NAME" >&2
exit 6
fi
FULL_TGZ_NAME="`cd ..;echo "$PWD/$TGZ_NAME"`"
echo "Created distfile: $FULL_TGZ_NAME"
if type -p pts-xclip >/dev/null; then
echo -n "$FULL_TGZ_NAME" | pts-xclip -i
echo -n "$FULL_TGZ_NAME" | pts-xclip -i -selection clipboard
echo "Name of distfile added to the X11 primary + clipboard."
fi
# __EOF__