-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmake-release.sh
executable file
·174 lines (140 loc) · 4.14 KB
/
make-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
174
#!/bin/bash
# Unofficial Bash Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
set -euo pipefail
IFS=$'\n\t'
PROG="$(basename "$0")"
function error()
{
if (( $# > 0 ));
then
echo "$PROG: error:" "$@"
else
echo
fi
} >&2
function bail_out()
{
error "$@"
exit 1
}
function bail_out_usage()
{
error "$@"
error
print_usage
exit 1
}
function log()
{
echo "--" "$@"
} >&2
function print_usage()
{
echo "USAGE: $PROG [-h]"
} >&2
function print_help()
{
print_usage
echo
echo 'Build DENTIST in release mode and create a tarball.'
echo
echo 'Optional arguments:'
echo ' --help, -h Prints this help.'
echo ' --usage Print a short command summary.'
echo ' --version Print software version.'
} >&2
function print_version()
{
echo "$PROG v0"
echo
echo "Copyright © 2019, Arne Ludwig <arne.ludwig@posteo.de>"
} >&2
function parse_args()
{
ARGS=()
for ARG in "$@";
do
if [[ "${ARG:0:1}" == - ]];
then
case "$ARG" in
-V*)
DENTIST_BUILD_VERSION="${ARG#-V}"
;;
--dentist=*)
DENTIST_BUILD_VERSION="${ARG#--dentist-version=}"
;;
-h|--help)
print_help
exit
;;
--usage)
print_usage
exit
;;
--version)
print_version
exit
;;
*)
bail_out_usage "unkown option $ARG"
;;
esac
else
ARGS+=( "$ARG" )
fi
done
(( ${#ARGS[*]} == 0 )) || bail_out_usage "too many arguments"
}
function make_tarball()
{
DENTIST_VERSION="$(dentist --version 2>&1 | head -n1)" && \
DENTIST_VERSION="${DENTIST_VERSION#dentist }" && \
DENTIST_VERSION="${DENTIST_VERSION% (*)}" && \
DENTIST_SRC="/opt/dentist" && \
ARCH="$(uname -m)" && \
TARBALL="dentist.$DENTIST_VERSION.$ARCH.tar.gz" && \
DIST_DIR="dentist.$DENTIST_VERSION.$ARCH" && \
INCLUDE_BINARIES=( Catrack DAM2fasta DAScover DASqv DB2fasta DBa2b DBb2a
DBdump DBdust DBmv DBrm DBshow DBsplit DBstats DBtrim DBwipe LAa2b
LAb2a LAcat LAcheck LAdump LAmerge LAshow LAsort LAsplit TANmask
computeintrinsicqv daccord daligner damapper datander dentist dumpLA
fasta2DAM fasta2DB lasfilteralignments rangen simulator )
for (( I = ${#INCLUDE_BINARIES[*]} - 1; I >= 0; --I ))
do
INCLUDE_BINARIES[$I]="$BINDIR/${INCLUDE_BINARIES[$I]}"
done
cd /tmp && \
install -Dt "$DIST_DIR" \
"$DENTIST_SRC/README.md" \
"$DENTIST_SRC/CHANGELOG.md" \
"$DENTIST_SRC/LICENSE" && \
install -Dt "$DIST_DIR/snakemake" \
"$DENTIST_SRC/snakemake/cluster.yml" \
"$DENTIST_SRC/snakemake/snakemake.yml" \
"$DENTIST_SRC/snakemake/profile-slurm."*".yml" \
"$DENTIST_SRC/snakemake/Snakefile" && \
install -Dt "$DIST_DIR/bin" "${INCLUDE_BINARIES[@]}" && \
tar --remove-files -czf "$TARBALL" "$DIST_DIR" && \
echo "TARBALL='$TARBALL'"
echo "DENTIST_VERSION='$DENTIST_VERSION'"
}
function main()
{
parse_args "$@"
log "building container image"
trap 'rm -f .docker-build-id' exit
docker build --build-arg "DENTIST_VERSION=$DENTIST_BUILD_VERSION" --iidfile .docker-build-id .
(
log "gathering release files"
CONTAINER_ID=$(docker create -v "$PWD:/opt/dentist:ro" "$(< .docker-build-id)" bash -c "$(declare -f make_tarball); make_tarball") && \
trap 'docker rm $CONTAINER_ID' exit && \
# set TARBALL and DENTIST_VERSION
eval "$(docker start -a "$CONTAINER_ID" | tee /dev/stderr | grep -F '=')"
log "copying tarball $TARBALL"
docker cp "$CONTAINER_ID:/tmp/$TARBALL" ./
log "created $TARBALL"
log "creating Docker image tag aludi/dentist:$DENTIST_VERSION"
docker tag "$(< .docker-build-id)" "aludi/dentist:$DENTIST_VERSION"
)
}
main "$@"