forked from arminbiere/lingeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-source-release.sh
executable file
·173 lines (154 loc) · 2.8 KB
/
make-source-release.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh
if [ -t 2 ]
then
BOLD="\033[1m"
GREEN="\033[1;32m"
NORMAL="\033[0m"
RED="\033[1;31m"
YELLOW="\033[1;33m"
else
BOLD=""
GREEN=""
NORMAL=""
RED=""
YELLOW=""
fi
script=`basename $0`
die () {
echo "${BOLD}$script: ${RED}error:${NORMAL} $*" 1>&2
exit 1
}
msg () {
echo "$script: $*" 1>&2
}
wrn () {
echo "${BOLD}$script: ${YELLOW}warning:${NORMAL} $*" 1>&2
}
full=no
force=no
tar=""
usage () {
cat <<EOF
usage: $script [-h|--help] [-f|--force] [-full] [-t <file>]
EOF
exit 0
}
while [ $# -gt 0 ]
do
case "$1" in
-h|--help) usage;;
-f|--force) force=yes;;
--full) full=yes;;
-t)
shift
[ $# = 0 ] && die "argument to '-t' missing"
tar="$1"
;;
*) die "invalid option '$1' (try '-h')";;
esac
shift
done
cd "`dirname $0`"
[ -d .git ] || die "could not find '.git' directory"
FULLID="`git show 2>/dev/null|awk '{print $2; exit}'`"
[ "$FULLID" = "" ] && die "could not get full git ID ('git show' failed)"
if git diff --quiet
then
CHANGES=no
else
CHANGES=yes
fi
if [ $force = yes ]
then
if [ $CHANGES = yes ]
then
wrn "uncommitted changes (but forced to continue)"
else
msg "no uncommitted changes (no need to use '-f')"
fi
else
if [ $CHANGES = yes ]
then
die "uncommitted changes ('git commit' or '-f')"
else
msg "no uncommitted changes (as expected)"
fi
fi
SHORTID="`echo $FULLID|sed -e 's,^\(........\).*,\1,'`"
[ "$SHORTID" = "" ] && die "could not get short git ID"
[ -f VERSION ] || die "could not find 'VERSION' file"
VERSION="`cat VERSION`"
[ "$VERSION" = "" ] && die "invalid 'VERSION' file"
NAME=lingeling-$VERSION-$SHORTID
DIR=/tmp/$NAME
ARCHIVE=/tmp/$NAME.tar.xz
if false
then
msg CHANGES $CHANGES
msg VERSION $VERSION
msg FULLID $FULLID
msg SHORTID $SHORTID
msg NAME $NAME
msg DIR $DIR
msg ARCHIVE $ARCHIVE
msg LIMIT $LIMIT
fi
if [ -d $DIR ]
then
msg "reusing '$DIR'"
rm -rf $DIR/*
else
msg "new directory '$DIR'"
mkdir $DIR || exit 1
fi
cp -p \
configure.sh \
COPYING \
getgitid \
lglbnr.c \
lglconst.h \
lgldimacs.c \
lgldimacs.h \
lglib.c \
lglib.h \
lglmain.c \
lgloptl.h \
lglopts.c \
lglopts.h \
makefile.in \
mkconfig.sh \
README \
VERSION \
$DIR
if [ $full = yes ]
then
cp -p \
lglmbt.c \
lgluntrace.c \
lglddtrace.c \
ilingeling.c \
plingeling.c \
treengeling.c \
$DIR
else
sed -i \
-e "s,^targets: lingeling.*,keep: lingeling," \
-e "/^targets:/d" \
-e "s,^keep:,targets:," \
$DIR/makefile.in
fi
msg "generating archive '$ARCHIVE'"
rm -f $ARCHIVE
cd /tmp
tar cJf $ARCHIVE $NAME || exit 1
msg "generated '${GREEN}$ARCHIVE${NORMAL}'"
BYTES="`ls --block-size=1 -s $ARCHIVE 2>/dev/null |awk '{print $1}'`"
msg "archive has $BYTES bytes"
if [ "$tar" = "" ]
then
echo "$ARCHIVE"
else
echo "$ARCHIVE" > "$tar"
msg "wrote archive name to '$tar'"
fi
exit 0