summaryrefslogtreecommitdiffstats
path: root/web/update
blob: 06fa927eccfe2da066361ce4a0bb0723a2caa0d3 (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/sh

set -e

RED="\033[1;33;31m"
GREEN="\033[1;33;32m"
YELLOW="\033[1;33;33m"
BLUE="\033[1;33;34m"
WHITE="\033[1;33;37m"
NORMAL="\033[0m"

# FIXME: getopt
# FIXME: -f for forced indices download
# FIXME: download downstream binary index and check for architecture-missing-builds

MODE="$(basename ${0} | awk -F. '{ print $2 }')"

case "${MODE}" in
	engywuck)
		UPSTREAM_DISTRIBUTIONS="buster buster-updates buster-proposed-updates"
		DOWNSTREAM_DISTRIBUTION="engywuck"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	engywuck-backports)
		UPSTREAM_DISTRIBUTIONS="bullseye bullseye-updates bullseye-proposed-updates"
		DOWNSTREAM_DISTRIBUTION="engywuck-backports"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	fuchur)
		UPSTREAM_DISTRIBUTIONS="bullseye bullseye-updates bullseye-proposed-updates"
		DOWNSTREAM_DISTRIBUTION="fuchur"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	fuchur-backports)
		UPSTREAM_DISTRIBUTIONS="sid experimental"
		DOWNSTREAM_DISTRIBUTION="fuchur-backports"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	graograman)
		#UPSTREAM_DISTRIBUTIONS="bookworm bookworm-updates bookworm-proposed-updates"
		UPSTREAM_DISTRIBUTIONS="sid experimental"
		DOWNSTREAM_DISTRIBUTION="graograman"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	graograman-backports)
		UPSTREAM_DISTRIBUTIONS="sid experimental"
		DOWNSTREAM_DISTRIBUTION="graograman-backports"
		DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages"
		DOWNSTREAM_TAG="progress"
		;;

	buster)
		UPSTREAM_DISTRIBUTIONS="buster buster-updates buster-proposed-updates"
		DOWNSTREAM_DISTRIBUTION="buster"
		DOWNSTREAM_MIRROR="https://apt.bfh.science/packages"
		DOWNSTREAM_TAG="bfh"
		;;

	buster-backports)
		UPSTREAM_DISTRIBUTIONS="sid experimental"
		DOWNSTREAM_DISTRIBUTION="buster-backports"
		DOWNSTREAM_MIRROR="https://apt.bfh.science/packages"
		DOWNSTREAM_TAG="bfh"
		;;
esac

UPSTREAM_SECTIONS="main contrib non-free"
UPSTREAM_MIRROR="http://debian.ethz.ch/debian"

DOWNSTREAM_SECTIONS="main contrib non-free"

ARCHITECTURES="amd64 armel armhf arm64 i386 all source"

Download_downstream_indices ()
{
	# Download downstream indices
#	if [ -e "downstream.${MODE}.sources" ] && [ "$(( $(stat -c %Y downstream.${MODE}.sources) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ]
#	then
#		# file is older than 4 hours
		rm -f "downstream.${MODE}.sources"
#	fi

	if [ ! -e "downstream.${MODE}.sources" ]
	then
		for SECTION in ${DOWNSTREAM_SECTIONS}
		do
			wget -q -O - "${DOWNSTREAM_MIRROR}/dists/${DOWNSTREAM_DISTRIBUTION}/${SECTION}/source/Sources.xz" | xz -d >> "downstream.${MODE}.sources"
		done
	fi
}

