1
0
mirror of https://github.com/zokradonh/kopano-docker.git synced 2026-08-11 16:32:59 +00:00

Make repo script more dynamic #232

* also add the ability to download the tar for supported releases
* use env variables for distribution, channel and branch
* add tests for new archive download for supported releases
This commit is contained in:
Felix Bartels
2019-10-14 11:19:07 +02:00
committed by GitHub
parent 9b5187d2e4
commit 37f3ee0720
5 changed files with 65 additions and 12 deletions
+15 -10
View File
@@ -1,21 +1,23 @@
#!/bin/bash
set -eu
#set -x
[ "$DEBUG" ] && set -x
function urldecode { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
function version_from_filename {
echo "$1" | awk -F"-" '{print $2}'
echo $(basename "$1") | awk -F"-" '{print $2}'
}
function h5ai_query {
component=${1:-core}
distribution=${2:-Debian_9.0}
channel=${3:-community} # could either be community, supported or limited
branch=${4:-""} # could either be empty, "master/tarballs/", "pre-final/tarballs/" or "final/tarballs/"
filename=$(curl -s -S -L -d "action=get&items%5Bhref%5D=%2Fcommunity%2F$component%3A%2F&items%5Bwhat%5D=1" -H \
"Accept: application/json" https://download.kopano.io/community/ | jq -r '.items[].href' | \
grep "$distribution-all\|$distribution-amd64" | sed "s#/community/$component:/##")
filename=$(curl -s -XPOST "https://download.kopano.io/$channel/?action=get&items\[href\]=/$channel/$component:/$branch&items\[what\]=1" | \
jq -r '.items[].href' | \
grep "$distribution-all\|$distribution-amd64" | sed "s#/$channel/$component:/##")
if [ -z "${filename// }" ]; then
echo "unknown component"
@@ -30,22 +32,25 @@ function dl_and_package_community {
# take component as first argument and fallback to core if none given
component=${1:-core}
distribution=${2:-Debian_9.0}
channel=${3:-community}
branch=${4:-""}
# query community server by h5ai API
filename=$(h5ai_query "$component" "$distribution")
filename=$(h5ai_query "$component" "$distribution" "$channel" "$branch")
filename2=$(basename "$filename")
# download & extract packages
curl -s -S -L -o "$filename" https://download.kopano.io/community/"$component":/"${filename}"
tar xf "$filename"
curl -s -S -L -o "$filename2" https://download.kopano.io/"$channel"/"$component":/"${filename}"
tar xf "$filename2"
# save buildversion
currentVersion=$(version_from_filename "$filename")
echo "$component-$currentVersion" >> /kopano/buildversion
# save disk space
rm "$filename"
rm "$filename2"
mv "${filename%.tar.gz}" "$component"
mv "${filename2%.tar.gz}" "$component"
# prepare directory to be apt source
cd "$component"