-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmigrate3x.lua
138 lines (122 loc) · 5.36 KB
/
migrate3x.lua
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
--[[
This is migration script used to migrate/update system from Turris OS 3.x to 4.x.
We have to update updater first so we do immediate replan and update only updater
itself.
]]
if not version_match or not self_version or version_match(self_version, "<64.0") then
local board
if model:match("[Oo]mnia") then
board = "omnia"
elseif model:match("^[Tt]urris$") then
board = "turris1x"
else
DIE("Unsupported Turris model: " .. tostring(model))
end
--[[
We provide access to only HBS repository and to only minimal set of feeds. We
don't need anything more to update updater.
]]
Repository("turris", "https://repo.turris.cz/hbs/" .. board .. "/packages", {
priority = 60,
subdirs = { "base", "core", "packages", "turrispackages"}
})
Install('updater-ng', { critical = true })
Package('updater-ng', {
replan = 'immediate',
deps = { 'libgcc', 'busybox', 'tos3to4-earliest' }
})
--[[
Updater package does not depend on libgcc but it requires it and dependency
breaks otherwise.
]]
else
if not installed["tos3to4"] or version_match(installed["tos3to4"].version, "<2.0.0") then
--[[
The first phase is to install new version of updater-ng. This is a second
phase where we install tos3to4-early that migrates updater's configuration
before we perform full system update.
The tos3to4-early is downloaded from HBS no matter what branch user has
configured as migration itself is performed by it later on and in case of
no settings HBS is the default.
With Turris OS 5.2.0 the package lists were migrated to separate file. The
fixup scripts were created to migrate it but trigger for them won't work
for us here as we install latest version of pkglists as part of this
immediate replan.
]]
Install('tos3to4-early', 'fix-pkglists-hardening-options', { critical = true, priority = 100 })
Package('tos3to4-early', { replan = 'immediate' })
Package('fix-pkglists-hardening-options', {
replan = 'immediate',
deps = 'fix-pkglists-options'
})
Package("fix-pkglists-options", {
deps = 'tos3to4-early'
})
--[[
tos3to4-early requires switch-branch but that depends on
updater-supervisor and that pulls in load of dependencies including
cronie. The issue is that cronie collides with vixe-cron. By making
updater-supervisor virtual we skip it for now and thus we prevent the
collision.
It has to be virtual till we install package we are doing replan on here.
]]
if not installed["fix-pkglists-hardening-options"] then
Package("updater-supervisor", { virtual = true })
end
end
--[[
The process of update is that we first update only updater and minimal system
dependencies with it. That replaces libc and pretty much breaks whole system.
We do it by just including minimal subset of latest feeds together with Turris
OS 3.x feeds. With next replan all Turris OS 3.x feeds are no longer used that
unfortunately can cause update fault because there might be requests for
packages that were available in Turris OS 3.x but are no more. In such
situation system stays in broken state.
Setting that all installs are optional solves this and ensures that update is
going to proceed and that result is working system.
This does not solve problem ultimately. It instead moves problem for user to
solve later when migration is completed. User have to modify its requests.
]]
Mode("optional_installs")
--[[
We install newer version of tos3to4 that migrates switch configuration. The
migration creates situation where we are running on kernel without DSA support
and without switch-config tools and thus we can't configure LAN in any way.
The solution is to just unconditionally reboot router after migration is
finished.
]]
Package("tos3to4", { reboot = "finished" })
end
--[[
Ubus is used by init scripts to communicate with procd. The problem this creates
is that new version of ubus is unable to communicate with old ubusd. This means
that we have to restart ubusd as soon as possible. We do it in postinst of ubus
package but there can be multiple service restarts before that and every such call
to ubus takes few minutes because of ubus timeouts. It also causes action to not
be executed. This uses replan to trick updater to update ubus as soon as possible
without updating anything else. First updater is updated. Then ubus is updated and
then rest of the system.
]]
if version_match and installed and installed["ubus"] and
version_match(self_version, ">=63.0") and
version_match(installed["ubus"].version, "<2018") then
Package("ubus", { replan = 'immediate' })
-- updater-supervisor depends on cronie but we are replacing vixie-cron with
-- it. Updater is unable to remove package on immediate replan so we instead
-- just mark it as virtual and install it after replan.
Package("updater-supervisor", { virtual = true })
end
--[[
This same package as in Turris OS 3.x which contains script pulling in this
script. The difference is that Turris OS 4.x contains version 2.x of this package
to ensure update and that it does not contain noted script. Instead it contains
script migrating system configuration. That way configuration is updated and at
the same time this script is left out of all following updater executions because
tos3to4 is going to be removed.
]]
Install("tos3to4")
Package("tos3to4", { replan = "finished" })
--[[
We are potentially migrating from uClibc so reinstall everything depending on it.
]]
Package("libc", { abi_change_deep = true })