From 504523cd470d078bdf87860a6eb7ca8e1e53c714 Mon Sep 17 00:00:00 2001 From: fewtarius Date: Sun, 23 Apr 2023 01:44:25 +0000 Subject: [PATCH] * Improve support for JELOS as a docker host. * Move configuration and data to user space (/storage/.config/docker/data). * Allow building JELOS as root when in a container (temporary). * Fix missing fonts when building BASE_ONLY. * Move debug packages to BASE_ONLY builds. --- config/options | 3 +- packages/jelos/package.mk | 2 +- packages/jelos/sources/post-update | 5 + packages/services/docker/moby/package.mk | 8 + ...moby-001-user-addon-storage-location.patch | 284 ------------------ packages/virtual/image/package.mk | 6 +- 6 files changed, 20 insertions(+), 288 deletions(-) delete mode 100644 packages/services/docker/moby/patches/moby-001-user-addon-storage-location.patch diff --git a/config/options b/config/options index 04a26cc26..0f1ac8dce 100644 --- a/config/options +++ b/config/options @@ -1,5 +1,6 @@ # Do not build as root. Ever. -if [[ "${EUID}" -eq 0 ]]; then +if [[ "${EUID}" -eq 0 ]] && \ + [ ! -f /.dockerenv ]; then echo "Building as the root user is NOT supported. Use a regular user account for the build." 1>&2 exit 1 fi diff --git a/packages/jelos/package.mk b/packages/jelos/package.mk index e3213ea00..278051ac1 100644 --- a/packages/jelos/package.mk +++ b/packages/jelos/package.mk @@ -87,7 +87,7 @@ EOF fi ### Disable automount on AMD64 - if [ "${DEVICE}" = "AMD64" ]] + if [ "${DEVICE}" = "AMD64" ] then sed -i "s#system.automount=1#system.automount=0#g" ${INSTALL}/usr/config/system/configs/system.cfg fi diff --git a/packages/jelos/sources/post-update b/packages/jelos/sources/post-update index 8aba3488e..5a9bd4484 100644 --- a/packages/jelos/sources/post-update +++ b/packages/jelos/sources/post-update @@ -54,3 +54,8 @@ rsync --ignore-existing /usr/config/rsync.conf /storage/.config/ ### Add items below this line that are safe to remove after a period of time. ################################################################################ +if [ -e "/usr/bin/docker" ] && \ + [ ! -d "/storage/.config/docker" ] +then + cp -rf /usr/config/docker /storage/.config +fi diff --git a/packages/services/docker/moby/package.mk b/packages/services/docker/moby/package.mk index 42bf54139..018e4eb52 100644 --- a/packages/services/docker/moby/package.mk +++ b/packages/services/docker/moby/package.mk @@ -56,6 +56,14 @@ makeinstall_target() { } post_install() { + mkdir -p ${INSTALL}/etc + ln -sf /storage/.config/docker ${INSTALL}/etc/docker + mkdir -p ${INSTALL}/usr/config/docker + cat <${INSTALL}/usr/config/docker/daemon.json +{ + "data-root": "/storage/.config/docker/data" +} +EOF enable_service containerd.service enable_service docker.service } diff --git a/packages/services/docker/moby/patches/moby-001-user-addon-storage-location.patch b/packages/services/docker/moby/patches/moby-001-user-addon-storage-location.patch deleted file mode 100644 index 6354be2fb..000000000 --- a/packages/services/docker/moby/patches/moby-001-user-addon-storage-location.patch +++ /dev/null @@ -1,284 +0,0 @@ -# when updating this patch just create it from scratch using this command -# -# find . -name "*.go" -print | xargs sed -i 's/\/etc\/docker/\/storage\/.kodi\/userdata\/addon_data\/service.system.docker\/config/g' -# -# -diff -Naur a/cmd/dockerd/daemon_unix.go b/cmd/dockerd/daemon_unix.go ---- a/cmd/dockerd/daemon_unix.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/cmd/dockerd/daemon_unix.go 2022-06-07 14:28:05.510327911 -0700 -@@ -25,7 +25,7 @@ - - func getDefaultDaemonConfigDir() (string, error) { - if !honorXDG { -- return "/etc/docker", nil -+ return "/storage/.kodi/userdata/addon_data/service.system.docker/config", nil - } - // NOTE: CLI uses ~/.docker while the daemon uses ~/.config/docker, because - // ~/.docker was not designed to store daemon configurations. -diff -Naur a/integration/plugin/authz/authz_plugin_test.go b/integration/plugin/authz/authz_plugin_test.go ---- a/integration/plugin/authz/authz_plugin_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration/plugin/authz/authz_plugin_test.go 2022-06-07 14:28:05.570328822 -0700 -@@ -56,15 +56,15 @@ - ctrl = &authorizationController{} - teardown := setupTest(t) - -- err := os.MkdirAll("/etc/docker/plugins", 0755) -+ err := os.MkdirAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", 0755) - assert.NilError(t, err) - -- fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", testAuthZPlugin) -+ fileName := fmt.Sprintf("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/%s.spec", testAuthZPlugin) - err = os.WriteFile(fileName, []byte(server.URL), 0644) - assert.NilError(t, err) - - return func() { -- err := os.RemoveAll("/etc/docker/plugins") -+ err := os.RemoveAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins") - assert.NilError(t, err) - - teardown() -diff -Naur a/integration/plugin/graphdriver/external_test.go b/integration/plugin/graphdriver/external_test.go ---- a/integration/plugin/graphdriver/external_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration/plugin/graphdriver/external_test.go 2022-06-07 14:28:05.570328822 -0700 -@@ -80,7 +80,7 @@ - - sserver.Close() - jserver.Close() -- err := os.RemoveAll("/etc/docker/plugins") -+ err := os.RemoveAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins") - assert.NilError(t, err) - } - -@@ -345,10 +345,10 @@ - respond(w, &graphDriverResponse{Size: size}) - }) - -- err = os.MkdirAll("/etc/docker/plugins", 0755) -+ err = os.MkdirAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", 0755) - assert.NilError(t, err) - -- specFile := "/etc/docker/plugins/" + name + "." + ext -+ specFile := "/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/" + name + "." + ext - err = os.WriteFile(specFile, b, 0644) - assert.NilError(t, err) - } -diff -Naur a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go ---- a/integration-cli/docker_cli_daemon_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration-cli/docker_cli_daemon_test.go 2022-06-07 14:28:05.556328610 -0700 -@@ -558,12 +558,12 @@ - - func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *testing.T) { - // TODO: skip or update for Windows daemon -- os.Remove("/etc/docker/key.json") -+ os.Remove("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json") - c.Setenv("DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE", "1") - s.d.Start(c) - s.d.Stop(c) - -- k, err := libtrust.LoadKeyFile("/etc/docker/key.json") -+ k, err := libtrust.LoadKeyFile("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json") - if err != nil { - c.Fatalf("Error opening key file") - } -@@ -1212,13 +1212,13 @@ - Y string `json:"y"` - } - -- os.Remove("/etc/docker/key.json") -+ os.Remove("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json") - c.Setenv("DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE", "1") - s.d.Start(c) - s.d.Stop(c) - - config := &Config{} -- bytes, err := os.ReadFile("/etc/docker/key.json") -+ bytes, err := os.ReadFile("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json") - if err != nil { - c.Fatalf("Error reading key.json file: %s", err) - } -@@ -1238,11 +1238,11 @@ - } - - // write back -- if err := os.WriteFile("/etc/docker/key.json", newBytes, 0400); err != nil { -+ if err := os.WriteFile("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json", newBytes, 0400); err != nil { - c.Fatalf("Error os.WriteFile: %s", err) - } - -- defer os.Remove("/etc/docker/key.json") -+ defer os.Remove("/storage/.kodi/userdata/addon_data/service.system.docker/config/key.json") - - if err := s.d.StartWithError(); err == nil { - c.Fatalf("It should not be successful to start daemon with wrong key: %v", err) -diff -Naur a/integration-cli/docker_cli_external_volume_driver_test.go b/integration-cli/docker_cli_external_volume_driver_test.go ---- a/integration-cli/docker_cli_external_volume_driver_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration-cli/docker_cli_external_volume_driver_test.go 2022-06-07 14:28:05.556328610 -0700 -@@ -258,10 +258,10 @@ - send(w, `{"Capabilities": { "Scope": "global" }}`) - }) - -- err := os.MkdirAll("/etc/docker/plugins", 0755) -+ err := os.MkdirAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", 0755) - assert.NilError(c, err) - -- err = os.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0644) -+ err = os.WriteFile("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/"+name+".spec", []byte(s.Server.URL), 0644) - assert.NilError(c, err) - return s - } -@@ -269,7 +269,7 @@ - func (s *DockerExternalVolumeSuite) TearDownSuite(c *testing.T) { - s.volumePlugin.Close() - -- err := os.RemoveAll("/etc/docker/plugins") -+ err := os.RemoveAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins") - assert.NilError(c, err) - } - -@@ -359,7 +359,7 @@ - - // Make sure a request to use a down driver doesn't block other requests - func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) { -- specPath := "/etc/docker/plugins/down-driver.spec" -+ specPath := "/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/down-driver.spec" - err := os.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644) - assert.NilError(c, err) - defer os.RemoveAll(specPath) -diff -Naur a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go ---- a/integration-cli/docker_cli_network_unix_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration-cli/docker_cli_network_unix_test.go 2022-06-07 14:28:05.558328640 -0700 -@@ -196,14 +196,14 @@ - } - }) - -- err := os.MkdirAll("/etc/docker/plugins", 0755) -+ err := os.MkdirAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", 0755) - assert.NilError(c, err) - -- fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv) -+ fileName := fmt.Sprintf("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/%s.spec", netDrv) - err = os.WriteFile(fileName, []byte(url), 0644) - assert.NilError(c, err) - -- ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv) -+ ipamFileName := fmt.Sprintf("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/%s.spec", ipamDrv) - err = os.WriteFile(ipamFileName, []byte(url), 0644) - assert.NilError(c, err) - } -@@ -215,7 +215,7 @@ - - s.server.Close() - -- err := os.RemoveAll("/etc/docker/plugins") -+ err := os.RemoveAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins") - assert.NilError(c, err) - } - -diff -Naur a/integration-cli/docker_cli_swarm_test.go b/integration-cli/docker_cli_swarm_test.go ---- a/integration-cli/docker_cli_swarm_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/integration-cli/docker_cli_swarm_test.go 2022-06-07 14:28:05.561328685 -0700 -@@ -770,14 +770,14 @@ - } - }) - -- err := os.MkdirAll("/etc/docker/plugins", 0755) -+ err := os.MkdirAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", 0755) - assert.NilError(c, err) - -- fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv) -+ fileName := fmt.Sprintf("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/%s.spec", netDrv) - err = os.WriteFile(fileName, []byte(url), 0644) - assert.NilError(c, err) - -- ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv) -+ ipamFileName := fmt.Sprintf("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins/%s.spec", ipamDrv) - err = os.WriteFile(ipamFileName, []byte(url), 0644) - assert.NilError(c, err) - } -@@ -789,7 +789,7 @@ - setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin) - defer func() { - s.server.Close() -- err := os.RemoveAll("/etc/docker/plugins") -+ err := os.RemoveAll("/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins") - assert.NilError(c, err) - }() - -diff -Naur a/libnetwork/drivers/remote/driver_test.go b/libnetwork/drivers/remote/driver_test.go ---- a/libnetwork/drivers/remote/driver_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/libnetwork/drivers/remote/driver_test.go 2022-06-07 14:28:05.586329065 -0700 -@@ -41,7 +41,7 @@ - } - - func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() { -- specPath := "/etc/docker/plugins" -+ specPath := "/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins" - if runtime.GOOS == "windows" { - specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins") - } -diff -Naur a/libnetwork/ipams/remote/remote_test.go b/libnetwork/ipams/remote/remote_test.go ---- a/libnetwork/ipams/remote/remote_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/libnetwork/ipams/remote/remote_test.go 2022-06-07 14:28:05.591329141 -0700 -@@ -36,7 +36,7 @@ - } - - func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() { -- specPath := "/etc/docker/plugins" -+ specPath := "/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins" - if runtime.GOOS == "windows" { - specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins") - } -diff -Naur a/libnetwork/libnetwork_unix_test.go b/libnetwork/libnetwork_unix_test.go ---- a/libnetwork/libnetwork_unix_test.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/libnetwork/libnetwork_unix_test.go 2022-06-07 14:28:05.592329156 -0700 -@@ -3,4 +3,4 @@ - - package libnetwork_test - --var specPath = "/etc/docker/plugins" -+var specPath = "/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins" -diff -Naur a/pkg/plugins/discovery_unix.go b/pkg/plugins/discovery_unix.go ---- a/pkg/plugins/discovery_unix.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/pkg/plugins/discovery_unix.go 2022-06-07 14:28:05.615329505 -0700 -@@ -3,4 +3,4 @@ - - package plugins // import "github.com/docker/docker/pkg/plugins" - --var specsPaths = []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"} -+var specsPaths = []string{"/storage/.kodi/userdata/addon_data/service.system.docker/config/plugins", "/usr/lib/docker/plugins"} -diff -Naur a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go ---- a/pkg/plugins/plugins.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/pkg/plugins/plugins.go 2022-06-07 14:28:05.616329521 -0700 -@@ -4,7 +4,7 @@ - // Docker discovers plugins by looking for them in the plugin directory whenever - // a user or container tries to use one by name. UNIX domain socket files must - // be located under /run/docker/plugins, whereas spec files can be located --// either under /etc/docker/plugins or /usr/lib/docker/plugins. This is handled -+// either under /storage/.kodi/userdata/addon_data/service.system.docker/config/plugins or /usr/lib/docker/plugins. This is handled - // by the Registry interface, which lets you list all plugins or get a plugin by - // its name if it exists. - // -diff -Naur a/registry/config_unix.go b/registry/config_unix.go ---- a/registry/config_unix.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/registry/config_unix.go 2022-06-07 14:28:05.626329672 -0700 -@@ -6,7 +6,7 @@ - // defaultCertsDir is the platform-specific default directory where certificates - // are stored. On Linux, it may be overridden through certsDir, for example, when - // running in rootless mode. --const defaultCertsDir = "/etc/docker/certs.d" -+const defaultCertsDir = "/storage/.kodi/userdata/addon_data/service.system.docker/config/certs.d" - - // cleanPath is used to ensure that a directory name is valid on the target - // platform. It will be passed in something *similar* to a URL such as -diff -Naur a/registry/endpoint_v1.go b/registry/endpoint_v1.go ---- a/registry/endpoint_v1.go 2022-06-03 10:30:24.000000000 -0700 -+++ b/registry/endpoint_v1.go 2022-06-07 14:28:05.627329688 -0700 -@@ -63,7 +63,7 @@ - if endpoint.IsSecure { - // If registry is secure and HTTPS failed, show user the error and tell them about `--insecure-registry` - // in case that's what they need. DO NOT accept unknown CA certificates, and DO NOT fallback to HTTP. -- return invalidParamf("invalid registry endpoint %s: %v. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry %s` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/%s/ca.crt", endpoint, err, endpoint.URL.Host, endpoint.URL.Host) -+ return invalidParamf("invalid registry endpoint %s: %v. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry %s` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /storage/.kodi/userdata/addon_data/service.system.docker/config/certs.d/%s/ca.crt", endpoint, err, endpoint.URL.Host, endpoint.URL.Host) - } - - // If registry is insecure and HTTPS failed, fallback to HTTP. diff --git a/packages/virtual/image/package.mk b/packages/virtual/image/package.mk index be8bc98d6..4b989f769 100644 --- a/packages/virtual/image/package.mk +++ b/packages/virtual/image/package.mk @@ -30,11 +30,14 @@ PKG_SOUND="libao" PKG_SYNC="synctools" -PKG_TOOLS="patchelf git ectool make i2c-tools evtest powertop debug" +PKG_TOOLS="patchelf git ectool make i2c-tools evtest powertop" + +PKG_DEBUG="debug" if [ "${BASE_ONLY}" = "true" ] then EMULATION_DEVICE=false + PKG_DEPENDS_TARGET+=" ${PKG_TOOLS} ${PKG_FONTS} ${PKG_DEBUG}" else PKG_DEPENDS_TARGET+=" ${PKG_TOOLS} ${PKG_FONTS} ${PKG_SOUND} ${PKG_BLUETOOTH} ${PKG_SYNC} ${PKG_UI} ${PKG_UI_TOOLS} ${PKG_MULTIMEDIA} misc-packages" @@ -43,7 +46,6 @@ else # Sound support [ "${ALSA_SUPPORT}" = "yes" ] && PKG_DEPENDS_TARGET+=" alsa" - fi [ "${DISPLAYSERVER}" = "wl" ] && PKG_DEPENDS_TARGET+=" weston"