From 9812abe07188d481e2b4ff5240f2123f3dd0e11e Mon Sep 17 00:00:00 2001 From: Joey Riches Date: Tue, 28 May 2024 23:14:30 +0100 Subject: [PATCH] Initial support for rootlesskit to replace fakeroot Less overhead and less stupid fucking bugs. --- builder/build.go | 2 +- builder/eopkg.go | 1 + builder/util.go | 8 ++++++++ go.mod | 2 +- go.sum | 10 ++++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/builder/build.go b/builder/build.go index 92d426f..a2b09b5 100644 --- a/builder/build.go +++ b/builder/build.go @@ -326,7 +326,7 @@ func (p *Package) BuildYpkg(notif PidNotifier, usr *UserInfo, pman *EopkgManager ymlFile := filepath.Join(wdir, filepath.Base(p.Path)) // Now build the package - cmd := fmt.Sprintf("/bin/su %s -- fakeroot ypkg-build -D %s %s", BuildUser, wdir, ymlFile) + cmd := fmt.Sprintf("/bin/su %s -- rootlesskit ypkg-build -D %s %s", BuildUser, wdir, ymlFile) if DisableColors { cmd += " -n" } diff --git a/builder/eopkg.go b/builder/eopkg.go index 1c0c887..a29b8aa 100644 --- a/builder/eopkg.go +++ b/builder/eopkg.go @@ -205,6 +205,7 @@ func (e *EopkgManager) Upgrade() error { "abi-wizard", "iproute2", "sccache", + "rootlesskit", } if err := ChrootExec(e.notif, e.root, eopkgCommand("eopkg upgrade -y")); err != nil { diff --git a/builder/util.go b/builder/util.go index 5577885..e673f14 100644 --- a/builder/util.go +++ b/builder/util.go @@ -269,6 +269,14 @@ func AddBuildUser(rootfs string) error { return fmt.Errorf("Failed to add build user to system, reason: %w\n", err) } + if err := commands.AddUserSubUserRange(rootfs, BuildUser, 100000, 65536); err != nil { + return fmt.Errorf("Failed to write /etc/subuid file, reason: %w\n", err) + } + + if err := commands.AddUserSubGroupRange(rootfs, BuildUser, 100000, 65536); err != nil { + return fmt.Errorf("Failed to write /etc/subgid file, reason: %w\n", err) + } + return nil } diff --git a/go.mod b/go.mod index 93b61d8..a5ce244 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/cavaliergopher/grab/v3 v3.0.1 github.com/cheggaaa/pb/v3 v3.1.5 github.com/coreos/go-systemd/v22 v22.5.0 - github.com/getsolus/libosdev v0.0.0-20181023041421-9ab0f4b463fd + github.com/getsolus/libosdev v0.0.0-20240528220548-d3601e826637 github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.12.0 gitlab.com/slxh/go/powerline v0.1.0 diff --git a/go.sum b/go.sum index 679c0ae..daa7e4c 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,16 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/getsolus/libosdev v0.0.0-20181023041421-9ab0f4b463fd h1:QZoSqUIKIFeqhImxNk1cdY7M4n8JVZxTzuhP+Y0DaK8= github.com/getsolus/libosdev v0.0.0-20181023041421-9ab0f4b463fd/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= +github.com/getsolus/libosdev v0.0.0-20240528214822-149f538ed58e h1:JrNEMklhvmy4K2h4/BQRwBHus8hOlufn/qH9BJi2V94= +github.com/getsolus/libosdev v0.0.0-20240528214822-149f538ed58e/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= +github.com/getsolus/libosdev v0.0.0-20240528215907-24e15ca78130 h1:g0h6vYDvuSrKPGRn5JT2dCnfYnJfE4MYNrG3CJWKNcE= +github.com/getsolus/libosdev v0.0.0-20240528215907-24e15ca78130/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= +github.com/getsolus/libosdev v0.0.0-20240528220039-4fcbaac5230a h1:nuFqvm/ULwyboMbjJ9g1W5Oa4MJZx8CM0jglVtVi7FQ= +github.com/getsolus/libosdev v0.0.0-20240528220039-4fcbaac5230a/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= +github.com/getsolus/libosdev v0.0.0-20240528220436-ab5b63433a1e h1:/eYKDYO0GAgqcCY3llivHcjXf0Sa22YNGy0N/B56YAE= +github.com/getsolus/libosdev v0.0.0-20240528220436-ab5b63433a1e/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= +github.com/getsolus/libosdev v0.0.0-20240528220548-d3601e826637 h1:suWW+9urtrRHInhn6dRNFEFtmrKrDXh1GbyHGYLMrKU= +github.com/getsolus/libosdev v0.0.0-20240528220548-d3601e826637/go.mod h1:8P4U+IYO8T6nRPLlC6qv1wMFcc0vK0vMVDCuyiFTTLg= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=