Download_upstream_indices ()
{
	# Download upstream indices
#	if [ -e "upstream.${MODE}.sources" ] && [ "$(( $(stat -c %Y upstream.${MODE}.sources) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ]
#	then
#		# file is older than 4 hours
		rm -f "upstream.${MODE}.sources"
#	fi

#	if [ -e "upstream.${MODE}.binaries" ] && [ "$(( $(stat -c %Y upstream.${MODE}.binaries) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ]
#	then
#		# file is older than 4 hours
		rm -f "upstream.${MODE}.binaries"
#	fi

#	if [ ! -e "upstream.${MODE}.indices" ]
#	then
		echo -n "Downloading indices... "

		for DISTRIBUTION in ${UPSTREAM_DISTRIBUTIONS}
		do
			case "${DISTRIBUTION}" in
				*-*)
					;;

				*)
					if wget -q -O /dev/null "http://security.debian.org/dists/${DISTRIBUTION}/updates/Release"
					then
						for SECTION in ${UPSTREAM_SECTIONS}
						do
							for ARCHITECTURE in ${ARCHITECTURES}
							do
								echo -n " ."

								case "${ARCHITECTURE}" in
									source)
										wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources"
										;;

									*)
										wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries"
										;;
								esac
							done
						done
					fi

					if wget -q -O /dev/null "http://security.debian.org/dists/${DISTRIBUTION}-security/Release"
					then
						for SECTION in ${UPSTREAM_SECTIONS}
						do
							for ARCHITECTURE in ${ARCHITECTURES}
							do
								echo -n "."

								case "${ARCHITECTURE}" in
									source)
										wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}-security/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources"
										;;

									*)
										wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}-security/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries"
										;;
								esac
							done
						done
					fi
					;;
			esac

			for SECTION in ${UPSTREAM_SECTIONS}
			do
				for ARCHITECTURE in ${ARCHITECTURES}
				do
					echo -n "."

					case "${ARCHITECTURE}" in
						source)
							wget -q -O - "${UPSTREAM_MIRROR}/dists/${DISTRIBUTION}/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources"
							;;

						*)
							wget -q -O - "${UPSTREAM_MIRROR}/dists/${DISTRIBUTION}/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries"
							;;
					esac
				done
			done
		done

		echo " done."
#	fi
}

Download_downstream_indices
Download_upstream_indices


echo FIXME
exit 1



# Process downstream indices
DOWNSTREAM_PACKAGES="$(awk '/^Package: / { print $2 }' downstream.${MODE}.indices | sort -u)"

echo "################################################################################"
echo "${DOWNSTREAM_DISTRIBUTION}"
echo "################################################################################"

echo -n "Comparing versions... "

for PACKAGE in ${DOWNSTREAM_PACKAGES}
do
	DOWNSTREAM_VERSION="$(sed -n "/^Package: ${PACKAGE}$/,/^Version:/p" downstream.${MODE}.indices | awk '/^Version: / { print $2 }')"
	UPSTREAM_VERSION="$(sed -n "/^Package: ${PACKAGE}$/,/^Version:/p" upstream.${MODE}.indices | awk '/^Version: / { print $2 }' | sort -rV | head -n1)"

	if echo ${UPSTREAM_VERSION} | grep -qs '-'
	then
		# package is non-native
		DOWNSTREAM="$(echo ${DOWNSTREAM_VERSION} | sed -e "s|~${DOWNSTREAM_TAG}.*||" -e "s|${DOWNSTREAM_TAG}.*||")"
	else
		# package is native
		DOWNSTREAM="$(echo ${DOWNSTREAM_VERSION} | sed -e "s|-0.0~${DOWNSTREAM_TAG}.*||" -e "s|-0.*${DOWNSTREAM_TAG}.*||")"
	fi

	if grep -qs "^${PACKAGE} ${UPSTREAM_VERSION}$" ignore.txt
	then
		continue
	fi

	if [ -z "${UPSTREAM_VERSION}" ] && grep -qs "^${PACKAGE} ${DOWNSTREAM_VERSION}$" ignore.txt
	then
		continue
	fi

	if [ -z "${UPSTREAM_VERSION}" ]
	then
		echo " ${BLUE}${PACKAGE}${NORMAL} (!${DOWNSTREAM_VERSION})"
		continue
	fi

	# comparing versions
	if dpkg --compare-versions ${UPSTREAM_VERSION} eq ${DOWNSTREAM}
	then
		echo -n "."
	elif dpkg --compare-versions ${UPSTREAM_VERSION} gt ${DOWNSTREAM}
	then
		echo " ${RED}${PACKAGE}${NORMAL} (${UPSTREAM_VERSION} >> ${DOWNSTREAM_VERSION})"
	elif dpkg --compare-versions ${UPSTREAM_VERSION} lt ${DOWNSTREAM}
	then
		echo " ${YELLOW}${PACKAGE}${NORMAL} (${UPSTREAM_VERSION} << ${DOWNSTREAM_VERSION})"
	else
		echo " ${PACKAGE}: internal error"
	fi
done

echo " done."