From faea1f4bd607263c59af8f228c97e9406ba482a7 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 17 Mar 2026 13:54:56 +0900 Subject: all: remove deprecated packages Closes #24. Signed-off-by: Ophestra --- system/acl/deprecated.go | 25 -------- system/dbus/deprecated.go | 115 ---------------------------------- system/deprecated.go | 50 --------------- system/wayland/deprecated.go | 144 ------------------------------------------- 4 files changed, 334 deletions(-) delete mode 100644 system/acl/deprecated.go delete mode 100644 system/dbus/deprecated.go delete mode 100644 system/deprecated.go delete mode 100644 system/wayland/deprecated.go (limited to 'system') diff --git a/system/acl/deprecated.go b/system/acl/deprecated.go deleted file mode 100644 index 1981eb72..00000000 --- a/system/acl/deprecated.go +++ /dev/null @@ -1,25 +0,0 @@ -// Package acl exposes the internal/acl package. -// -// Deprecated: This package will be removed in 0.4. -package acl - -import ( - _ "unsafe" // for go:linkname - - "hakurei.app/internal/acl" -) - -type Perm = acl.Perm - -const ( - Read = acl.Read - Write = acl.Write - Execute = acl.Execute -) - -// Update replaces ACL_USER entry with qualifier uid. -// -//go:linkname Update hakurei.app/internal/acl.Update -func Update(name string, uid int, perms ...Perm) error - -type Perms = acl.Perms diff --git a/system/dbus/deprecated.go b/system/dbus/deprecated.go deleted file mode 100644 index 8f8a6695..00000000 --- a/system/dbus/deprecated.go +++ /dev/null @@ -1,115 +0,0 @@ -// Package dbus exposes the internal/dbus package. -// -// Deprecated: This package will be removed in 0.4. -package dbus - -import ( - "context" - "io" - _ "unsafe" // for go:linkname - - "hakurei.app/hst" - "hakurei.app/internal/dbus" - "hakurei.app/message" -) - -type AddrEntry = dbus.AddrEntry - -// EqualAddrEntries returns whether two slices of [AddrEntry] are equal. -// -//go:linkname EqualAddrEntries hakurei.app/internal/dbus.EqualAddrEntries -func EqualAddrEntries(entries, target []AddrEntry) bool - -// Parse parses D-Bus address according to -// https://dbus.freedesktop.org/doc/dbus-specification.html#addresses -// -//go:linkname Parse hakurei.app/internal/dbus.Parse -func Parse(addr []byte) ([]AddrEntry, error) - -type ParseError = dbus.ParseError - -const ( - ErrNoColon = dbus.ErrNoColon - ErrBadPairSep = dbus.ErrBadPairSep - ErrBadPairKey = dbus.ErrBadPairKey - ErrBadPairVal = dbus.ErrBadPairVal - ErrBadValLength = dbus.ErrBadValLength - ErrBadValByte = dbus.ErrBadValByte - ErrBadValHexLength = dbus.ErrBadValHexLength - ErrBadValHexByte = dbus.ErrBadValHexByte -) - -type BadAddressError = dbus.BadAddressError - -// ProxyPair is an upstream dbus address and a downstream socket path. -type ProxyPair = dbus.ProxyPair - -// Args returns the xdg-dbus-proxy arguments equivalent of [hst.BusConfig]. -// -//go:linkname Args hakurei.app/internal/dbus.Args -func Args(c *hst.BusConfig, bus ProxyPair) (args []string) - -// NewConfig returns the address of a new [hst.BusConfig] with optional defaults. -// -//go:linkname NewConfig hakurei.app/internal/dbus.NewConfig -func NewConfig(id string, defaults, mpris bool) *hst.BusConfig - -const ( - /* - SessionBusAddress is the name of the environment variable where the address of the login session message bus is given in. - - If that variable is not set, applications may also try to read the address from the X Window System root window property _DBUS_SESSION_BUS_ADDRESS. - The root window property must have type STRING. The environment variable should have precedence over the root window property. - - The address of the login session message bus is given in the DBUS_SESSION_BUS_ADDRESS environment variable. - If DBUS_SESSION_BUS_ADDRESS is not set, or if it's set to the string "autolaunch:", - the system should use platform-specific methods of locating a running D-Bus session server, - or starting one if a running instance cannot be found. - Note that this mechanism is not recommended for attempting to determine if a daemon is running. - It is inherently racy to attempt to make this determination, since the bus daemon may be started just before or just after the determination is made. - Therefore, it is recommended that applications do not try to make this determination for their functionality purposes, and instead they should attempt to start the server. - - This package diverges from the specification, as the caller is unlikely to be an X client, or be in a position to autolaunch a dbus server. - So a fallback address with a socket located in the well-known default XDG_RUNTIME_DIR formatting is used. - */ - SessionBusAddress = dbus.SessionBusAddress - - /* - SystemBusAddress is the name of the environment variable where the address of the system message bus is given in. - - If that variable is not set, applications should try to connect to the well-known address unix:path=/var/run/dbus/system_bus_socket. - Implementations of the well-known system bus should listen on an address that will result in that connection being successful. - */ - SystemBusAddress = dbus.SystemBusAddress - - // FallbackSystemBusAddress is used when [SystemBusAddress] is not set. - FallbackSystemBusAddress = dbus.FallbackSystemBusAddress -) - -// Address returns the session and system bus addresses copied from environment, -// or appropriate fallback values if they are not set. -// -//go:linkname Address hakurei.app/internal/dbus.Address -func Address() (session, system string) - -// ProxyName is the file name or path to the proxy program. -// Overriding ProxyName will only affect Proxy instance created after the change. -// -//go:linkname ProxyName hakurei.app/internal/dbus.ProxyName -var ProxyName string - -// Proxy holds the state of a xdg-dbus-proxy process, and should never be copied. -type Proxy = dbus.Proxy - -// Final describes the outcome of a proxy configuration. -type Final = dbus.Final - -// Finalise creates a checked argument writer for [Proxy]. -// -//go:linkname Finalise hakurei.app/internal/dbus.Finalise -func Finalise(sessionBus, systemBus ProxyPair, session, system *hst.BusConfig) (final *Final, err error) - -// New returns a new instance of [Proxy]. -// -//go:linkname New hakurei.app/internal/dbus.New -func New(ctx context.Context, msg message.Msg, final *Final, output io.Writer) *Proxy diff --git a/system/deprecated.go b/system/deprecated.go deleted file mode 100644 index 3f0a423d..00000000 --- a/system/deprecated.go +++ /dev/null @@ -1,50 +0,0 @@ -// Package system exposes the internal/system package. -// -// Deprecated: This package will be removed in 0.4. -package system - -import ( - "context" - _ "unsafe" // for go:linkname - - "hakurei.app/hst" - "hakurei.app/internal/system" - "hakurei.app/message" -) - -// ErrDBusConfig is returned when a required hst.BusConfig argument is nil. -// -//go:linkname ErrDBusConfig hakurei.app/internal/system.ErrDBusConfig -var ErrDBusConfig error - -// OpError is returned by [I.Commit] and [I.Revert]. -type OpError = system.OpError - -const ( - // User type is reverted at final instance exit. - User = system.User - // Process type is unconditionally reverted on exit. - Process = system.Process - - CM = system.CM -) - -// Criteria specifies types of Op to revert. -type Criteria = system.Criteria - -// Op is a reversible system operation. -type Op = system.Op - -// TypeString extends [Enablement.String] to support [User] and [Process]. -// -//go:linkname TypeString hakurei.app/internal/system.TypeString -func TypeString(e hst.Enablement) string - -// New returns the address of a new [I] targeting uid. -// -//go:linkname New hakurei.app/internal/system.New -func New(ctx context.Context, msg message.Msg, uid int) (sys *I) - -// An I provides deferred operating system interaction. [I] must not be copied. -// Methods of [I] must not be used concurrently. -type I = system.I diff --git a/system/wayland/deprecated.go b/system/wayland/deprecated.go deleted file mode 100644 index 3eddbf73..00000000 --- a/system/wayland/deprecated.go +++ /dev/null @@ -1,144 +0,0 @@ -// Package wayland exposes the internal/wayland package. -// -// Deprecated: This package will be removed in 0.4. -package wayland - -import ( - "errors" - "net" - "os" - "runtime" - "sync" - "syscall" - _ "unsafe" // for go:linkname - - "hakurei.app/internal/wayland" -) - -//go:linkname bindWaylandFd hakurei.app/internal/wayland.bindWaylandFd -func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFd uintptr) error - -// Conn represents a connection to the wayland display server. -// -// Deprecated: this interface is being replaced. -// Additionally, the package it belongs to will be removed in 0.4. -type Conn struct { - conn *net.UnixConn - - done chan struct{} - doneOnce sync.Once - - mu sync.Mutex -} - -// Attach connects Conn to a wayland socket. -func (c *Conn) Attach(p string) (err error) { - c.mu.Lock() - defer c.mu.Unlock() - - if c.conn != nil { - return errors.New("socket already attached") - } - - c.conn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: p, Net: "unix"}) - return -} - -// Close releases resources and closes the connection to the wayland compositor. -func (c *Conn) Close() error { - c.mu.Lock() - defer c.mu.Unlock() - - if c.done == nil { - return errors.New("no socket bound") - } - - c.doneOnce.Do(func() { - c.done <- struct{}{} - <-c.done - }) - - // closed by wayland - runtime.SetFinalizer(c.conn, nil) - return nil -} - -// Bind binds the new socket to pathname. -func (c *Conn) Bind(pathname, appID, instanceID string) (*os.File, error) { - c.mu.Lock() - defer c.mu.Unlock() - - if c.conn == nil { - return nil, errors.New("socket not attached") - } - if c.done != nil { - return nil, errors.New("socket already bound") - } - - if rc, err := c.conn.SyscallConn(); err != nil { - // unreachable - return nil, err - } else { - c.done = make(chan struct{}) - if closeFds, err := bindRawConn(c.done, rc, pathname, appID, instanceID); err != nil { - return nil, err - } else { - return os.NewFile(uintptr(closeFds[1]), "close_fd"), nil - } - } -} - -func bindRawConn(done chan struct{}, rc syscall.RawConn, p, appID, instanceID string) ([2]int, error) { - var closeFds [2]int - if err := syscall.Pipe2(closeFds[0:], syscall.O_CLOEXEC); err != nil { - return closeFds, err - } - - setupDone := make(chan error, 1) // does not block with c.done - - go func() { - if err := rc.Control(func(fd uintptr) { - // allow the Bind method to return after setup - setupDone <- bind(fd, p, appID, instanceID, uintptr(closeFds[1])) - close(setupDone) - - // keep socket alive until done is requested - <-done - }); err != nil { - setupDone <- err - } - - // notify Close that rc.Control has returned - close(done) - }() - - // return write end of the pipe - return closeFds, <-setupDone -} - -func bind(fd uintptr, p, appID, instanceID string, syncFd uintptr) error { - // ensure p is available - if f, err := os.Create(p); err != nil { - return err - } else if err = f.Close(); err != nil { - return err - } else if err = os.Remove(p); err != nil { - return err - } - - return bindWaylandFd(p, fd, appID, instanceID, syncFd) -} - -const ( - // WaylandDisplay contains the name of the server socket - // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1147) - // which is concatenated with XDG_RUNTIME_DIR - // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1171) - // or used as-is if absolute - // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1176). - WaylandDisplay = wayland.Display - - // FallbackName is used as the wayland socket name if WAYLAND_DISPLAY is unset - // (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1149). - FallbackName = wayland.FallbackName -) -- cgit v1.3.1