shell

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package shell provides process execution and shell operations.

Package shell provides process execution and shell operations.

Package shell provides process execution and shell operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// SetVerbose configures verbose logging output.
	SetVerbose = logger.SetVerbose
	// MultiPrinter handles concurrent output formatting.
	MultiPrinter = logger.MultiPrinter
)

Functions

func Exec

func Exec(ctx context.Context, excludeStdout bool, dir, name string, args ...string) error

Exec executes a command in the specified directory with optional stdout exclusion.

func ExecWithContext

func ExecWithContext(
	ctx context.Context, excludeStdout bool, dir, name string, args ...string,
) error

ExecWithContext executes a command with context for cancellation control.

func ExecWithSudo

func ExecWithSudo(ctx context.Context, excludeStdout bool, dir, name string, args ...string) error

ExecWithSudo executes a command with sudo if the user is not running as root. This is specifically for package manager commands that need elevated privileges.

func ExecWithSudoContext

func ExecWithSudoContext(
	ctx context.Context, excludeStdout bool, dir, name string, args ...string,
) error

ExecWithSudoContext executes a command with sudo if needed, with context for cancellation.

func RunScript

func RunScript(cmds string) error

RunScript executes a shell script from a string.

func RunScriptInFakeroot

func RunScriptInFakeroot(cmds, packageName string, extraEnv ...[]string) error

RunScriptInFakeroot executes a shell script identically to RunScriptWithPackage but wraps every subprocess in a Linux user-namespace fakeroot so that ownership operations (install -o root, chown, etc.) succeed without real root privileges. Use this for the package() stage of PKGBUILD execution.

func RunScriptWithPackage

func RunScriptWithPackage(cmds, packageName string, extraEnv ...[]string) error

RunScriptWithPackage executes a shell script with package-specific output formatting. An optional extraEnv slice of "KEY=VALUE" pairs may be supplied; each entry overrides or extends the inherited process environment for this script invocation only, without mutating os.Environ(). This makes the function safe to call concurrently from parallel build goroutines.

Types

type GitProgressWriter

type GitProgressWriter struct {
	// contains filtered or unexported fields
}

GitProgressWriter handles git command output with progress formatting.

func NewGitProgressWriter

func NewGitProgressWriter(writer io.Writer, packageName string) *GitProgressWriter

NewGitProgressWriter creates a new GitProgressWriter instance.

func (*GitProgressWriter) Close

func (gpw *GitProgressWriter) Close() error

Close returns the buffer to the pool and should be called when done with the writer.

func (*GitProgressWriter) Write

func (gpw *GitProgressWriter) Write(p []byte) (int, error)

type PackageDecoratedWriter

type PackageDecoratedWriter struct {
	// contains filtered or unexported fields
}

PackageDecoratedWriter decorates output with package name prefixes.

func NewPackageDecoratedWriter

func NewPackageDecoratedWriter(writer io.Writer, packageName string) *PackageDecoratedWriter

NewPackageDecoratedWriter creates a new PackageDecoratedWriter instance.

func (*PackageDecoratedWriter) Close

func (pdw *PackageDecoratedWriter) Close() error

Close returns the buffer to the pool and should be called when done with the writer.

func (*PackageDecoratedWriter) Write

func (pdw *PackageDecoratedWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL