From 3b4d386d0333c6fe91a94ed986fa08bf431e4592 Mon Sep 17 00:00:00 2001
From: Simon Eisenmann <simon@struktur.de>
Date: Tue, 1 Dec 2015 12:11:33 +0100
Subject: [PATCH] Added hack to move generated snap services to writable
partition.
---
ubuntu-device-flash/core.go | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/ubuntu-device-flash/core.go b/ubuntu-device-flash/core.go
index dd0c58a..1d9222a 100644
--- a/ubuntu-device-flash/core.go
+++ b/ubuntu-device-flash/core.go
@@ -14,6 +14,7 @@ import (
"io"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"strings"
"time"
@@ -80,11 +81,41 @@ func (coreCmd *CoreCmd) Execute(args []string) error {
if !coreCmd.Deprecated.Cloud {
coreCmd.customizationFunc = append(coreCmd.customizationFunc, coreCmd.setupCloudInit)
coreCmd.customizationFunc = append(coreCmd.customizationFunc, coreCmd.setupOemConfigs)
+ coreCmd.customizationFunc = append(coreCmd.customizationFunc, coreCmd.moveSnapServicesWritable)
}
return coreCmd.create()
}
+// hack to move snap services to writable
+func (coreCmd *CoreCmd) moveSnapServicesWritable() error {
+ fmt.Println("Moving snappy systemd services to writable ...")
+
+ systemPath := coreCmd.img.System()
+ writableSystemPath := filepath.Join(coreCmd.img.Writable(), "system-data")
+
+ paths := []string{
+ filepath.Join("etc", "systemd", "system"),
+ filepath.Join("etc", "systemd", "system", "multi-user.target.wants"),
+ }
+
+ for _, path := range paths {
+ sourceDir := filepath.Join(systemPath, path)
+ targetDir := filepath.Join(writableSystemPath, path)
+ if err := os.MkdirAll(targetDir, 0755); err != nil {
+ return err
+ }
+ mv := fmt.Sprintf("mv %s/*_*.service %s", sourceDir, targetDir)
+ cmd := exec.Command("/bin/sh", "-c", mv)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ fmt.Printf("Failed to move systemd services to writable: %s\n", out)
+ break
+ }
+ }
+
+ return nil
+}
+
// this is a hackish way to get the config in place
func (coreCmd *CoreCmd) setupOemConfigs() error {
modprobeDContent := coreCmd.oem.Config.UbuntuCore.Modprobe
--
2.5.0