From 6063608b2b212ab46aa287d0063007cae5ff429c Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 17 May 2018 09:08:25 +0200 Subject: [PATCH] update: introduce a /bootonly handler for bakery Regular updates hit /boot, /root, then /switch. bakery only updates /boot, so we need to take care of persisting the active root partition across /boot updates. --- update.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/update.go b/update.go index 1438f0f..66c9253 100644 --- a/update.go +++ b/update.go @@ -130,6 +130,17 @@ func initUpdate() error { http.HandleFunc("/update/boot", nonConcurrentUpdateHandler("/dev/mmcblk0p1")) http.HandleFunc("/update/root", nonConcurrentUpdateHandler("/dev/mmcblk0p"+inactiveRootPartition)) http.HandleFunc("/update/switch", nonConcurrentSwitchHandler(inactiveRootPartition)) + // bakery updates only the boot partition, which would reset the active root + // partition to 2. + updateHandler := nonConcurrentUpdateHandler("/dev/mmcblk0p1") + http.HandleFunc("/update/bootonly", func(w http.ResponseWriter, r *http.Request) { + updateHandler(w, r) + if err := switchRootPartition(rootPartition); err != nil { + log.Printf("switching root partition to %q failed: %v", rootPartition, err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + }) http.HandleFunc("/reboot", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "expected a POST request", http.StatusBadRequest)