diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-05-24 15:50:30 -0300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-05-24 19:30:38 -0300 |
commit | c8139e296abc65214faa965581d9327604c19b7d (patch) | |
tree | 22b811d09e8814f9bb1dc2f5374ed4e26904d728 | |
parent | 6f2766da36447d5c02f4c40fdf1c153a5764a001 (diff) | |
download | gnome-todo-gbsneto/parallel-install.tar.gz |
ci: Add development flatpak bundle generationgbsneto/parallel-install
-rw-r--r-- | .gitlab-ci.yml | 22 | ||||
-rwxr-xr-x | build-aux/ci/build-flatpak.sh | 14 | ||||
-rwxr-xr-x | build-aux/ci/debug.sh | 52 | ||||
-rwxr-xr-x | build-aux/ci/setup.sh | 77 |
4 files changed, 157 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e185d18a..de18f7f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,17 +62,23 @@ flatpak:master: image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.28 stage: flatpak variables: - FLATPAK_MANIFEST_FILE: build-aux/flatpak/org.gnome.Todo.json + BUNDLE: "org.gnome.Todo.flatpak" + DEVELOPMENT_FLATPAK_ID: "TodoDevel" + script: - - cp ${FLATPAK_MANIFEST_FILE} . || true - - flatpak-builder --stop-at=gnome-todo app org.gnome.Todo.json - - flatpak build app meson --prefix /app -Dtracing=true _build - - flatpak build app ninja -C _build install - - flatpak-builder --finish-only --repo=repo app org.gnome.Todo.json - - flatpak build-bundle repo gnome-todo-$CI_COMMIT_REF_SLUG.flatpak --runtime-repo=https://sdk.gnome.org/gnome-nightly.flatpakrepo org.gnome.Todo + # Print debug information + - build-aux/ci/debug.sh environment + - build-aux/ci/debug.sh git + + # Setup the current directory + - build-aux/ci/setup.sh $DEVELOPMENT_FLATPAK_ID $CI_COMMIT_SHA + + # Build and generate the bundle + - build-aux/ci/build-flatpak.sh $DEVELOPMENT_FLATPAK_ID + artifacts: paths: - - gnome-todo-$CI_COMMIT_REF_SLUG.flatpak + - ${BUNDLE} - _build/meson-logs/meson-log.txt expire_in: 3 days cache: diff --git a/build-aux/ci/build-flatpak.sh b/build-aux/ci/build-flatpak.sh new file mode 100755 index 00000000..f0098609 --- /dev/null +++ b/build-aux/ci/build-flatpak.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +PROJECT_ID=org.gnome.$1 +BUNDLE=$PROJECT_ID.flatpak +MANIFEST=$PROJECT_ID.json +RUNTIME_REPO="https://sdk.gnome.org/gnome-nightly.flatpakrepo" + +flatpak-builder --stop-at=gnome-todo --bundle-sources --repo=repo app $MANIFEST + +flatpak build app meson . _build --prefix=/app -Dtracing=true +flatpak build app ninja -C _build install +flatpak-builder --finish-only --repo=repo app $MANIFEST + +flatpak build-bundle repo $BUNDLE --runtime-repo=$RUNTIME_REPO $PROJECT_ID diff --git a/build-aux/ci/debug.sh b/build-aux/ci/debug.sh new file mode 100755 index 00000000..18c40c13 --- /dev/null +++ b/build-aux/ci/debug.sh @@ -0,0 +1,52 @@ +#!/bin/bash -e + +function print_headers(){ + + if [[ -n "${1}" ]]; then + label_len=${#1} + span=$(((54 - $label_len) / 2)) + + echo + echo "= ======================================================== =" + printf "%s %${span}s %s %${span}s %s\n" "=" "" "$1" "" "=" + echo "= ======================================================== =" + else + echo "= ========================= Done ========================= =" + echo + fi +} + +function print_environment(){ + + local compiler=gcc + + echo -n "Processors: "; grep -c ^processor /proc/cpuinfo + grep ^MemTotal /proc/meminfo + id; uname -a + printenv + echo '-----------------------------------------' + cat /etc/*-release + echo '-----------------------------------------' +} + +function check_warnings(){ + + cat compilation.log | grep "warning:" | awk '{total+=1}END{print "Total number of warnings: "total}' +} + +# ----------- ----------- +if [[ $1 == "environment" ]]; then + print_headers 'Build environment ' + print_environment + print_headers + +elif [[ $1 == "git" ]]; then + print_headers 'Commit' + git log --pretty=format:"%h %cd %s" -1; echo + print_headers + +elif [[ $1 == "warnings" ]]; then + print_headers 'Warning Report ' + check_warnings + print_headers +fi diff --git a/build-aux/ci/setup.sh b/build-aux/ci/setup.sh new file mode 100755 index 00000000..54efcb62 --- /dev/null +++ b/build-aux/ci/setup.sh @@ -0,0 +1,77 @@ +#!/bin/bash -e + +COMMIT=$2 +PROJECT_ID=Todo +PROJECT_DEVEL_ID=$1 +PROJECT_NAME=gnome-todo +FLATPAK_MANIFEST=org.gnome.$PROJECT_ID.json +FLATPAK_DEVEL_MANIFEST=org.gnome.$PROJECT_DEVEL_ID.json +FLATPAK_DIR=build-aux/flatpak + +function copy_flatpak_files() { + + echo "Copying Flatpak manifest to root folder" + + cp -R ${FLATPAK_DIR}/* . || true + + # org.gnome.Todo.json → org.gnome.$PROJECT_DEVEL_ID.json + mv ${FLATPAK_MANIFEST} ${FLATPAK_DEVEL_MANIFEST} || true +} + +function modify_manifest() { + + echo "Modifying Flatpak manifest file…" + + # Replace all instances of "org.gnome.Todo" from every file + echo " - Changing app ID to org.gnome.TodoDevel" + sed -i "s,\"org\.gnome\.$PROJECT_ID\",\"org\.gnome\.$PROJECT_DEVEL_ID\",g" ${FLATPAK_DEVEL_MANIFEST} + + for file in $(grep -rl "org\.gnome\.$PROJECT_ID" data po plugins src) + do + echo " Modifying $file" + sed -i "s,org\.gnome\.$PROJECT_ID,org\.gnome\.$PROJECT_DEVEL_ID,g" $file + done + + + # org.gnome.Todo.* → org.gnome.<New Suffix>.* + echo " - Renaming files" + for file in `find . -type f -name "*org.gnome.$PROJECT_ID[.-]*"` + do + new_filename=$(sed "s,org\.gnome\.$PROJECT_ID,org\.gnome\.$PROJECT_DEVEL_ID,g" <<< $file) + + echo " Moving $file to $new_filename" + mv $file $new_filename || true + done + + # Makes org.gnome.<NewSuffix>.json point to . + echo " - Pointing Flatpak Manifest to the current branch" + sed -i "/\"url\" \: \"https\:\/\/gitlab\.gnome\.org\/GNOME\/$PROJECT_NAME\.git\"/a \"path\" : \".\"" $FLATPAK_DEVEL_MANIFEST + sed -i "/\"url\" \: \"https\:\/\/gitlab\.gnome\.org\/GNOME\/$PROJECT_NAME\.git\"/a \"commit\" : \"$COMMIT\"\," $FLATPAK_DEVEL_MANIFEST + sed -i "s/\"url\" \: \"https\:\/\/gitlab\.gnome\.org\/GNOME\/$PROJECT_NAME\.git\"//g" $FLATPAK_DEVEL_MANIFEST +} + +function print_new_files() { + + cat $FLATPAK_DEVEL_MANIFEST + + ls -Rl +} + +# ---------------------- + +echo "" +echo "Building Flatpak" +echo "" + +# Copy all the files to the root folder +copy_flatpak_files + +# Change the app id to make it parallel installable with stable To Do. +modify_manifest + +# Print the new filesystem tree and manifest for debugging +print_new_files + +echo "" +echo "Done" +echo "" |