summaryrefslogtreecommitdiff
path: root/.github/workflows/marco.sh
blob: 4d7917ea7d8aa0776dbaaed32516e22d31bfa0fd (plain)
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/bash

set -e
set -o pipefail

NAME="marco"
TEMP_DIR=$(mktemp -d)
OS=$(cat /etc/os-release | grep ^ID | head -n 1 | awk -F= '{ print $2}')
TAG=$1
CACHE_DIR=$2

# Use grouped output messages
infobegin() {
	echo "::group::${1}"
}
infoend() {
	echo "::endgroup::"
}

# Required packages to build marco
arch_requires=(
	autoconf-archive
	gcc
	git
	glib2
	gtk3
	intltool
	libcanberra
	libgtop
	libxpresent
	libxres
	make
	mate-common
	mate-desktop
	which
	yelp-tools
	zenity
)

debian_requires=(
	autoconf-archive
	autopoint
	gcc
	git
	intltool
	libcanberra-gtk3-dev
	libglib2.0-dev
	libgtk-3-dev
	libgtop2-dev
	libice-dev
	libmate-desktop-dev
	libpango1.0-dev
	libsm-dev
	libstartup-notification0-dev
	libx11-dev
	libxcomposite-dev
	libxcursor-dev
	libxdamage-dev
	libxext-dev
	libxfixes-dev
	libxinerama-dev
	libxpresent-dev
	libxrandr-dev
	libxrender-dev
	libxres-dev
	libxt-dev
	make
	mate-common
	x11proto-present-dev
	yelp-tools
	zenity
)

fedora_requires=(
	desktop-file-utils
	gcc
	gtk3-devel
	libSM-devel
	libXdamage-devel
	libXpresent-devel
	libXres-devel
	libcanberra-devel
	libgtop2-devel
	libsoup-devel
	make
	mate-common
	mate-desktop-devel
	redhat-rpm-config
	startup-notification-devel
	yelp-tools
	zenity
)

ubuntu_requires=(
	autoconf-archive
	autopoint
	gcc
	git
	intltool
	libcanberra-gtk3-dev
	libglib2.0-dev
	libgtk-3-dev
	libgtop2-dev
	libice-dev
	libmate-desktop-dev
	libpango1.0-dev
	libsm-dev
	libstartup-notification0-dev
	libx11-dev
	libxcomposite-dev
	libxcursor-dev
	libxdamage-dev
	libxext-dev
	libxfixes-dev
	libxinerama-dev
	libxpresent-dev
	libxrandr-dev
	libxrender-dev
	libxres-dev
	libxt-dev
	make
	mate-common
	x11proto-present-dev
	yelp-tools
	zenity
)

requires=$(eval echo '${'"${OS}_requires[@]}")

infobegin "Install Depends for marco"
case ${OS} in
arch)
	pacman --noconfirm -Syu
	pacman --noconfirm -S ${requires[@]}
	;;
debian | ubuntu)
	apt-get update -qq
	env DEBIAN_FRONTEND=noninteractive \
		apt-get install --assume-yes --no-install-recommends ${requires[@]}
	;;
fedora)
	dnf update -y
	dnf install -y ${requires[@]}
	;;
esac
infoend

# Use cached packages first
if [ -f $CACHE_DIR/${NAME}-${TAG}.tar.xz ]; then
	echo "Found cache package, reuse it"
	tar -C / -Jxf $CACHE_DIR/${NAME}-${TAG}.tar.xz
else
	git clone --recurse-submodules https://github.com/mate-desktop/${NAME}

	# Foldable output information
	infobegin "Configure"
	cd ${NAME}
	git checkout v${TAG}
	if [[ ${OS} == "debian" || ${OS} == "ubuntu" ]]; then
		./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu || {
			cat config.log
			exit 1
		}
	else
		./autogen.sh --prefix=/usr || {
			cat config.log
			exit 1
		}
	fi
	infoend

	infobegin "Build"
	make -j ${JOBS}
	infoend

	infobegin "Install"
	make install
	infoend

	# Cache this package version
	infobegin "Cache"
	[ -d ${CACHE_DIR} ] || mkdir -p ${CACHE_DIR}
	make install DESTDIR=${TEMP_DIR}
	cd $TEMP_DIR
	tar -J -cf $CACHE_DIR/${NAME}-${TAG}.tar.xz *
	infoend
fi