aboutsummaryrefslogtreecommitdiffstats
path: root/conf/swupd/swupd-config.inc
blob: bb9eaa513a95f2089cdc2d19cb90fe83bc55f8e3 (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
# The "format" needs to be bumped for different reasons:
# - the output of the swupd-server changes in a way that
#   a swupd-client currently installed on devices  will not
#   understand it (example: changing file names or using
#   a new compression method for archives)
# - the content of the distro changes such that a device
#   cannot update directly to the latest build (example:
#   the distro changes the boot loader and some swupd postinst
#   helper which knows about that change must be installed on
#   the device first before actually switching)
#
# meta-swupd handles the first case with SWUPD_TOOLS_FORMAT.
# The default value matches the default versions of the swupd-server
# and swupd-client. Distros can override this if they need to pick
# non-default versions of the tools, but that is not tested.
#
# Distros need to handle the second case by preparing and releasing
# a build that devices can update to (i.e. the version URL the devices
# check must have that update), then make the incompatible change and
# in the next build bump the SWUPD_DISTRO_FORMAT.
#
# In both cases, SWUPD_FORMAT gets bumped. meta-swupd notices that
# and then prepares a special transitional update:
# - the rootfs is configured to use the new SWUUPD_FORMAT and
#   OS_VERSION
# - a fake OS_VERSION-1 release is built using a swupd-server that is
#   compatible with the swupd-client before the bump
# - the OS_VERSION release then is the first one using the new format
#
# This way, devices are forced to update to OS_VERSION-1 because that
# will forever be the "latest" version for their current format.
# Once they have updated, the device really is on OS_VERSION, configured
# to use the new format, and the next update check will see future
# releases again.
#
# For this to work, "swupd-client" should always be invoked without
# explicit format parameter.
SWUPD_TOOLS_FORMAT ?= "4"
SWUPD_DISTRO_FORMAT ?= "0"
SWUPD_FORMAT = "${@ str(int('${SWUPD_TOOLS_FORMAT}') + int('${SWUPD_DISTRO_FORMAT}')) }"


# This version number *must* map to VERSION_ID in /etc/os-release and *must* be
# a non-negative integer that fits in an int.
OS_VERSION ??= "${DISTRO_VERSION}"

python () {
    ver = d.getVar('OS_VERSION', True) or 'invalid'
    try:
        ver = int(ver)
    except ValueError:
        bb.fatal("Invalid value for OS_VERSION (%s), must be a non-negative integer value." % ver)
    if ver <= 0 or ver > 2147483647:
        bb.fatal('OS_VERSION outside of valid range (> 0, <= 2147483647): %d' % ver)
}