forked from docker-library/redmine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·76 lines (61 loc) · 2.28 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
72
73
74
75
76
#!/usr/bin/env bash
set -Eeuo pipefail
# see https://www.redmine.org/projects/redmine/wiki/redmineinstall
defaultRubyVersion='2.6'
declare -A rubyVersions=(
[3.4]='2.4'
)
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/')"
travisEnv=
for version in "${versions[@]}"; do
fullVersion="$(echo $versionsPage | sed -r "s/.*($version\.[0-9]+)\.tar\.gz[^.].*/\1/" | sort -V | tail -1)"
md5="$(wget -qO- "$relasesUrl/redmine-$fullVersion.tar.gz.md5" | 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_MD5%%/'"$md5"'/'
-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" = 3.4 ] || [ "$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
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"
travisEnv='\n - VERSION='"$version/alpine$travisEnv"
travisEnv='\n - VERSION='"$version$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml