@@ -8,6 +8,10 @@ declare -A alpine_version=(
88 [default]=' 3.17'
99)
1010
11+ declare -A debian_version=(
12+ [default]=' bullseye'
13+ )
14+
1115declare -A php_version=(
1216 [default]=' 8.1'
1317)
@@ -93,8 +97,11 @@ function version_greater_or_equal() {
9397function create_variant() {
9498 dir=" $1 /$variant "
9599 alpineVersion=${alpine_version[$version]-${alpine_version[default]} }
100+ debianVersion=${debian_version[$version]-${debian_version[default]} }
96101 phpVersion=${php_version[$version]-${php_version[default]} }
97102 crontabInt=${crontab_int[$version]-${crontab_int[default]} }
103+ url=" https://download.nextcloud.com/server/releases/nextcloud-$fullversion .tar.bz2"
104+ ascUrl=" https://download.nextcloud.com/server/releases/nextcloud-$fullversion .tar.bz2.asc"
98105
99106 # Create the version+variant directory with a Dockerfile.
100107 mkdir -p " $dir "
@@ -105,13 +112,30 @@ function create_variant() {
105112
106113 echo " updating $fullversion [$1 ] $variant "
107114
115+ # Apply version+variant-specific patches
116+ case " $version " in
117+ 25)
118+ case " $variant " in
119+ fpm-alpine)
120+ # Alpine 3.16 / OpenSSL 1.1 is only available for PHP 8.0
121+ phpVersion=8.0
122+ ;;
123+ esac
124+
125+ # Nextcloud 26+ recommends sysvsem
126+ sed -ri -e ' /sysvsem/d' " $dir /Dockerfile"
127+ ;;
128+ esac
129+
108130 # Replace the variables.
109131 sed -ri -e '
110132 s/%%ALPINE_VERSION%%/' " $alpineVersion " ' /g;
133+ s/%%DEBIAN_VERSION%%/' " $debianVersion " ' /g;
111134 s/%%PHP_VERSION%%/' " $phpVersion " ' /g;
112135 s/%%VARIANT%%/' " $variant " ' /g;
113136 s/%%VERSION%%/' " $fullversion " ' /g;
114- s/%%BASE_DOWNLOAD_URL%%/' " $2 " ' /g;
137+ s/%%DOWNLOAD_URL%%/' " $( sed -e ' s/[\/&]/\\&/g' <<< " $url" ) " ' /g;
138+ s/%%DOWNLOAD_URL_ASC%%/' " $( sed -e ' s/[\/&]/\\&/g' <<< " $ascUrl" ) " ' /g;
115139 s/%%CMD%%/' " ${cmd[$variant]} " ' /g;
116140 s|%%VARIANT_EXTRAS%%|' " ${extras[$variant]} " ' |g;
117141 s/%%APCU_VERSION%%/' " ${pecl_versions[APCu]} " ' /g;
@@ -121,24 +145,6 @@ function create_variant() {
121145 s/%%CRONTAB_INT%%/' " $crontabInt " ' /g;
122146 ' " $dir /Dockerfile"
123147
124- # Nextcloud 26+ recommends sysvsem
125- case " $version " in
126- 25 )
127- case " $variant " in
128- fpm-alpine )
129- # Alpine 3.16 / OpenSSL 1.1 is only available for PHP 8.0
130- sed -ri -e '
131- s/FROM php:8\.1-fpm-alpine/FROM php:8.0-fpm-alpine/
132- ' " $dir /Dockerfile"
133- ;;
134- esac
135-
136- sed -ri -e '
137- /sysvsem/d
138- ' " $dir /Dockerfile"
139- ;;
140- esac
141-
142148 # Copy the shell scripts
143149 for name in entrypoint cron; do
144150 cp " docker-$name .sh" " $dir /$name .sh"
@@ -154,6 +160,16 @@ function create_variant() {
154160 if [ " $variant " != " apache" ]; then
155161 rm " $dir /config/apache-pretty-urls.config.php"
156162 fi
163+
164+ # Add variant to versions.json
165+ [ " ${base[$variant]} " == " alpine" ] && baseVersion=" $alpineVersion " || baseVersion=" $debianVersion "
166+ versionVariantsJson=" $( jq -e \
167+ --arg version " $version " --arg variant " $variant " --arg base " ${base[$variant]} " --arg baseVersion " $baseVersion " --arg phpVersion " $phpVersion " \
168+ ' .[$version].variants[$variant] = {"variant": $variant, "base": $base, "baseVersion": $baseVersion, "phpVersion": $phpVersion}' versions.json) "
169+ versionJson=" $( jq -e \
170+ --arg version " $version " --arg fullversion " $fullversion " --arg url " $url " --arg ascUrl " $ascUrl " --argjson variants " $versionVariantsJson " \
171+ ' .[$version] = {"branch": $version, "version": $fullversion, "url": $url, "ascUrl": $ascUrl, "variants": $variants[$version].variants}' versions.json) "
172+ printf ' %s\n' " $versionJson " > versions.json
157173}
158174
159175curl -fsSL ' https://download.nextcloud.com/server/releases/' | tac| tac| \
@@ -164,19 +180,20 @@ curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
164180
165181find . -maxdepth 1 -type d -regextype sed -regex ' \./[[:digit:]]\+\.[[:digit:]]\+\(-rc\|-beta\|-alpha\)\?' -exec rm -r ' {}' \;
166182
183+ printf ' %s' " {}" > versions.json
184+
167185fullversions=( $( curl -fsSL ' https://download.nextcloud.com/server/releases/' | tac| tac| \
168186 grep -oE ' nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \
169187 grep -oE ' [[:digit:]]+(\.[[:digit:]]+){2}' | \
170188 sort -urV ) )
171189versions=( $( printf ' %s\n' " ${fullversions[@]} " | cut -d. -f1 | sort -urV ) )
190+
172191for version in " ${versions[@]} " ; do
173192 fullversion=" $( printf ' %s\n' " ${fullversions[@]} " | grep -E " ^$version " | head -1 ) "
174193
175194 if version_greater_or_equal " $version " " $min_version " ; then
176-
177195 for variant in " ${variants[@]} " ; do
178-
179- create_variant " $version " " https:\/\/download.nextcloud.com\/server\/releases"
196+ create_variant " $version "
180197 done
181198 fi
182199done
0 commit comments