summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjak1 <mike.wollmann@gmail.com>2021-03-18 08:14:59 +0100
committerjak1 <mike.wollmann@gmail.com>2021-03-18 08:14:59 +0100
commitc4a59a989f655d08a97cfaabdb318431f0c2285b (patch)
treef429ee64f793e98246f8dc8bfc77f6a8dc71d551
parent71d10242e17738a9b368c9fd1b505d3a147211db (diff)
downloaddocker-windows-builder-c4a59a989f655d08a97cfaabdb318431f0c2285b.tar.gz
docker-windows-builder-c4a59a989f655d08a97cfaabdb318431f0c2285b.tar.bz2
docker-windows-builder-c4a59a989f655d08a97cfaabdb318431f0c2285b.tar.xz
docker-windows-builder-c4a59a989f655d08a97cfaabdb318431f0c2285b.zip
[WIP] added mirroring (currently just pseudo url)
-rw-r--r--.gitignore4
-rw-r--r--.gitlab-ci.yml10
-rw-r--r--pages.sh113
-rw-r--r--public/mirrorlist.xsd29
4 files changed, 155 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 7aeeead..f3cb3c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,7 @@
# .txt files ¬_¬ if u want to document andything use .md files!
*.txt
+*.html
+
+# local test files
+public/*.xml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c205944..3ab50d0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -60,9 +60,17 @@ pages:
only:
- stable
- release
+ before_script:
+ - apk add openssh-client libxml2-utils
+ - eval $(ssh-agent -s)
+ - mkdir -p ~/.ssh
+ - echo "${SSH_PRIVATE_KEY_BASE64}" | base64 -d | tr -d '\r' > ~/.ssh/id_rsa
+ - chmod -R 700 ~/.ssh
script:
- echo "[WIP] mirror"
- - exit 1
+ - ./pages.sh
+ - scp -o StrictHostKeyChecking=no versions.txt $DEPLOY_HOST:$DEPLOY_LOCATION
+ - rm -rf ~/.ssh
<<: *job-deploy
allow_failure: true
diff --git a/pages.sh b/pages.sh
new file mode 100644
index 0000000..89e3fee
--- /dev/null
+++ b/pages.sh
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+
+version_file="versions.txt"
+checksum_file="sha256checksum.txt"
+deploy_dir="public"
+
+if [[ ${CI_PROJECT_DIR} == "" ]]; then
+ version_url="https://jak89_1.gitlab.io/docker-testing/${version_file}" # change me!
+ version_url2="https://gitlab.com/jak89_1/docker-testing/-/jobs/artifacts/master/raw/public/${version_file}?job=pages" # change me
+ echo "[NON CI] : using local paths"
+else
+ version_url="${CI_PAGES_URL}/${version_file}"
+ version_url2="https://gitlab.com/jak89_1/docker-testing/-/jobs/artifacts/master/raw/public/${version_file}?job=${CI_JOB_NAME}" # change me
+fi
+version_url3="https://manaplus.germantmw.de/versions/${version_file}" # fallback to my server if gitlab breaks its own pages *blames gitlab*
+
+#add new mirrors to the end of BOTH lines
+mirror_names=("gitlab.io gertmw.de")
+mirror_urls=("https://themanaworld.gitlab.io/manaplus/builder/ https://manaplus.germantmw.de/versions/") # change me
+
+last_checksum="https://gitlab.com/jak89_1/docker-testing/-/jobs/artifacts/master/raw/build/${checksum_file}?job=mxe_gcc5" # change me
+#last_checksum_d="https://gitlab.com/jak89_1/docker-testing/-/jobs/artifacts/master/raw/build/debug-${checksum_file}?job=mxe_gcc5" # change me # not handled yet
+
+# end of variable-scrabble (move this to gitlab-ci.yml later™)
+
+if [[ ! -d $deploy_dir ]]; then
+ mkdir -p $deploy_dir
+fi
+
+
+_b(){
+ BUFFER_HTML=${BUFFER_HTML}${1}
+}
+_x(){
+ BUFFER_XML=${BUFFER_XML}${1}
+}
+
+gen_page(){
+ _b "<!DOCTYPE html><html>"
+ _b "<head><title>MirrorList</title></head>"
+ _b "<body><center>"
+ _b "<h1>ManaPlus Mirror & Version List</h1>"
+ _b "<sup>hover to see checksums</sup>"
+ _b "<table border='1px solid black'>"
+ _b "<tr>"
+ for mirror in $mirror_names; do
+ _b "<th>$mirror</th>"
+ done
+ _b "</tr>"
+ _x "<?xml version='1.0' encoding='utf-8'?>\n"
+ _x "<!--\n Authors: jak1\n Copyright: (C) 2021 TheManaWorld Developers\n Generated by: Gitlab deploy (manual changes will get overwritten)\n-->\n"
+ _x "<versions>\n";
+ while IFS= read -r line; do
+ # ${line#* } = checksum
+ # ${line% *} = filename
+ _b "<tr>"
+ _x " <version file='${line#* }' checksum='${line% *}'>\n";
+ for mirror_url in $mirror_urls; do
+ _b "<td><a title='sha256:${line% *}' href='${mirror_url}${line#* }'>${line#* }</a></td>";
+ _x $" <mirror url='${mirror_url}${line#* }' />\n";
+ done
+ _x " </version>\n";
+ _b "</tr>"
+ done < $version_file
+ _x "</versions>\n";
+ _b "</table>"
+ _b "<a href='$version_file'>versions.txt</a>"
+ _b "</center></body>"
+ _b "</html>"
+
+ #write out files (keep source formating for xml)
+ echo $BUFFER_HTML > $deploy_dir/mirrorlist.html
+ echo -e "$BUFFER_XML" > $deploy_dir/mirrorlist.xml
+}
+
+add_new_release(){
+ wget $last_checksum -O $checksum_file -q
+ #if #TODO: check if new tag/version exists, of if the pipeline got trigerred manualy
+ checksum=$(<${checksum_file})
+ echo $checksum >> $version_file
+ rm $checksum_file || exit 1
+ #fi
+}
+
+get_version_file(){
+ # -O is needed for artifacts!
+ # getting version file from deployed pages (this can break)
+ wget $version_url -O $version_file -q
+ if [[ ! -f $version_file ]]; then
+ echo "cant download '${version_file}' from '${version_url}'"
+ # getting version file from last artifacts (this can break)
+ wget $version_url2 -O $version_file -q
+ if [[ ! -f $version_file ]]; then
+ echo "cant download '${version_file}' from '${version_url2}'"
+ # getting version file from my server as fallback
+ wget $version_url3 -O $version_file -q
+ if [[ ! -f $version_file ]]; then
+ echo "cant download '${version_file}' from '${version_url3}'"
+ # this should only happen for the first build!
+ touch $version_file
+ fi
+ fi
+ fi
+}
+
+get_version_file
+add_new_release
+gen_page
+
+xmllint --schema $deploy_dir/mirrorlist.xsd $deploy_dir/mirrorlist.xml --noout || exit 1
+
+mv $version_file $deploy_dir || exit 1
+echo "deploy passed \o/"
diff --git a/public/mirrorlist.xsd b/public/mirrorlist.xsd
new file mode 100644
index 0000000..9620925
--- /dev/null
+++ b/public/mirrorlist.xsd
@@ -0,0 +1,29 @@
+<!--
+ Authors: jak1
+ Copyright: (C) 2021 TheManaWorld Developers
+-->
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="versions">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="version" maxOccurs="unbounded" minOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="mirror" maxOccurs="unbounded" minOccurs="1">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="url" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="file" use="required"/>
+ <xs:attribute type="xs:string" name="checksum" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>