@@ -57,7 +57,7 @@ for version in "${versions[@]}"; do
5757 pkg ~ /^mongodb-(org(-unstable)?|10gen)$/ && $1 == "Version" { print $2 "=" pkg }
5858 ' \
5959 | grep " ^$rcVersion \." \
60- | grep -v ' ~pre~$' \
60+ | grep -vE ' ~pre~$' \
6161 | sort -V \
6262 | tac| tac
6363 }
@@ -112,18 +112,29 @@ for version in "${versions[@]}"; do
112112 cp -a docker-entrypoint.sh " $version /"
113113
114114 if [ -d " $version /windows" ]; then
115- windowsVersions=" $(
116- curl -fsSL ' https://www.mongodb.org/dl/win32/x86_64' \
117- | grep --extended-regexp --only-matching ' "https?://[^"]+/win32/mongodb-win32-x86_64-(2008plus-ssl|2012plus)-' " ${rcVersion// ./ \\ .} " ' \.[^"]+-signed.msi"' \
118- | sed \
119- -e ' s!^"!!' \
120- -e ' s!"$!!' \
121- -e ' s!http://downloads.mongodb.org/!https://downloads.mongodb.org/!' \
122- | grep $rcGrepV -E -- ' -rc[0-9]'
115+ # https://github.com/mkevenaar/chocolatey-packages/blob/8c38398f695e86c55793ee9d61f4e541a25ce0be/automatic/mongodb.install/update.ps1#L15-L31
116+ windowsDownloads=" $(
117+ curl -fsSL ' https://www.mongodb.com/download-center/community' \
118+ | grep -oiE ' "server-data">window[.]__serverData = {(.+?)}<' \
119+ | cut -d= -f2- | cut -d' <' -f1 \
120+ | jq -r --arg rcVersion " $rcVersion " '
121+ .community.versions[]
122+ | select(.version | startswith($rcVersion + "."))
123+ | .downloads[]
124+ | select(
125+ .edition == "base"
126+ and .arch == "x86_64"
127+ and (.target // "" | test("^windows(_x86_64-(2008plus-ssl|2012plus))?$"))
128+ )
129+ | .msi
130+ ' \
131+ | grep -vE -- ' -rc'
123132 ) "
124- windowsLatest=" $( echo " $windowsVersions " | head -1) "
125- windowsSha256=" $( curl -fsSL " $windowsLatest .sha256" | cut -d' ' -f1) "
126- windowsVersion=" $( echo " $windowsLatest " | sed -r -e " s!^https?://.+(${rcVersion// ./ \\ .} \.[^\" ]+)-signed.msi\$ !\1!" ) "
133+ windowsLatest=" $( head -1 <<< " $windowsDownloads" ) "
134+ windowsVersion=" $( sed -r -e " s!^https?://.+-(${rcVersion// ./ \\ .} \.[^\" ]+)-signed.msi\$ !\1!" <<< " $windowsLatest" ) "
135+
136+ # 4.3 doesn't seem to have a sha256 file (403 forbidden), so this has to be optional :(
137+ windowsSha256=" $( curl -fsSL " $windowsLatest .sha256" | cut -d' ' -f1 || :) "
127138
128139 echo " $version : $windowsVersion (windows)"
129140
@@ -135,7 +146,7 @@ for version in "${versions[@]}"; do
135146 sed -r \
136147 -e ' s/^(ENV MONGO_VERSION) .*/\1 ' " $windowsVersion " ' /' \
137148 -e ' s!^(ENV MONGO_DOWNLOAD_URL) .*!\1 ' " $windowsLatest " ' !' \
138- -e ' s/^(ENV MONGO_DOWNLOAD_SHA256) .*/\1 ' " $windowsSha256 " ' /' \
149+ -e ' s/^(ENV MONGO_DOWNLOAD_SHA256)= .*/\1= ' " $windowsSha256 " ' /' \
139150 -e ' s!^(FROM .+):.+!\1:' " ${winVariant#* -} " ' !' \
140151 Dockerfile-windows.template \
141152 > " $version /windows/$winVariant /Dockerfile"
0 commit comments