Message ID | 20221110124503.274124-4-Quirin.Gylstorff@siemens.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | SWUpdate abort on installing indentical image | expand |
On 10.11.22 13:45, Quirin Gylstorff wrote: > From: Quirin Gylstorff <quirin.gylstorff@siemens.com> > > This patch adds a pre/post function to the swupdate-handler > roundrobin to compare the uuid parameter from the sw-description > with the uuid of the current system to avoid a updating with > the same image and breaking the update cycle. > > Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> > --- > ...-add-uuidcheck-to-roundrobin-handler.patch | 43 +++++++++++++++++++ > .../swupdate-handler-roundrobin_0.1.bb | 3 ++ > 2 files changed, 46 insertions(+) > create mode 100644 recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch > > diff --git a/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch > new file mode 100644 > index 0000000..f2392f4 > --- /dev/null > +++ b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch > @@ -0,0 +1,43 @@ > +From f093a3a097e518ef9f74ff88eafa9259ba50626f Mon Sep 17 00:00:00 2001 > +From: Quirin Gylstorff <quirin.gylstorff@siemens.com> > +Date: Tue, 8 Nov 2022 16:08:25 +0100 > +Subject: [PATCH] add uuidcheck to roundrobin handler > + > +Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> > +--- > + swupdate_handlers_roundrobin.lua | 22 ++++++++++++++++++++++ > + 1 file changed, 22 insertions(+) > + > +diff --git a/swupdate_handlers_roundrobin.lua b/swupdate_handlers_roundrobin.lua > +index bf9c997..bb24fc7 100644 > +--- a/swupdate_handlers_roundrobin.lua > ++++ b/swupdate_handlers_roundrobin.lua > +@@ -726,3 +726,25 @@ function pp_mmclock(when, device, image) > + swupdate.info("%s: %s MMC device %s", logprefix, when == WHEN.PRE and "Unlocked" or "Locked", device) > + return true > + end > ++ > ++function pp_uuidcheck(when, uuid, image) > ++ local filename = "/etc/os-release" > ++ local filehandle = io.open(filename, "rb") > ++ if not filehandle then > ++ swupdate.error("%s: Cannot open file %s", logprefix, filename) > ++ return false > ++ end > ++ osrelease = filehandle:read("*a") > ++ filehandle:close() > ++ image_uuid = string.match(osrelease, "IMAGE_UUID.*") > ++ if not image_uuid then > ++ swupdate.error("%s: Cannot find IMAGE_UUID in %s", logprefix, filename) > ++ return false > ++ end > ++ swupdate.debug("%s: %s", logprefix, image_uuid, uuid) > ++ if string.find(image_uuid, uuid, 1, true) then > ++ swupdate.error("%s: Update already installed.", logprefix) > ++ return false > ++ end > ++ return true > ++end > +-- > +2.35.1 > + > diff --git a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb > index 65cd652..447a093 100644 > --- a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb > +++ b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb > @@ -13,8 +13,11 @@ inherit dpkg-raw > PROVIDES = "swupdate-handlers" > > SRC_URI += "git://gitlab.com/cip-project/cip-sw-updates/swupdate-handler-roundrobin.git;protocol=https;destsuffix=swupdate-handler-roundrobin;name=swupdate-handler-roundrobin;nobranch=1" > +SRC_URI += "file://0001-add-uuidcheck-to-roundrobin-handler.patch" Can we upstream that directly? It's a CIP sub-project - should be doable. ;) > SRCREV_swupdate-handler-roundrobin ?= "fbc8d8a7e4ae8c381198cab81ae3fb13398a028e" > > +S="${WORKDIR}/${PN}" Unrelated or even unneeded change? > + > SWUPDATE_LUASCRIPT = "swupdate-handler-roundrobin/swupdate_handlers_roundrobin.lua" > > SWUPDATE_ROUND_ROBIN_HANDLER_CONFIG ?= "swupdate.handler.${SWUPDATE_BOOTLOADER}.ini" Jan
On 11/10/22 14:52, Jan Kiszka wrote: > On 10.11.22 13:45, Quirin Gylstorff wrote: >> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> >> This patch adds a pre/post function to the swupdate-handler >> roundrobin to compare the uuid parameter from the sw-description >> with the uuid of the current system to avoid a updating with >> the same image and breaking the update cycle. >> >> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> --- >> ...-add-uuidcheck-to-roundrobin-handler.patch | 43 +++++++++++++++++++ >> .../swupdate-handler-roundrobin_0.1.bb | 3 ++ >> 2 files changed, 46 insertions(+) >> create mode 100644 recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch >> >> diff --git a/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch >> new file mode 100644 >> index 0000000..f2392f4 >> --- /dev/null >> +++ b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch >> @@ -0,0 +1,43 @@ >> +From f093a3a097e518ef9f74ff88eafa9259ba50626f Mon Sep 17 00:00:00 2001 >> +From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> +Date: Tue, 8 Nov 2022 16:08:25 +0100 >> +Subject: [PATCH] add uuidcheck to roundrobin handler >> + >> +Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> +--- >> + swupdate_handlers_roundrobin.lua | 22 ++++++++++++++++++++++ >> + 1 file changed, 22 insertions(+) >> + >> +diff --git a/swupdate_handlers_roundrobin.lua b/swupdate_handlers_roundrobin.lua >> +index bf9c997..bb24fc7 100644 >> +--- a/swupdate_handlers_roundrobin.lua >> ++++ b/swupdate_handlers_roundrobin.lua >> +@@ -726,3 +726,25 @@ function pp_mmclock(when, device, image) >> + swupdate.info("%s: %s MMC device %s", logprefix, when == WHEN.PRE and "Unlocked" or "Locked", device) >> + return true >> + end >> ++ >> ++function pp_uuidcheck(when, uuid, image) >> ++ local filename = "/etc/os-release" >> ++ local filehandle = io.open(filename, "rb") >> ++ if not filehandle then >> ++ swupdate.error("%s: Cannot open file %s", logprefix, filename) >> ++ return false >> ++ end >> ++ osrelease = filehandle:read("*a") >> ++ filehandle:close() >> ++ image_uuid = string.match(osrelease, "IMAGE_UUID.*") >> ++ if not image_uuid then >> ++ swupdate.error("%s: Cannot find IMAGE_UUID in %s", logprefix, filename) >> ++ return false >> ++ end >> ++ swupdate.debug("%s: %s", logprefix, image_uuid, uuid) >> ++ if string.find(image_uuid, uuid, 1, true) then >> ++ swupdate.error("%s: Update already installed.", logprefix) >> ++ return false >> ++ end >> ++ return true >> ++end >> +-- >> +2.35.1 >> + >> diff --git a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb >> index 65cd652..447a093 100644 >> --- a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb >> +++ b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb >> @@ -13,8 +13,11 @@ inherit dpkg-raw >> PROVIDES = "swupdate-handlers" >> >> SRC_URI += "git://gitlab.com/cip-project/cip-sw-updates/swupdate-handler-roundrobin.git;protocol=https;destsuffix=swupdate-handler-roundrobin;name=swupdate-handler-roundrobin;nobranch=1" >> +SRC_URI += "file://0001-add-uuidcheck-to-roundrobin-handler.patch" > > Can we upstream that directly? It's a CIP sub-project - should be doable. ;) I will do that soon. > >> SRCREV_swupdate-handler-roundrobin ?= "fbc8d8a7e4ae8c381198cab81ae3fb13398a028e" >> >> +S="${WORKDIR}/${PN}" > > Unrelated or even unneeded change? It is necessary for the quilt patching as without it the patch is applied wrong. > >> + >> SWUPDATE_LUASCRIPT = "swupdate-handler-roundrobin/swupdate_handlers_roundrobin.lua" >> >> SWUPDATE_ROUND_ROBIN_HANDLER_CONFIG ?= "swupdate.handler.${SWUPDATE_BOOTLOADER}.ini" > > Jan > Quirin
diff --git a/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch new file mode 100644 index 0000000..f2392f4 --- /dev/null +++ b/recipes-core/swupdate-handler-roundrobin/files/0001-add-uuidcheck-to-roundrobin-handler.patch @@ -0,0 +1,43 @@ +From f093a3a097e518ef9f74ff88eafa9259ba50626f Mon Sep 17 00:00:00 2001 +From: Quirin Gylstorff <quirin.gylstorff@siemens.com> +Date: Tue, 8 Nov 2022 16:08:25 +0100 +Subject: [PATCH] add uuidcheck to roundrobin handler + +Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> +--- + swupdate_handlers_roundrobin.lua | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/swupdate_handlers_roundrobin.lua b/swupdate_handlers_roundrobin.lua +index bf9c997..bb24fc7 100644 +--- a/swupdate_handlers_roundrobin.lua ++++ b/swupdate_handlers_roundrobin.lua +@@ -726,3 +726,25 @@ function pp_mmclock(when, device, image) + swupdate.info("%s: %s MMC device %s", logprefix, when == WHEN.PRE and "Unlocked" or "Locked", device) + return true + end ++ ++function pp_uuidcheck(when, uuid, image) ++ local filename = "/etc/os-release" ++ local filehandle = io.open(filename, "rb") ++ if not filehandle then ++ swupdate.error("%s: Cannot open file %s", logprefix, filename) ++ return false ++ end ++ osrelease = filehandle:read("*a") ++ filehandle:close() ++ image_uuid = string.match(osrelease, "IMAGE_UUID.*") ++ if not image_uuid then ++ swupdate.error("%s: Cannot find IMAGE_UUID in %s", logprefix, filename) ++ return false ++ end ++ swupdate.debug("%s: %s", logprefix, image_uuid, uuid) ++ if string.find(image_uuid, uuid, 1, true) then ++ swupdate.error("%s: Update already installed.", logprefix) ++ return false ++ end ++ return true ++end +-- +2.35.1 + diff --git a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb index 65cd652..447a093 100644 --- a/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb +++ b/recipes-core/swupdate-handler-roundrobin/swupdate-handler-roundrobin_0.1.bb @@ -13,8 +13,11 @@ inherit dpkg-raw PROVIDES = "swupdate-handlers" SRC_URI += "git://gitlab.com/cip-project/cip-sw-updates/swupdate-handler-roundrobin.git;protocol=https;destsuffix=swupdate-handler-roundrobin;name=swupdate-handler-roundrobin;nobranch=1" +SRC_URI += "file://0001-add-uuidcheck-to-roundrobin-handler.patch" SRCREV_swupdate-handler-roundrobin ?= "fbc8d8a7e4ae8c381198cab81ae3fb13398a028e" +S="${WORKDIR}/${PN}" + SWUPDATE_LUASCRIPT = "swupdate-handler-roundrobin/swupdate_handlers_roundrobin.lua" SWUPDATE_ROUND_ROBIN_HANDLER_CONFIG ?= "swupdate.handler.${SWUPDATE_BOOTLOADER}.ini"