File: update_flatpak_repo.sh

package info (click to toggle)
paperwork 1.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,060 kB
  • sloc: python: 19,833; makefile: 470; sh: 274; xml: 114
file content (140 lines) | stat: -rwxr-xr-x 2,551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
echo $PWD
git log -1

LOCKDIR=/tmp/build.lock.d
PIDFILE=${LOCKDIR}/pid

branch="${CI_COMMIT_REF_NAME}"

echo "Branch: ${branch}"

if [ "${branch}" != "master" ] && [ "${branch}" != "testing" ] && [ "${branch}" != "develop" ]; then
	echo Nothing to do
	exit 0
fi

msg() {
	echo "#####" "$@" "######"
}

export LANG=C

if ! mkdir ${LOCKDIR} ; then
	pid=$(cat ${PIDFILE})
	msg "Lock directory present (PID: ${pid})"
	if kill -0 ${pid} ; then
		msg "PID ${pid} alive"
		exit 1
	fi
fi

cleanup() {
	msg "Cleaning up ${LOCKDIR}"
	rm -rf ${LOCKDIR}
}

# possible race condition if the other was stopping
# -> re-mkdir
mkdir -p ${LOCKDIR}

msg "PID: $$ \> ${PIDFILE}"
echo $$ > ${PIDFILE}

# We make our own copy of the repository: there will be a big .flatpak-builder
# created in it with a lot of cache files we want to reuse later.
mkdir -p ~/git
cd ~/git
if ! [ -d paperwork ] ; then
	if ! git clone https://gitlab.gnome.org/World/OpenPaperwork/paperwork.git ;
	then
		echo "Clone failed !"
		exit 1
	fi
fi
cd paperwork
if ! git checkout "${branch}" || ! git pull ; then
	echo "Git pull failed !"
	exit 1
fi

mkdir -p ~/flatpak  # directory that contains the repository directory

cd flatpak/

export EXPORT_ARGS="--gpg-sign=E5ACE6FEA7A6DD48"
export REPO=/home/gitlab-runner/flatpak/paperwork_repo

for arch in x86_64 i386 ; do
	msg "=== Architecture: ${arch} ==="

	export ARCH_ARGS=--arch=${arch}

	msg "Cleaning ..."
	if ! make clean ; then
		msg "Clean failed"
		cleanup
		exit 2
	fi

	if [ -z "${branch}" ]; then
		msg "Building ..."
		if ! make ; then
			msg "Build failed"
			cleanup
			exit 2
		fi
	else
		msg "Building branch ${branch} ..."
		if ! make ${branch}.app ; then
			msg "Build failed"
			cleanup
			exit 2
		fi
		if ! make upd_repo ; then
			msg "Repo update failed"
			cleanup
			exit 2
		fi
	fi

	msg "Cleaning ..."
	if ! make clean ; then
		msg "Clean failed"
		cleanup
		exit 2
	fi
done

cd ..

chmod -R a+rX ${HOME}/flatpak

if [ -z "$RCLONE_CONFIG_OVHSWIFT_USER" ] ; then
  echo "Delivery: No rclone credentials provided."
  exit 0
fi

echo "Syncing ..."

# we must sync first the objects and the deltas before the references
# otherwise users might get temporarily an inconsistent content.
for dir in \
		paperwork_repo/objects \
		paperwork_repo/deltas \
		paperwork_repo ; do

	local_path="/home/gitlab-runner/flatpak/${dir}"

	echo "${local_path} --> ${dir} ..."

	if ! rclone --config ./rclone.conf sync ${local_path} "ovhswift:paperwork_flatpak/${dir}" ; then
		echo "rclone failed"
		exit 1
	fi

done



cleanup