2016-09-02 15:11:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
2018-03-08 09:52:55 +01:00
|
|
|
declare -A php_version=(
|
|
|
|
[default]='7.1'
|
|
|
|
)
|
|
|
|
|
2017-01-13 10:31:57 +01:00
|
|
|
declare -A cmd=(
|
|
|
|
[apache]='apache2-foreground'
|
|
|
|
[fpm]='php-fpm'
|
2018-02-11 02:58:17 +01:00
|
|
|
[fpm-alpine]='php-fpm'
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A base=(
|
|
|
|
[apache]='debian'
|
|
|
|
[fpm]='debian'
|
|
|
|
[fpm-alpine]='alpine'
|
2017-01-13 10:31:57 +01:00
|
|
|
)
|
|
|
|
|
2018-01-04 22:35:31 +01:00
|
|
|
declare -A extras=(
|
|
|
|
[apache]='\nRUN a2enmod rewrite'
|
|
|
|
[fpm]=''
|
2018-02-11 02:58:17 +01:00
|
|
|
[fpm-alpine]=''
|
2018-01-04 22:35:31 +01:00
|
|
|
)
|
|
|
|
|
2018-03-08 09:38:24 +01:00
|
|
|
declare -A pecl_versions=(
|
2018-03-08 09:41:24 +01:00
|
|
|
[APCu]='5.1.11'
|
2018-03-08 09:38:24 +01:00
|
|
|
[memcached]='3.0.4'
|
|
|
|
[redis]='3.1.6'
|
|
|
|
)
|
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
variants=(
|
|
|
|
apache
|
|
|
|
fpm
|
|
|
|
fpm-alpine
|
|
|
|
)
|
|
|
|
|
|
|
|
min_version='11.0'
|
|
|
|
|
2017-03-07 15:33:57 +01:00
|
|
|
# version_greater_or_equal A B returns whether A >= B
|
|
|
|
function version_greater_or_equal() {
|
|
|
|
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]];
|
|
|
|
}
|
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
# checks if the the rc is already released
|
|
|
|
function check_released() {
|
|
|
|
printf '%s\n' "${fullversions[@]}" | grep -qE "^$( echo "$1" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' )"
|
|
|
|
}
|
2017-06-10 23:15:01 +02:00
|
|
|
|
2017-03-14 10:48:58 +01:00
|
|
|
travisEnv=
|
2017-01-13 10:31:57 +01:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
function create_variant() {
|
|
|
|
dir="$1/$variant"
|
|
|
|
|
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$dir"
|
|
|
|
|
|
|
|
cp "Dockerfile-${base[$variant]}.template" "$dir/Dockerfile"
|
|
|
|
|
|
|
|
echo "updating $fullversion [$1] $variant"
|
|
|
|
|
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
|
|
|
s/%%PHP_VERSION%%/'"${php_version[$version]-${php_version[default]}}"'/g;
|
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$fullversion"'/g;
|
|
|
|
s/%%BASE_DOWNLOAD_URL%%/'"$2"'/g;
|
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
|
|
|
s/%%VARIANT_EXTRAS%%/'"${extras[$variant]}"'/g;
|
|
|
|
s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g;
|
|
|
|
s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g;
|
|
|
|
s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g;
|
|
|
|
' "$dir/Dockerfile"
|
|
|
|
|
|
|
|
# Copy the shell scripts
|
|
|
|
for name in entrypoint cron; do
|
|
|
|
cp "docker-$name.sh" "$dir/$name.sh"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Copy the config directory
|
|
|
|
cp -rT .config "$dir/config"
|
|
|
|
|
|
|
|
# Remove Apache config if we're not an Apache variant.
|
|
|
|
if [ "$variant" != "apache" ]; then
|
|
|
|
rm "$dir/config/apache-pretty-urls.config.php"
|
2017-06-23 16:12:44 +02:00
|
|
|
fi
|
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
for arch in i386 amd64; do
|
|
|
|
travisEnv='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH='"$arch$travisEnv"
|
|
|
|
done
|
|
|
|
}
|
2017-03-14 10:48:58 +01:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\.[[:digit:]]\+\(-rc\)\?' -exec rm -r '{}' \;
|
2017-04-17 23:02:25 +02:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
fullversions=( $( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
sort -urV ) )
|
|
|
|
versions=( $( printf '%s\n' "${fullversions[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | head -1 )"
|
2017-09-14 10:23:46 +02:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
|
|
|
|
create_variant "$version" "https:\/\/download.nextcloud.com\/server\/releases"
|
2017-06-10 23:15:01 +02:00
|
|
|
done
|
|
|
|
fi
|
2017-01-13 10:31:57 +01:00
|
|
|
done
|
2017-03-14 10:48:58 +01:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
fullversions_rc=( $( curl -fsSL 'https://download.nextcloud.com/server/prereleases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
|
|
|
sort -urV ) )
|
|
|
|
versions_rc=( $( printf '%s\n' "${fullversions_rc[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions_rc[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions_rc[@]}" | grep -E "^$version" | head -1 )"
|
|
|
|
|
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
if ! check_released "$fullversion"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
|
|
|
|
create_variant "$version-rc" "https:\/\/download.nextcloud.com\/server\/prereleases"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-06-23 16:12:44 +02:00
|
|
|
# replace the fist '-' with ' '
|
|
|
|
travisEnv="$(echo "$travisEnv" | sed '0,/-/{s/-/ /}')"
|
|
|
|
|
2017-03-14 10:48:58 +01:00
|
|
|
# update .travis.yml
|
2017-06-23 16:12:44 +02:00
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" { $0 = " - stage: test images'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
2017-03-14 10:48:58 +01:00
|
|
|
echo "$travis" > .travis.yml
|