forked from docker-library/redmine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·71 lines (58 loc) · 2.05 KB
/
update.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
#!/usr/bin/env bash
set -Eeuo pipefail
# see https://www.redmine.org/projects/redmine/wiki/redmineinstall
defaultRubyVersion='2.7'
declare -A rubyVersions=(
[4.0]='2.6'
[4.1]='2.6'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
relasesUrl='https://www.redmine.org/releases'
versionsPage="$(wget -qO- "$relasesUrl")"
passenger="$(wget -qO- 'https://rubygems.org/api/v1/gems/passenger.json' | sed -r 's/^.*"version":"([^"]+)".*$/\1/')"
for version in "${versions[@]}"; do
fullVersion="$(echo $versionsPage | sed -r "s/.*($version\.[0-9]+)\.tar\.gz[^.].*/\1/" | sort -V | tail -1)"
sha256="$(wget -qO- "$relasesUrl/redmine-$fullVersion.tar.gz.sha256" | cut -d' ' -f1)"
rubyVersion="${rubyVersions[$version]:-$defaultRubyVersion}"
echo "$version: $fullVersion (ruby $rubyVersion; passenger $passenger)"
commonSedArgs=(
-r
-e 's/%%REDMINE_VERSION%%/'"$fullVersion"'/'
-e 's/%%RUBY_VERSION%%/'"$rubyVersion"'/'
-e 's/%%REDMINE_DOWNLOAD_SHA256%%/'"$sha256"'/'
-e 's/%%REDMINE%%/redmine:'"$version"'/'
-e 's/%%PASSENGER_VERSION%%/'"$passenger"'/'
)
alpineSedArgs=()
# https://github.com/docker-library/redmine/pull/184
# https://www.redmine.org/issues/22481
# https://www.redmine.org/issues/30492
if [ "$version" = 4.0 ]; then
commonSedArgs+=(
-e '/ghostscript /d'
)
alpineSedArgs+=(
-e 's/imagemagick/imagemagick6/g'
)
else
commonSedArgs+=(
-e '/imagemagick-dev/d'
-e '/libmagickcore-dev/d'
-e '/libmagickwand-dev/d'
)
fi
mkdir -p "$version"
cp docker-entrypoint.sh "$version/"
sed "${commonSedArgs[@]}" Dockerfile-debian.template > "$version/Dockerfile"
mkdir -p "$version/passenger"
sed "${commonSedArgs[@]}" Dockerfile-passenger.template > "$version/passenger/Dockerfile"
mkdir -p "$version/alpine"
cp docker-entrypoint.sh "$version/alpine/"
sed -i -e 's/gosu/su-exec/g' "$version/alpine/docker-entrypoint.sh"
sed "${commonSedArgs[@]}" "${alpineSedArgs[@]}" Dockerfile-alpine.template > "$version/alpine/Dockerfile"
done