File: make-source-release.sh

package info (click to toggle)
kissat 4.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,068 kB
  • sloc: ansic: 39,201; sh: 1,226; makefile: 91
file content (146 lines) | stat: -rwxr-xr-x 2,828 bytes parent folder | download | duplicates (2)
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
#!/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
}

force=no
tar=""

usage () {
cat <<EOF
usage: $script [-h|--help] [-f|--force][-t <file>]
EOF
exit 0
}

while [ $# -gt 0 ]
do
  case "$1" in
    -h|--help) usage;;
    -f|--force) force=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=kissat-$VERSION-$SHORTID
DIR=/tmp/$NAME
ARCHIVE=/tmp/$NAME.tar.xz
LIMIT=10

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

msg "copying complete repository"
git archive HEAD | tar -x -C $DIR

msg "removing redundant files"
rm $DIR/scripts/build-and-test-all-configurations.sh || exit 1
rm $DIR/scripts/make-source-release.sh || exit 1
rm $DIR/scripts/prepare-competition.sh || exit 1
rm $DIR/.gitignore || exit 1
rm $DIR/.vimdir || exit 1
sed -i -e "s,ID=unknown,ID=$FULLID," $DIR/scripts/generate-build-header.sh
msg "removing CNF files with more than ${LIMIT}k bytes"
find $DIR/test/cnf -size +${LIMIT}k -exec rm {} \;
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