diff --git a/docs/cmd.md b/docs/cmd.md index 88f90b79..fbfe71fd 100644 --- a/docs/cmd.md +++ b/docs/cmd.md @@ -1,7 +1,7 @@ -# core -`import "github.com/vanilla-os/abroot/core"` +# cmd +`import "github.com/vanilla-os/abroot/cmd"` * [Overview](#pkg-overview) * [Index](#pkg-index) @@ -11,1386 +11,69 @@ ## Index -* [Constants](#pkg-constants) -* [Variables](#pkg-variables) -* [func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error](#AtomicRsync) -* [func AtomicSwap(src, dst string) error](#AtomicSwap) -* [func BaseImagePackageDiff(currentDigest, newDigest string) (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#BaseImagePackageDiff) -* [func CopyFile(source, dest string) error](#CopyFile) -* [func DeleteImageForRoot(root string) error](#DeleteImageForRoot) -* [func DiffFiles(sourceFile, destFile string) ([]byte, error)](#DiffFiles) -* [func FindImageWithLabel(key, value string) (string, error)](#FindImageWithLabel) -* [func GetLogFile() *os.File](#GetLogFile) -* [func GetRepoContentsForPkg(pkg string) (map[string]any, error)](#GetRepoContentsForPkg) -* [func GetToken() (string, error)](#GetToken) -* [func IsVerbose() bool](#IsVerbose) -* [func KargsBackup() error](#KargsBackup) -* [func KargsEdit() (bool, error)](#KargsEdit) -* [func KargsFormat(content string) (string, error)](#KargsFormat) -* [func KargsRead() (string, error)](#KargsRead) -* [func KargsWrite(content string) error](#KargsWrite) -* [func LogToFile(msg string, args ...interface{}) error](#LogToFile) -* [func MergeDiff(firstFile, secondFile, destination string) error](#MergeDiff) -* [func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error](#OciExportRootFs) -* [func OverlayPackageDiff() (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#OverlayPackageDiff) -* [func PrintVerbose(msg string, args ...interface{})](#PrintVerbose) -* [func PrintVerboseNoLog(msg string, args ...interface{})](#PrintVerboseNoLog) -* [func RetrieveImageForRoot(root string) (string, error)](#RetrieveImageForRoot) -* [func RootCheck(display bool) bool](#RootCheck) -* [func WriteDiff(destFile string, diffLines []byte) error](#WriteDiff) -* [type ABImage](#ABImage) - * [func NewABImage(digest string, image string) (*ABImage, error)](#NewABImage) - * [func NewABImageFromRoot() (*ABImage, error)](#NewABImageFromRoot) - * [func (a *ABImage) WriteTo(dest string, suffix string) error](#ABImage.WriteTo) -* [type ABRootManager](#ABRootManager) - * [func NewABRootManager() *ABRootManager](#NewABRootManager) - * [func (a *ABRootManager) GetBoot() (partition Partition, err error)](#ABRootManager.GetBoot) - * [func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error)](#ABRootManager.GetFuture) - * [func (a *ABRootManager) GetInit() (partition Partition, err error)](#ABRootManager.GetInit) - * [func (a *ABRootManager) GetOther() (partition ABRootPartition, err error)](#ABRootManager.GetOther) - * [func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error)](#ABRootManager.GetPartition) - * [func (a *ABRootManager) GetPartitions() error](#ABRootManager.GetPartitions) - * [func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error)](#ABRootManager.GetPresent) - * [func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error)](#ABRootManager.IdentifyPartition) - * [func (a *ABRootManager) IsCurrent(partition Partition) bool](#ABRootManager.IsCurrent) -* [type ABRootPartition](#ABRootPartition) -* [type ABSystem](#ABSystem) - * [func NewABSystem() (*ABSystem, error)](#NewABSystem) - * [func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{})](#ABSystem.AddToCleanUpQueue) - * [func (s *ABSystem) CheckAll() error](#ABSystem.CheckAll) - * [func (s *ABSystem) CheckUpdate() (string, bool)](#ABSystem.CheckUpdate) - * [func (s *ABSystem) CreateStageFile() error](#ABSystem.CreateStageFile) - * [func (s *ABSystem) GenerateCrypttab(rootPath string) error](#ABSystem.GenerateCrypttab) - * [func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error](#ABSystem.GenerateFstab) - * [func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error](#ABSystem.GenerateSystemdUnits) - * [func (s *ABSystem) LockUpgrade() error](#ABSystem.LockUpgrade) - * [func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error](#ABSystem.MergeUserEtcFiles) - * [func (s *ABSystem) RemoveFromCleanUpQueue(name string)](#ABSystem.RemoveFromCleanUpQueue) - * [func (s *ABSystem) RemoveStageFile() error](#ABSystem.RemoveStageFile) - * [func (s *ABSystem) ResetQueue()](#ABSystem.ResetQueue) - * [func (s *ABSystem) RunCleanUpQueue(fnName string) error](#ABSystem.RunCleanUpQueue) - * [func (s *ABSystem) RunOperation(operation ABSystemOperation) error](#ABSystem.RunOperation) - * [func (s *ABSystem) SyncUpperEtc(newEtc string) error](#ABSystem.SyncUpperEtc) - * [func (s *ABSystem) UnlockUpgrade() error](#ABSystem.UnlockUpgrade) - * [func (s *ABSystem) UpgradeLockExists() bool](#ABSystem.UpgradeLockExists) - * [func (s *ABSystem) UserLockRequested() bool](#ABSystem.UserLockRequested) -* [type ABSystemOperation](#ABSystemOperation) -* [type Checks](#Checks) - * [func NewChecks() *Checks](#NewChecks) - * [func (c *Checks) CheckCompatibilityFS() error](#Checks.CheckCompatibilityFS) - * [func (c *Checks) CheckConnectivity() error](#Checks.CheckConnectivity) - * [func (c *Checks) CheckRoot() error](#Checks.CheckRoot) - * [func (c *Checks) PerformAllChecks() error](#Checks.PerformAllChecks) -* [type Children](#Children) -* [type Chroot](#Chroot) - * [func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error)](#NewChroot) - * [func (c *Chroot) Close() error](#Chroot.Close) - * [func (c *Chroot) Execute(cmd string, args []string) error](#Chroot.Execute) - * [func (c *Chroot) ExecuteCmds(cmds []string) error](#Chroot.ExecuteCmds) -* [type DiskManager](#DiskManager) - * [func NewDiskManager() *DiskManager](#NewDiskManager) - * [func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error)](#DiskManager.GetPartitionByLabel) -* [type GPUInfo](#GPUInfo) -* [type Grub](#Grub) - * [func NewGrub(bootPart Partition) (*Grub, error)](#NewGrub) - * [func (g *Grub) IsBootedIntoPresentRoot() (bool, error)](#Grub.IsBootedIntoPresentRoot) -* [type ImageRecipe](#ImageRecipe) - * [func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe](#NewImageRecipe) - * [func (c *ImageRecipe) Write(path string) error](#ImageRecipe.Write) -* [type IntegrityCheck](#IntegrityCheck) - * [func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error)](#NewIntegrityCheck) - * [func (ic *IntegrityCheck) Repair() error](#IntegrityCheck.Repair) -* [type Manifest](#Manifest) -* [type PCSpecs](#PCSpecs) - * [func GetPCSpecs() PCSpecs](#GetPCSpecs) -* [type PackageManager](#PackageManager) - * [func NewPackageManager(dryRun bool) *PackageManager](#NewPackageManager) - * [func (p *PackageManager) Add(pkg string) error](#PackageManager.Add) - * [func (p *PackageManager) ClearUnstagedPackages() error](#PackageManager.ClearUnstagedPackages) - * [func (p *PackageManager) ExistsInRepo(pkg string) error](#PackageManager.ExistsInRepo) - * [func (p *PackageManager) GetAddPackages() ([]string, error)](#PackageManager.GetAddPackages) - * [func (p *PackageManager) GetAddPackagesString(sep string) (string, error)](#PackageManager.GetAddPackagesString) - * [func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string](#PackageManager.GetFinalCmd) - * [func (p *PackageManager) GetRemovePackages() ([]string, error)](#PackageManager.GetRemovePackages) - * [func (p *PackageManager) GetRemovePackagesString(sep string) (string, error)](#PackageManager.GetRemovePackagesString) - * [func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error)](#PackageManager.GetUnstagedPackages) - * [func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error)](#PackageManager.GetUnstagedPackagesPlain) - * [func (p *PackageManager) Remove(pkg string) error](#PackageManager.Remove) -* [type Partition](#Partition) - * [func (p *Partition) IsDevMapper() bool](#Partition.IsDevMapper) - * [func (p *Partition) IsEncrypted() bool](#Partition.IsEncrypted) - * [func (p *Partition) Mount(destination string) error](#Partition.Mount) - * [func (p *Partition) Unmount() error](#Partition.Unmount) -* [type QueuedFunction](#QueuedFunction) -* [type Registry](#Registry) - * [func NewRegistry() *Registry](#NewRegistry) - * [func (r *Registry) GetManifest(token string) (*Manifest, error)](#Registry.GetManifest) - * [func (r *Registry) HasUpdate(digest string) (string, bool)](#Registry.HasUpdate) -* [type UnstagedPackage](#UnstagedPackage) +* [func New(version string, fs embed.FS) *cmdr.App](#New) +* [func NewKargsCommand() *cmdr.Command](#NewKargsCommand) +* [func NewPkgCommand() *cmdr.Command](#NewPkgCommand) +* [func NewRollbackCommand() *cmdr.Command](#NewRollbackCommand) +* [func NewRootCommand(version string) *cmdr.Command](#NewRootCommand) +* [func NewStatusCommand() *cmdr.Command](#NewStatusCommand) +* [func NewUpdateInitfsCommand() *cmdr.Command](#NewUpdateInitfsCommand) +* [func NewUpgradeCommand() *cmdr.Command](#NewUpgradeCommand) #### Package files -[atomic-io.go](/src/github.com/vanilla-os/abroot/core/atomic-io.go) [checks.go](/src/github.com/vanilla-os/abroot/core/checks.go) [chroot.go](/src/github.com/vanilla-os/abroot/core/chroot.go) [diff.go](/src/github.com/vanilla-os/abroot/core/diff.go) [disk-manager.go](/src/github.com/vanilla-os/abroot/core/disk-manager.go) [grub.go](/src/github.com/vanilla-os/abroot/core/grub.go) [image-recipe.go](/src/github.com/vanilla-os/abroot/core/image-recipe.go) [image.go](/src/github.com/vanilla-os/abroot/core/image.go) [integrity.go](/src/github.com/vanilla-os/abroot/core/integrity.go) [kargs.go](/src/github.com/vanilla-os/abroot/core/kargs.go) [logging.go](/src/github.com/vanilla-os/abroot/core/logging.go) [oci.go](/src/github.com/vanilla-os/abroot/core/oci.go) [package-diff.go](/src/github.com/vanilla-os/abroot/core/package-diff.go) [packages.go](/src/github.com/vanilla-os/abroot/core/packages.go) [registry.go](/src/github.com/vanilla-os/abroot/core/registry.go) [root.go](/src/github.com/vanilla-os/abroot/core/root.go) [rsync.go](/src/github.com/vanilla-os/abroot/core/rsync.go) [specs.go](/src/github.com/vanilla-os/abroot/core/specs.go) [system.go](/src/github.com/vanilla-os/abroot/core/system.go) [utils.go](/src/github.com/vanilla-os/abroot/core/utils.go) +[kargs.go](/src/github.com/vanilla-os/abroot/cmd/kargs.go) [pkg.go](/src/github.com/vanilla-os/abroot/cmd/pkg.go) [rollback.go](/src/github.com/vanilla-os/abroot/cmd/rollback.go) [root.go](/src/github.com/vanilla-os/abroot/cmd/root.go) [status.go](/src/github.com/vanilla-os/abroot/cmd/status.go) [update-initramfs.go](/src/github.com/vanilla-os/abroot/cmd/update-initramfs.go) [upgrade.go](/src/github.com/vanilla-os/abroot/cmd/upgrade.go) -## Constants -``` go -const ( - DefaultKargs = "quiet splash bgrt_disable $vt_handoff" - KargsTmpFile = "/tmp/kargs-temp" -) -``` -``` go -const ( - PackagesBaseDir = "/etc/abroot" - DryRunPackagesBaseDir = "/tmp/abroot" - PackagesAddFile = "packages.add" - PackagesRemoveFile = "packages.remove" - PackagesUnstagedFile = "packages.unstaged" -) -``` -``` go -const ( - ADD = "+" - REMOVE = "-" -) -``` -``` go -const ( - UPGRADE = "upgrade" - FORCE_UPGRADE = "force-upgrade" - DRY_RUN_UPGRADE = "dry-run-upgrade" - APPLY = "package-apply" - DRY_RUN_APPLY = "dry-run-package-apply" - INITRAMFS = "initramfs" - DRY_RUN_INITRAMFS = "dry-run-initramfs" -) -``` -``` go -const ( - MountUnitDir = "/etc/systemd/system" -) -``` - -## Variables -``` go -var ( - ErrNoUpdate error = errors.New("no update available") -) -``` -``` go -var KargsPath = "/etc/abroot/kargs" -``` -``` go -var ReservedMounts = []string{ - "/dev", - "/dev/pts", - "/proc", - "/run", - "/sys", -} -``` - - -## func [AtomicRsync](/src/target/rsync.go?s=3049:3169#L120) -``` go -func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error -``` -AtomicRsync executes the rsync command in an atomic-like manner. -It does so by dry-running the rsync, and if it succeeds, it runs -the rsync again performing changes. -If the keepUnwanted option -is set to true, it will omit the --delete option, so that the already -existing and unwanted files will not be deleted. -To ensure the changes are applied atomically, we rsync on a _new directory first, -and use atomicSwap to replace the _new with the dst directory. - - - -## func [AtomicSwap](/src/target/atomic-io.go?s=686:724#L26) -``` go -func AtomicSwap(src, dst string) error -``` -atomicSwap allows swapping 2 files or directories in-place and atomically, -using the renameat2 syscall. This should be used instead of os.Rename, -which is not atomic at all. - - - -## func [BaseImagePackageDiff](/src/target/package-diff.go?s=732:864#L30) -``` go -func BaseImagePackageDiff(currentDigest, newDigest string) ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -BaseImagePackageDiff retrieves the added, removed, upgraded and downgraded -base packages (the ones bundled with the image). - - - -## func [CopyFile](/src/target/utils.go?s=1376:1416#L74) -``` go -func CopyFile(source, dest string) error -``` -CopyFile copies a file from source to dest - - - -## func [DeleteImageForRoot](/src/target/oci.go?s=4047:4089#L164) -``` go -func DeleteImageForRoot(root string) error -``` -DeleteImageForRoot deletes the image created for the provided root ("vos-a"|"vos-b") - - - -## func [DiffFiles](/src/target/diff.go?s=1442:1501#L57) -``` go -func DiffFiles(sourceFile, destFile string) ([]byte, error) -``` -DiffFiles returns the diff lines between source and dest files. - - - -## func [FindImageWithLabel](/src/target/oci.go?s=2711:2769#L114) -``` go -func FindImageWithLabel(key, value string) (string, error) -``` -FindImageWithLabel returns the name of the first image containinig the provided key-value pair -or an empty string if none was found - - - -## func [GetLogFile](/src/target/logging.go?s=1980:2006#L98) -``` go -func GetLogFile() *os.File -``` - - -## func [GetRepoContentsForPkg](/src/target/packages.go?s=14199:14261#L520) -``` go -func GetRepoContentsForPkg(pkg string) (map[string]any, error) -``` -GetRepoContentsForPkg retrieves package information from the repository API - - - -## func [GetToken](/src/target/registry.go?s=1685:1716#L70) -``` go -func GetToken() (string, error) -``` -GetToken generates a token using the provided tokenURL and returns it - - - -## func [IsVerbose](/src/target/logging.go?s=1338:1359#L64) -``` go -func IsVerbose() bool -``` - - -## func [KargsBackup](/src/target/kargs.go?s=1884:1908#L84) -``` go -func KargsBackup() error -``` -KargsBackup makes a backup of the current kargs file - - - -## func [KargsEdit](/src/target/kargs.go?s=3643:3673#L159) -``` go -func KargsEdit() (bool, error) -``` -KargsEdit copies the kargs file to a temporary file and opens it in the -user's preferred editor by querying the $EDITOR environment variable. -Once closed, its contents are written back to the main kargs file. -This function returns a boolean parameter indicating whether any changes -were made to the kargs file. - - - -## func [KargsFormat](/src/target/kargs.go?s=2768:2816#L123) -``` go -func KargsFormat(content string) (string, error) -``` -KargsFormat formats the contents of the kargs file, ensuring that -there are no duplicate entries, multiple spaces or trailing newline - - - -## func [KargsRead](/src/target/kargs.go?s=2275:2307#L103) -``` go -func KargsRead() (string, error) -``` -KargsRead reads the content of the kargs file - - - -## func [KargsWrite](/src/target/kargs.go?s=1243:1280#L53) -``` go -func KargsWrite(content string) error -``` -KargsWrite makes a backup of the current kargs file and then -writes the new content to it - - - -## func [LogToFile](/src/target/logging.go?s=1739:1792#L85) -``` go -func LogToFile(msg string, args ...interface{}) error -``` - - -## func [MergeDiff](/src/target/diff.go?s=539:602#L23) -``` go -func MergeDiff(firstFile, secondFile, destination string) error -``` -MergeDiff merges the diff lines between the first and second files into destination - - - -## func [OciExportRootFs](/src/target/oci.go?s=691:796#L29) -``` go -func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error -``` -OciExportRootFs generates a rootfs from a image recipe file - - - -## func [OverlayPackageDiff](/src/target/package-diff.go?s=2565:2664#L88) -``` go -func OverlayPackageDiff() ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -OverlayPackageDiff retrieves the added, removed, upgraded and downgraded -overlay packages (the ones added manually via `abroot pkg add`). - - - -## func [PrintVerbose](/src/target/logging.go?s=1464:1514#L70) -``` go -func PrintVerbose(msg string, args ...interface{}) -``` - - -## func [PrintVerboseNoLog](/src/target/logging.go?s=1604:1659#L78) -``` go -func PrintVerboseNoLog(msg string, args ...interface{}) -``` - - -## func [RetrieveImageForRoot](/src/target/oci.go?s=3686:3740#L151) -``` go -func RetrieveImageForRoot(root string) (string, error) -``` -RetrieveImageForRoot retrieves the image created for the provided root ("vos-a"|"vos-b") - - - -## func [RootCheck](/src/target/utils.go?s=690:723#L39) -``` go -func RootCheck(display bool) bool -``` - - -## func [WriteDiff](/src/target/diff.go?s=2023:2078#L81) -``` go -func WriteDiff(destFile string, diffLines []byte) error -``` -WriteDiff applies the diff lines to the destination file. - - - - -## type [ABImage](/src/target/image.go?s=499:635#L25) -``` go -type ABImage struct { - Digest string `json:"digest"` - Timestamp time.Time `json:"timestamp"` - Image string `json:"image"` -} - -``` -ABImage struct - - - - - - - -### func [NewABImage](/src/target/image.go?s=680:742#L32) -``` go -func NewABImage(digest string, image string) (*ABImage, error) -``` -NewABImage returns a new ABImage struct - - -### func [NewABImageFromRoot](/src/target/image.go?s=987:1030#L45) -``` go -func NewABImageFromRoot() (*ABImage, error) -``` -NewABImageFromRoot returns the current ABImage from /abimage.abr - - - - - -### func (\*ABImage) [WriteTo](/src/target/image.go?s=1501:1560#L66) -``` go -func (a *ABImage) WriteTo(dest string, suffix string) error -``` -WriteTo writes the json to a dest path - - - - -## type [ABRootManager](/src/target/root.go?s=525:610#L23) -``` go -type ABRootManager struct { - Partitions []ABRootPartition - VarPartition Partition -} - -``` -ABRootManager represents the ABRoot manager - - - - - - - -### func [NewABRootManager](/src/target/root.go?s=1002:1040#L41) -``` go -func NewABRootManager() *ABRootManager -``` -NewABRootManager creates a new ABRootManager - - - - - -### func (\*ABRootManager) [GetBoot](/src/target/root.go?s=5676:5742#L194) -``` go -func (a *ABRootManager) GetBoot() (partition Partition, err error) -``` -GetBoot gets the boot partition from the current device - - - - -### func (\*ABRootManager) [GetFuture](/src/target/root.go?s=4037:4111#L143) -``` go -func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error) -``` -GetFuture gets the future partition - - - - -### func (\*ABRootManager) [GetInit](/src/target/root.go?s=6201:6267#L211) -``` go -func (a *ABRootManager) GetInit() (partition Partition, err error) -``` -GetInit gets the init volume when using LVM Thin-Provisioning - - - - -### func (\*ABRootManager) [GetOther](/src/target/root.go?s=4539:4612#L159) -``` go -func (a *ABRootManager) GetOther() (partition ABRootPartition, err error) -``` -GetOther gets the other partition - - - - -### func (\*ABRootManager) [GetPartition](/src/target/root.go?s=5152:5241#L178) -``` go -func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error) -``` -GetPartition gets a partition by label - - - - -### func (\*ABRootManager) [GetPartitions](/src/target/root.go?s=1212:1257#L51) -``` go -func (a *ABRootManager) GetPartitions() error -``` -GetPartitions gets the root partitions from the current device - - - - -### func (\*ABRootManager) [GetPresent](/src/target/root.go?s=3526:3601#L127) -``` go -func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error) -``` -GetPresent gets the present partition - - - - -### func (\*ABRootManager) [IdentifyPartition](/src/target/root.go?s=2854:2949#L108) -``` go -func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error) -``` -IdentifyPartition identifies a partition - - - - -### func (\*ABRootManager) [IsCurrent](/src/target/root.go?s=2494:2553#L95) -``` go -func (a *ABRootManager) IsCurrent(partition Partition) bool -``` -IsCurrent checks if a partition is the current one - - - - -## type [ABRootPartition](/src/target/root.go?s=662:952#L29) -``` go -type ABRootPartition struct { - Label string // Matches `partLabelA` and `partLabelB` settings entries - IdentifiedAs string // Either `present` or `future` - Partition Partition - MountPoint string - MountOptions string - Uuid string - FsType string - Current bool -} - -``` -ABRootPartition represents an ABRoot partition - - - - - - - - - - -## type [ABSystem](/src/target/system.go?s=598:704#L30) -``` go -type ABSystem struct { - Checks *Checks - RootM *ABRootManager - Registry *Registry - CurImage *ABImage -} - -``` -ABSystem represents the system - - - - - - - -### func [NewABSystem](/src/target/system.go?s=1496:1533#L68) -``` go -func NewABSystem() (*ABSystem, error) -``` -NewABSystem creates a new system - - - - - -### func (\*ABSystem) [AddToCleanUpQueue](/src/target/system.go?s=7633:7719#L288) -``` go -func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{}) -``` -AddToCleanUpQueue adds a function to the queue - - - - -### func (\*ABSystem) [CheckAll](/src/target/system.go?s=1903:1938#L90) -``` go -func (s *ABSystem) CheckAll() error -``` -CheckAll performs all checks from the Checks struct - - - - -### func (\*ABSystem) [CheckUpdate](/src/target/system.go?s=2231:2278#L104) -``` go -func (s *ABSystem) CheckUpdate() (string, bool) -``` -CheckUpdate checks if there is an update available - - - - -### func (\*ABSystem) [CreateStageFile](/src/target/system.go?s=29265:29307#L1039) -``` go -func (s *ABSystem) CreateStageFile() error -``` - - - -### func (\*ABSystem) [GenerateCrypttab](/src/target/system.go?s=9297:9355#L349) -``` go -func (s *ABSystem) GenerateCrypttab(rootPath string) error -``` -GenerateCrypttab identifies which devices are encrypted and generates -the /etc/crypttab file for the specified root - - - - -### func (\*ABSystem) [GenerateFstab](/src/target/system.go?s=8227:8304#L312) -``` go -func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error -``` -GenerateFstab generates a fstab file for the future root - - - - -### func (\*ABSystem) [GenerateSystemdUnits](/src/target/system.go?s=10698:10782#L398) -``` go -func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error -``` -GenerateSystemdUnits generates systemd units that mount the mutable parts of the system - - - - -### func (\*ABSystem) [LockUpgrade](/src/target/system.go?s=28810:28848#L1017) -``` go -func (s *ABSystem) LockUpgrade() error -``` - - - -### func (\*ABSystem) [MergeUserEtcFiles](/src/target/system.go?s=2546:2634#L111) -``` go -func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error -``` -MergeUserEtcFiles merges user-related files from the new lower etc (/.system/etc) -with the old upper etc, if present, saving the result in the new upper etc. - - - - -### func (\*ABSystem) [RemoveFromCleanUpQueue](/src/target/system.go?s=7888:7942#L297) -``` go -func (s *ABSystem) RemoveFromCleanUpQueue(name string) -``` -RemoveFromCleanUpQueue removes a function from the queue - - - - -### func (\*ABSystem) [RemoveStageFile](/src/target/system.go?s=29505:29547#L1050) -``` go -func (s *ABSystem) RemoveStageFile() error -``` - - - -### func (\*ABSystem) [ResetQueue](/src/target/system.go?s=8102:8133#L307) -``` go -func (s *ABSystem) ResetQueue() -``` -ResetQueue resets the queue - - - - -### func (\*ABSystem) [RunCleanUpQueue](/src/target/system.go?s=4882:4937#L199) -``` go -func (s *ABSystem) RunCleanUpQueue(fnName string) error -``` -RunCleanUpQueue runs the functions in the queue or only the specified one - - - - -### func (\*ABSystem) [RunOperation](/src/target/system.go?s=13435:13501#L477) -``` go -func (s *ABSystem) RunOperation(operation ABSystemOperation) error -``` -RunOperation executes a root-switching operation from the options below: - - - UPGRADE: Upgrades to a new image, if available, - FORCE_UPGRADE: Forces the upgrade operation, even if no new image is available, - APPLY: Applies package changes, but doesn't update the system. - INITRAMFS: Updates the initramfs for the future root, but doesn't update the system. - - - - -### func (\*ABSystem) [SyncUpperEtc](/src/target/system.go?s=3834:3886#L158) -``` go -func (s *ABSystem) SyncUpperEtc(newEtc string) error -``` -SyncUpperEtc syncs the mutable etc directories from /var/lib/abroot/etc - - - - -### func (\*ABSystem) [UnlockUpgrade](/src/target/system.go?s=29036:29076#L1028) -``` go -func (s *ABSystem) UnlockUpgrade() error -``` - - - -### func (\*ABSystem) [UpgradeLockExists](/src/target/system.go?s=28613:28656#L1008) -``` go -func (s *ABSystem) UpgradeLockExists() bool -``` - - - -### func (\*ABSystem) [UserLockRequested](/src/target/system.go?s=28412:28455#L999) -``` go -func (s *ABSystem) UserLockRequested() bool -``` - - - -## type [ABSystemOperation](/src/target/system.go?s=1116:1145#L57) -``` go -type ABSystemOperation string -``` - - - - - - - - - -## type [Checks](/src/target/checks.go?s=616:636#L27) -``` go -type Checks struct{} - -``` -Represents a Checks struct which contains all the checks which can -be performed one by one or all at once using PerformAllChecks() - - - - - - - -### func [NewChecks](/src/target/checks.go?s=679:703#L30) -``` go -func NewChecks() *Checks -``` -NewChecks returns a new Checks struct - - - - - -### func (\*Checks) [CheckCompatibilityFS](/src/target/checks.go?s=1074:1119#L55) -``` go -func (c *Checks) CheckCompatibilityFS() error -``` -CheckCompatibilityFS checks if the filesystem is compatible - - - - -### func (\*Checks) [CheckConnectivity](/src/target/checks.go?s=2252:2294#L93) -``` go -func (c *Checks) CheckConnectivity() error -``` -CheckConnectivity checks if the system is connected to the internet - - - - -### func (\*Checks) [CheckRoot](/src/target/checks.go?s=2598:2632#L107) -``` go -func (c *Checks) CheckRoot() error -``` -CheckRoot checks if the user is root - - - - -### func (\*Checks) [PerformAllChecks](/src/target/checks.go?s=767:808#L35) -``` go -func (c *Checks) PerformAllChecks() error -``` -PerformAllChecks performs all checks - - - - -## type [Children](/src/target/disk-manager.go?s=1735:2089#L61) -``` go -type Children struct { - MountPoint string `json:"mountpoint"` - FsType string `json:"fstype"` - Label string `json:"label"` - Uuid string `json:"uuid"` - LogicalName string `json:"name"` - Size string `json:"size"` - MountOptions string `json:"mountopts"` - Children []Children `json:"children"` -} - -``` -The children a block device or partition may have - - - - - - - - - - -## type [Chroot](/src/target/chroot.go?s=542:621#L25) -``` go -type Chroot struct { - // contains filtered or unexported fields -} - -``` -Chroot is a struct which represents a chroot environment - - - - - - - -### func [NewChroot](/src/target/chroot.go?s=753:833#L40) -``` go -func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error) -``` -NewChroot creates a new chroot environment - - - - - -### func (\*Chroot) [Close](/src/target/chroot.go?s=1759:1789#L78) -``` go -func (c *Chroot) Close() error -``` -Close unmounts all the bind mounts - - - - -### func (\*Chroot) [Execute](/src/target/chroot.go?s=2473:2530#L109) -``` go -func (c *Chroot) Execute(cmd string, args []string) error -``` -Execute runs a command in the chroot environment - - - - -### func (\*Chroot) [ExecuteCmds](/src/target/chroot.go?s=3078:3127#L130) -``` go -func (c *Chroot) ExecuteCmds(cmds []string) error -``` -ExecuteCmds runs a list of commands in the chroot environment, -stops at the first error - - - - -## type [DiskManager](/src/target/disk-manager.go?s=532:557#L27) -``` go -type DiskManager struct{} - -``` -DiskManager represents a disk - - - - - - - -### func [NewDiskManager](/src/target/disk-manager.go?s=2135:2169#L73) -``` go -func NewDiskManager() *DiskManager -``` -NewDiskManager creates a new DiskManager - - -### func (\*DiskManager) [GetPartitionByLabel](/src/target/disk-manager.go?s=2339:2413#L80) -``` go -func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error) -``` -GetPartitionByLabel finds a partition by searching for its label. - -If no partition can be found with the given label, returns error. - - - - -## type [GPUInfo](/src/target/specs.go?s=596:659#L31) -``` go -type GPUInfo struct { - Address string - Description string -} - -``` - - - - - - - - - -## type [Grub](/src/target/grub.go?s=519:579#L26) -``` go -type Grub struct { - PresentRoot string - FutureRoot string -} - -``` - - - - - - -### func [NewGrub](/src/target/grub.go?s=3047:3094#L126) -``` go -func NewGrub(bootPart Partition) (*Grub, error) -``` -NewGrub creates a new Grub instance - - - - - -### func (\*Grub) [IsBootedIntoPresentRoot](/src/target/grub.go?s=4101:4155#L168) -``` go -func (g *Grub) IsBootedIntoPresentRoot() (bool, error) -``` - - - -## type [ImageRecipe](/src/target/image-recipe.go?s=439:552#L21) -``` go -type ImageRecipe struct { - From string - Labels map[string]string - Args map[string]string - Content string -} - -``` - - - - - - -### func [NewImageRecipe](/src/target/image-recipe.go?s=605:717#L29) -``` go -func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe -``` -NewImageRecipe creates a new ImageRecipe struct - - - - - -### func (\*ImageRecipe) [Write](/src/target/image-recipe.go?s=907:953#L41) -``` go -func (c *ImageRecipe) Write(path string) error -``` -Write writes a ImageRecipe to a path - - - - -## type [IntegrityCheck](/src/target/integrity.go?s=498:644#L24) -``` go -type IntegrityCheck struct { - // contains filtered or unexported fields -} - -``` - - - - - - -### func [NewIntegrityCheck](/src/target/integrity.go?s=705:787#L33) -``` go -func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error) -``` -NewIntegrityCheck creates a new IntegrityCheck instance - - - - - -### func (\*IntegrityCheck) [Repair](/src/target/integrity.go?s=3427:3467#L151) -``` go -func (ic *IntegrityCheck) Repair() error -``` -Repair repairs the system - - - - -## type [Manifest](/src/target/registry.go?s=585:662#L30) -``` go -type Manifest struct { - Manifest []byte - Digest string - Layers []string -} - -``` -Manifest struct - - - - - - - - - - -## type [PCSpecs](/src/target/specs.go?s=524:594#L25) -``` go -type PCSpecs struct { - CPU string - GPU []string - Memory string -} - -``` - - - - - - -### func [GetPCSpecs](/src/target/specs.go?s=1838:1863#L93) -``` go -func GetPCSpecs() PCSpecs -``` - - - - -## type [PackageManager](/src/target/packages.go?s=590:650#L31) -``` go -type PackageManager struct { - // contains filtered or unexported fields -} - -``` -PackageManager struct - - - - - - - -### func [NewPackageManager](/src/target/packages.go?s=1250:1301#L60) -``` go -func NewPackageManager(dryRun bool) *PackageManager -``` -NewPackageManager returns a new PackageManager struct - - - - - -### func (\*PackageManager) [Add](/src/target/packages.go?s=2539:2585#L117) -``` go -func (p *PackageManager) Add(pkg string) error -``` -Add adds a package to the packages.add file - - - - -### func (\*PackageManager) [ClearUnstagedPackages](/src/target/packages.go?s=6419:6473#L252) -``` go -func (p *PackageManager) ClearUnstagedPackages() error -``` -ClearUnstagedPackages removes all packages from the unstaged list - - - - -### func (\*PackageManager) [ExistsInRepo](/src/target/packages.go?s=13359:13414#L490) -``` go -func (p *PackageManager) ExistsInRepo(pkg string) error -``` - - - -### func (\*PackageManager) [GetAddPackages](/src/target/packages.go?s=4767:4826#L200) -``` go -func (p *PackageManager) GetAddPackages() ([]string, error) -``` -GetAddPackages returns the packages in the packages.add file - - - - -### func (\*PackageManager) [GetAddPackagesString](/src/target/packages.go?s=6672:6745#L258) -``` go -func (p *PackageManager) GetAddPackagesString(sep string) (string, error) -``` -GetAddPackages returns the packages in the packages.add file as string - - - - -### func (\*PackageManager) [GetFinalCmd](/src/target/packages.go?s=11425:11497#L432) -``` go -func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string -``` - - - -### func (\*PackageManager) [GetRemovePackages](/src/target/packages.go?s=5000:5062#L206) -``` go -func (p *PackageManager) GetRemovePackages() ([]string, error) -``` -GetRemovePackages returns the packages in the packages.remove file - - - - -### func (\*PackageManager) [GetRemovePackagesString](/src/target/packages.go?s=7137:7213#L271) -``` go -func (p *PackageManager) GetRemovePackagesString(sep string) (string, error) -``` -GetRemovePackages returns the packages in the packages.remove file as string - - - - -### func (\*PackageManager) [GetUnstagedPackages](/src/target/packages.go?s=5250:5323#L212) -``` go -func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error) -``` -GetUnstagedPackages returns the package changes that are yet to be applied - - - - -### func (\*PackageManager) [GetUnstagedPackagesPlain](/src/target/packages.go?s=5917:5986#L235) -``` go -func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error) -``` -GetUnstagedPackagesPlain returns the package changes that are yet to be applied -as strings - - - - -### func (\*PackageManager) [Remove](/src/target/packages.go?s=3654:3703#L163) -``` go -func (p *PackageManager) Remove(pkg string) error -``` -Remove removes a package from the packages.add file - - - - -## type [Partition](/src/target/disk-manager.go?s=641:1680#L30) -``` go -type Partition struct { - Label string - MountPoint string - MountOptions string - Uuid string - FsType string - - // If standard partition, Device will be the partition's name (e.g. sda1, nvme0n1p1). - // If LUKS-encrypted or LVM volume, Device will be the name in device-mapper. - Device string - - // If the partition is LUKS-encrypted or an LVM volume, the logical volume - // opened in /dev/mapper will be a child of the physical partition in /dev. - // Otherwise, the partition will be a direct child of the block device, and - // Parent will be nil. - // - // The same logic applies for encrypted LVM volumes. When this is the case, - // the filesystem hirearchy is as follows: - // - // NAME FSTYPE - // -- sda1 LVM2_member - // |-- myVG-myLV crypto_LUKS - // |-- luks-volume btrfs - // - // In this case, the parent of "luks-volume" is "myVG-myLV", which, - // in turn, has "sda1" as parent. Since "sda1" is a physical partition, - // its parent is nil. - Parent *Partition -} - -``` -Partition represents either a standard partition or a device-mapper partition. - - - - - - - - - - -### func (\*Partition) [IsDevMapper](/src/target/disk-manager.go?s=6054:6092#L211) -``` go -func (p *Partition) IsDevMapper() bool -``` -Returns whether the partition is a device-mapper virtual partition - - - - -### func (\*Partition) [IsEncrypted](/src/target/disk-manager.go?s=6180:6218#L216) +## func [New](/src/target/root.go?s=537:584#L28) ``` go -func (p *Partition) IsEncrypted() bool +func New(version string, fs embed.FS) *cmdr.App ``` -IsEncrypted returns whether the partition is encrypted - - - - -### func (\*Partition) [Mount](/src/target/disk-manager.go?s=4757:4808#L161) -``` go -func (p *Partition) Mount(destination string) error -``` -Mount mounts a partition to a directory - - -### func (\*Partition) [Unmount](/src/target/disk-manager.go?s=5459:5494#L189) +## func [NewKargsCommand](/src/target/kargs.go?s=584:620#L27) ``` go -func (p *Partition) Unmount() error +func NewKargsCommand() *cmdr.Command ``` -Unmount unmounts a partition - - -## type [QueuedFunction](/src/target/system.go?s=706:791#L37) +## func [NewPkgCommand](/src/target/pkg.go?s=611:645#L28) ``` go -type QueuedFunction struct { - Name string - Values []interface{} - Priority int -} - +func NewPkgCommand() *cmdr.Command ``` - - - - - - - -## type [Registry](/src/target/registry.go?s=528:564#L25) +## func [NewRollbackCommand](/src/target/rollback.go?s=526:565#L23) ``` go -type Registry struct { - API string -} - +func NewRollbackCommand() *cmdr.Command ``` -Registry struct - - - - - -### func [NewRegistry](/src/target/registry.go?s=709:737#L37) +## func [NewRootCommand](/src/target/root.go?s=649:698#L32) ``` go -func NewRegistry() *Registry +func NewRootCommand(version string) *cmdr.Command ``` -NewRegistry returns a new Registry struct - - - -### func (\*Registry) [GetManifest](/src/target/registry.go?s=2507:2570#L107) +## func [NewStatusCommand](/src/target/status.go?s=690:727#L34) ``` go -func (r *Registry) GetManifest(token string) (*Manifest, error) +func NewStatusCommand() *cmdr.Command ``` -GetManifest returns the manifest of the image - - -### func (\*Registry) [HasUpdate](/src/target/registry.go?s=977:1035#L45) +## func [NewUpdateInitfsCommand](/src/target/update-initramfs.go?s=526:569#L23) ``` go -func (r *Registry) HasUpdate(digest string) (string, bool) +func NewUpdateInitfsCommand() *cmdr.Command ``` -HasUpdate checks if the image/tag from the registry has a different digest - - -## type [UnstagedPackage](/src/target/packages.go?s=1139:1191#L55) +## func [NewUpgradeCommand](/src/target/upgrade.go?s=605:643#L29) ``` go -type UnstagedPackage struct { - Name, Status string -} - +func NewUpgradeCommand() *cmdr.Command ``` -An unstaged package is a package that is waiting to be applied -to the next root. - -Every time a `pkg apply` or `upgrade` operation -is executed, all unstaged packages are consumed and added/removed -in the next root. - - - - - - - diff --git a/docs/extras.md b/docs/extras.md index 88f90b79..e69de29b 100644 --- a/docs/extras.md +++ b/docs/extras.md @@ -1,1402 +0,0 @@ - - -# core -`import "github.com/vanilla-os/abroot/core"` - -* [Overview](#pkg-overview) -* [Index](#pkg-index) - -## Overview - - - -## Index -* [Constants](#pkg-constants) -* [Variables](#pkg-variables) -* [func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error](#AtomicRsync) -* [func AtomicSwap(src, dst string) error](#AtomicSwap) -* [func BaseImagePackageDiff(currentDigest, newDigest string) (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#BaseImagePackageDiff) -* [func CopyFile(source, dest string) error](#CopyFile) -* [func DeleteImageForRoot(root string) error](#DeleteImageForRoot) -* [func DiffFiles(sourceFile, destFile string) ([]byte, error)](#DiffFiles) -* [func FindImageWithLabel(key, value string) (string, error)](#FindImageWithLabel) -* [func GetLogFile() *os.File](#GetLogFile) -* [func GetRepoContentsForPkg(pkg string) (map[string]any, error)](#GetRepoContentsForPkg) -* [func GetToken() (string, error)](#GetToken) -* [func IsVerbose() bool](#IsVerbose) -* [func KargsBackup() error](#KargsBackup) -* [func KargsEdit() (bool, error)](#KargsEdit) -* [func KargsFormat(content string) (string, error)](#KargsFormat) -* [func KargsRead() (string, error)](#KargsRead) -* [func KargsWrite(content string) error](#KargsWrite) -* [func LogToFile(msg string, args ...interface{}) error](#LogToFile) -* [func MergeDiff(firstFile, secondFile, destination string) error](#MergeDiff) -* [func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error](#OciExportRootFs) -* [func OverlayPackageDiff() (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#OverlayPackageDiff) -* [func PrintVerbose(msg string, args ...interface{})](#PrintVerbose) -* [func PrintVerboseNoLog(msg string, args ...interface{})](#PrintVerboseNoLog) -* [func RetrieveImageForRoot(root string) (string, error)](#RetrieveImageForRoot) -* [func RootCheck(display bool) bool](#RootCheck) -* [func WriteDiff(destFile string, diffLines []byte) error](#WriteDiff) -* [type ABImage](#ABImage) - * [func NewABImage(digest string, image string) (*ABImage, error)](#NewABImage) - * [func NewABImageFromRoot() (*ABImage, error)](#NewABImageFromRoot) - * [func (a *ABImage) WriteTo(dest string, suffix string) error](#ABImage.WriteTo) -* [type ABRootManager](#ABRootManager) - * [func NewABRootManager() *ABRootManager](#NewABRootManager) - * [func (a *ABRootManager) GetBoot() (partition Partition, err error)](#ABRootManager.GetBoot) - * [func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error)](#ABRootManager.GetFuture) - * [func (a *ABRootManager) GetInit() (partition Partition, err error)](#ABRootManager.GetInit) - * [func (a *ABRootManager) GetOther() (partition ABRootPartition, err error)](#ABRootManager.GetOther) - * [func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error)](#ABRootManager.GetPartition) - * [func (a *ABRootManager) GetPartitions() error](#ABRootManager.GetPartitions) - * [func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error)](#ABRootManager.GetPresent) - * [func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error)](#ABRootManager.IdentifyPartition) - * [func (a *ABRootManager) IsCurrent(partition Partition) bool](#ABRootManager.IsCurrent) -* [type ABRootPartition](#ABRootPartition) -* [type ABSystem](#ABSystem) - * [func NewABSystem() (*ABSystem, error)](#NewABSystem) - * [func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{})](#ABSystem.AddToCleanUpQueue) - * [func (s *ABSystem) CheckAll() error](#ABSystem.CheckAll) - * [func (s *ABSystem) CheckUpdate() (string, bool)](#ABSystem.CheckUpdate) - * [func (s *ABSystem) CreateStageFile() error](#ABSystem.CreateStageFile) - * [func (s *ABSystem) GenerateCrypttab(rootPath string) error](#ABSystem.GenerateCrypttab) - * [func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error](#ABSystem.GenerateFstab) - * [func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error](#ABSystem.GenerateSystemdUnits) - * [func (s *ABSystem) LockUpgrade() error](#ABSystem.LockUpgrade) - * [func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error](#ABSystem.MergeUserEtcFiles) - * [func (s *ABSystem) RemoveFromCleanUpQueue(name string)](#ABSystem.RemoveFromCleanUpQueue) - * [func (s *ABSystem) RemoveStageFile() error](#ABSystem.RemoveStageFile) - * [func (s *ABSystem) ResetQueue()](#ABSystem.ResetQueue) - * [func (s *ABSystem) RunCleanUpQueue(fnName string) error](#ABSystem.RunCleanUpQueue) - * [func (s *ABSystem) RunOperation(operation ABSystemOperation) error](#ABSystem.RunOperation) - * [func (s *ABSystem) SyncUpperEtc(newEtc string) error](#ABSystem.SyncUpperEtc) - * [func (s *ABSystem) UnlockUpgrade() error](#ABSystem.UnlockUpgrade) - * [func (s *ABSystem) UpgradeLockExists() bool](#ABSystem.UpgradeLockExists) - * [func (s *ABSystem) UserLockRequested() bool](#ABSystem.UserLockRequested) -* [type ABSystemOperation](#ABSystemOperation) -* [type Checks](#Checks) - * [func NewChecks() *Checks](#NewChecks) - * [func (c *Checks) CheckCompatibilityFS() error](#Checks.CheckCompatibilityFS) - * [func (c *Checks) CheckConnectivity() error](#Checks.CheckConnectivity) - * [func (c *Checks) CheckRoot() error](#Checks.CheckRoot) - * [func (c *Checks) PerformAllChecks() error](#Checks.PerformAllChecks) -* [type Children](#Children) -* [type Chroot](#Chroot) - * [func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error)](#NewChroot) - * [func (c *Chroot) Close() error](#Chroot.Close) - * [func (c *Chroot) Execute(cmd string, args []string) error](#Chroot.Execute) - * [func (c *Chroot) ExecuteCmds(cmds []string) error](#Chroot.ExecuteCmds) -* [type DiskManager](#DiskManager) - * [func NewDiskManager() *DiskManager](#NewDiskManager) - * [func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error)](#DiskManager.GetPartitionByLabel) -* [type GPUInfo](#GPUInfo) -* [type Grub](#Grub) - * [func NewGrub(bootPart Partition) (*Grub, error)](#NewGrub) - * [func (g *Grub) IsBootedIntoPresentRoot() (bool, error)](#Grub.IsBootedIntoPresentRoot) -* [type ImageRecipe](#ImageRecipe) - * [func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe](#NewImageRecipe) - * [func (c *ImageRecipe) Write(path string) error](#ImageRecipe.Write) -* [type IntegrityCheck](#IntegrityCheck) - * [func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error)](#NewIntegrityCheck) - * [func (ic *IntegrityCheck) Repair() error](#IntegrityCheck.Repair) -* [type Manifest](#Manifest) -* [type PCSpecs](#PCSpecs) - * [func GetPCSpecs() PCSpecs](#GetPCSpecs) -* [type PackageManager](#PackageManager) - * [func NewPackageManager(dryRun bool) *PackageManager](#NewPackageManager) - * [func (p *PackageManager) Add(pkg string) error](#PackageManager.Add) - * [func (p *PackageManager) ClearUnstagedPackages() error](#PackageManager.ClearUnstagedPackages) - * [func (p *PackageManager) ExistsInRepo(pkg string) error](#PackageManager.ExistsInRepo) - * [func (p *PackageManager) GetAddPackages() ([]string, error)](#PackageManager.GetAddPackages) - * [func (p *PackageManager) GetAddPackagesString(sep string) (string, error)](#PackageManager.GetAddPackagesString) - * [func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string](#PackageManager.GetFinalCmd) - * [func (p *PackageManager) GetRemovePackages() ([]string, error)](#PackageManager.GetRemovePackages) - * [func (p *PackageManager) GetRemovePackagesString(sep string) (string, error)](#PackageManager.GetRemovePackagesString) - * [func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error)](#PackageManager.GetUnstagedPackages) - * [func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error)](#PackageManager.GetUnstagedPackagesPlain) - * [func (p *PackageManager) Remove(pkg string) error](#PackageManager.Remove) -* [type Partition](#Partition) - * [func (p *Partition) IsDevMapper() bool](#Partition.IsDevMapper) - * [func (p *Partition) IsEncrypted() bool](#Partition.IsEncrypted) - * [func (p *Partition) Mount(destination string) error](#Partition.Mount) - * [func (p *Partition) Unmount() error](#Partition.Unmount) -* [type QueuedFunction](#QueuedFunction) -* [type Registry](#Registry) - * [func NewRegistry() *Registry](#NewRegistry) - * [func (r *Registry) GetManifest(token string) (*Manifest, error)](#Registry.GetManifest) - * [func (r *Registry) HasUpdate(digest string) (string, bool)](#Registry.HasUpdate) -* [type UnstagedPackage](#UnstagedPackage) - - -#### Package files -[atomic-io.go](/src/github.com/vanilla-os/abroot/core/atomic-io.go) [checks.go](/src/github.com/vanilla-os/abroot/core/checks.go) [chroot.go](/src/github.com/vanilla-os/abroot/core/chroot.go) [diff.go](/src/github.com/vanilla-os/abroot/core/diff.go) [disk-manager.go](/src/github.com/vanilla-os/abroot/core/disk-manager.go) [grub.go](/src/github.com/vanilla-os/abroot/core/grub.go) [image-recipe.go](/src/github.com/vanilla-os/abroot/core/image-recipe.go) [image.go](/src/github.com/vanilla-os/abroot/core/image.go) [integrity.go](/src/github.com/vanilla-os/abroot/core/integrity.go) [kargs.go](/src/github.com/vanilla-os/abroot/core/kargs.go) [logging.go](/src/github.com/vanilla-os/abroot/core/logging.go) [oci.go](/src/github.com/vanilla-os/abroot/core/oci.go) [package-diff.go](/src/github.com/vanilla-os/abroot/core/package-diff.go) [packages.go](/src/github.com/vanilla-os/abroot/core/packages.go) [registry.go](/src/github.com/vanilla-os/abroot/core/registry.go) [root.go](/src/github.com/vanilla-os/abroot/core/root.go) [rsync.go](/src/github.com/vanilla-os/abroot/core/rsync.go) [specs.go](/src/github.com/vanilla-os/abroot/core/specs.go) [system.go](/src/github.com/vanilla-os/abroot/core/system.go) [utils.go](/src/github.com/vanilla-os/abroot/core/utils.go) - - -## Constants -``` go -const ( - DefaultKargs = "quiet splash bgrt_disable $vt_handoff" - KargsTmpFile = "/tmp/kargs-temp" -) -``` -``` go -const ( - PackagesBaseDir = "/etc/abroot" - DryRunPackagesBaseDir = "/tmp/abroot" - PackagesAddFile = "packages.add" - PackagesRemoveFile = "packages.remove" - PackagesUnstagedFile = "packages.unstaged" -) -``` -``` go -const ( - ADD = "+" - REMOVE = "-" -) -``` -``` go -const ( - UPGRADE = "upgrade" - FORCE_UPGRADE = "force-upgrade" - DRY_RUN_UPGRADE = "dry-run-upgrade" - APPLY = "package-apply" - DRY_RUN_APPLY = "dry-run-package-apply" - INITRAMFS = "initramfs" - DRY_RUN_INITRAMFS = "dry-run-initramfs" -) -``` -``` go -const ( - MountUnitDir = "/etc/systemd/system" -) -``` - -## Variables -``` go -var ( - ErrNoUpdate error = errors.New("no update available") -) -``` -``` go -var KargsPath = "/etc/abroot/kargs" -``` -``` go -var ReservedMounts = []string{ - "/dev", - "/dev/pts", - "/proc", - "/run", - "/sys", -} -``` - - -## func [AtomicRsync](/src/target/rsync.go?s=3049:3169#L120) -``` go -func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error -``` -AtomicRsync executes the rsync command in an atomic-like manner. -It does so by dry-running the rsync, and if it succeeds, it runs -the rsync again performing changes. -If the keepUnwanted option -is set to true, it will omit the --delete option, so that the already -existing and unwanted files will not be deleted. -To ensure the changes are applied atomically, we rsync on a _new directory first, -and use atomicSwap to replace the _new with the dst directory. - - - -## func [AtomicSwap](/src/target/atomic-io.go?s=686:724#L26) -``` go -func AtomicSwap(src, dst string) error -``` -atomicSwap allows swapping 2 files or directories in-place and atomically, -using the renameat2 syscall. This should be used instead of os.Rename, -which is not atomic at all. - - - -## func [BaseImagePackageDiff](/src/target/package-diff.go?s=732:864#L30) -``` go -func BaseImagePackageDiff(currentDigest, newDigest string) ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -BaseImagePackageDiff retrieves the added, removed, upgraded and downgraded -base packages (the ones bundled with the image). - - - -## func [CopyFile](/src/target/utils.go?s=1376:1416#L74) -``` go -func CopyFile(source, dest string) error -``` -CopyFile copies a file from source to dest - - - -## func [DeleteImageForRoot](/src/target/oci.go?s=4047:4089#L164) -``` go -func DeleteImageForRoot(root string) error -``` -DeleteImageForRoot deletes the image created for the provided root ("vos-a"|"vos-b") - - - -## func [DiffFiles](/src/target/diff.go?s=1442:1501#L57) -``` go -func DiffFiles(sourceFile, destFile string) ([]byte, error) -``` -DiffFiles returns the diff lines between source and dest files. - - - -## func [FindImageWithLabel](/src/target/oci.go?s=2711:2769#L114) -``` go -func FindImageWithLabel(key, value string) (string, error) -``` -FindImageWithLabel returns the name of the first image containinig the provided key-value pair -or an empty string if none was found - - - -## func [GetLogFile](/src/target/logging.go?s=1980:2006#L98) -``` go -func GetLogFile() *os.File -``` - - -## func [GetRepoContentsForPkg](/src/target/packages.go?s=14199:14261#L520) -``` go -func GetRepoContentsForPkg(pkg string) (map[string]any, error) -``` -GetRepoContentsForPkg retrieves package information from the repository API - - - -## func [GetToken](/src/target/registry.go?s=1685:1716#L70) -``` go -func GetToken() (string, error) -``` -GetToken generates a token using the provided tokenURL and returns it - - - -## func [IsVerbose](/src/target/logging.go?s=1338:1359#L64) -``` go -func IsVerbose() bool -``` - - -## func [KargsBackup](/src/target/kargs.go?s=1884:1908#L84) -``` go -func KargsBackup() error -``` -KargsBackup makes a backup of the current kargs file - - - -## func [KargsEdit](/src/target/kargs.go?s=3643:3673#L159) -``` go -func KargsEdit() (bool, error) -``` -KargsEdit copies the kargs file to a temporary file and opens it in the -user's preferred editor by querying the $EDITOR environment variable. -Once closed, its contents are written back to the main kargs file. -This function returns a boolean parameter indicating whether any changes -were made to the kargs file. - - - -## func [KargsFormat](/src/target/kargs.go?s=2768:2816#L123) -``` go -func KargsFormat(content string) (string, error) -``` -KargsFormat formats the contents of the kargs file, ensuring that -there are no duplicate entries, multiple spaces or trailing newline - - - -## func [KargsRead](/src/target/kargs.go?s=2275:2307#L103) -``` go -func KargsRead() (string, error) -``` -KargsRead reads the content of the kargs file - - - -## func [KargsWrite](/src/target/kargs.go?s=1243:1280#L53) -``` go -func KargsWrite(content string) error -``` -KargsWrite makes a backup of the current kargs file and then -writes the new content to it - - - -## func [LogToFile](/src/target/logging.go?s=1739:1792#L85) -``` go -func LogToFile(msg string, args ...interface{}) error -``` - - -## func [MergeDiff](/src/target/diff.go?s=539:602#L23) -``` go -func MergeDiff(firstFile, secondFile, destination string) error -``` -MergeDiff merges the diff lines between the first and second files into destination - - - -## func [OciExportRootFs](/src/target/oci.go?s=691:796#L29) -``` go -func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error -``` -OciExportRootFs generates a rootfs from a image recipe file - - - -## func [OverlayPackageDiff](/src/target/package-diff.go?s=2565:2664#L88) -``` go -func OverlayPackageDiff() ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -OverlayPackageDiff retrieves the added, removed, upgraded and downgraded -overlay packages (the ones added manually via `abroot pkg add`). - - - -## func [PrintVerbose](/src/target/logging.go?s=1464:1514#L70) -``` go -func PrintVerbose(msg string, args ...interface{}) -``` - - -## func [PrintVerboseNoLog](/src/target/logging.go?s=1604:1659#L78) -``` go -func PrintVerboseNoLog(msg string, args ...interface{}) -``` - - -## func [RetrieveImageForRoot](/src/target/oci.go?s=3686:3740#L151) -``` go -func RetrieveImageForRoot(root string) (string, error) -``` -RetrieveImageForRoot retrieves the image created for the provided root ("vos-a"|"vos-b") - - - -## func [RootCheck](/src/target/utils.go?s=690:723#L39) -``` go -func RootCheck(display bool) bool -``` - - -## func [WriteDiff](/src/target/diff.go?s=2023:2078#L81) -``` go -func WriteDiff(destFile string, diffLines []byte) error -``` -WriteDiff applies the diff lines to the destination file. - - - - -## type [ABImage](/src/target/image.go?s=499:635#L25) -``` go -type ABImage struct { - Digest string `json:"digest"` - Timestamp time.Time `json:"timestamp"` - Image string `json:"image"` -} - -``` -ABImage struct - - - - - - - -### func [NewABImage](/src/target/image.go?s=680:742#L32) -``` go -func NewABImage(digest string, image string) (*ABImage, error) -``` -NewABImage returns a new ABImage struct - - -### func [NewABImageFromRoot](/src/target/image.go?s=987:1030#L45) -``` go -func NewABImageFromRoot() (*ABImage, error) -``` -NewABImageFromRoot returns the current ABImage from /abimage.abr - - - - - -### func (\*ABImage) [WriteTo](/src/target/image.go?s=1501:1560#L66) -``` go -func (a *ABImage) WriteTo(dest string, suffix string) error -``` -WriteTo writes the json to a dest path - - - - -## type [ABRootManager](/src/target/root.go?s=525:610#L23) -``` go -type ABRootManager struct { - Partitions []ABRootPartition - VarPartition Partition -} - -``` -ABRootManager represents the ABRoot manager - - - - - - - -### func [NewABRootManager](/src/target/root.go?s=1002:1040#L41) -``` go -func NewABRootManager() *ABRootManager -``` -NewABRootManager creates a new ABRootManager - - - - - -### func (\*ABRootManager) [GetBoot](/src/target/root.go?s=5676:5742#L194) -``` go -func (a *ABRootManager) GetBoot() (partition Partition, err error) -``` -GetBoot gets the boot partition from the current device - - - - -### func (\*ABRootManager) [GetFuture](/src/target/root.go?s=4037:4111#L143) -``` go -func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error) -``` -GetFuture gets the future partition - - - - -### func (\*ABRootManager) [GetInit](/src/target/root.go?s=6201:6267#L211) -``` go -func (a *ABRootManager) GetInit() (partition Partition, err error) -``` -GetInit gets the init volume when using LVM Thin-Provisioning - - - - -### func (\*ABRootManager) [GetOther](/src/target/root.go?s=4539:4612#L159) -``` go -func (a *ABRootManager) GetOther() (partition ABRootPartition, err error) -``` -GetOther gets the other partition - - - - -### func (\*ABRootManager) [GetPartition](/src/target/root.go?s=5152:5241#L178) -``` go -func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error) -``` -GetPartition gets a partition by label - - - - -### func (\*ABRootManager) [GetPartitions](/src/target/root.go?s=1212:1257#L51) -``` go -func (a *ABRootManager) GetPartitions() error -``` -GetPartitions gets the root partitions from the current device - - - - -### func (\*ABRootManager) [GetPresent](/src/target/root.go?s=3526:3601#L127) -``` go -func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error) -``` -GetPresent gets the present partition - - - - -### func (\*ABRootManager) [IdentifyPartition](/src/target/root.go?s=2854:2949#L108) -``` go -func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error) -``` -IdentifyPartition identifies a partition - - - - -### func (\*ABRootManager) [IsCurrent](/src/target/root.go?s=2494:2553#L95) -``` go -func (a *ABRootManager) IsCurrent(partition Partition) bool -``` -IsCurrent checks if a partition is the current one - - - - -## type [ABRootPartition](/src/target/root.go?s=662:952#L29) -``` go -type ABRootPartition struct { - Label string // Matches `partLabelA` and `partLabelB` settings entries - IdentifiedAs string // Either `present` or `future` - Partition Partition - MountPoint string - MountOptions string - Uuid string - FsType string - Current bool -} - -``` -ABRootPartition represents an ABRoot partition - - - - - - - - - - -## type [ABSystem](/src/target/system.go?s=598:704#L30) -``` go -type ABSystem struct { - Checks *Checks - RootM *ABRootManager - Registry *Registry - CurImage *ABImage -} - -``` -ABSystem represents the system - - - - - - - -### func [NewABSystem](/src/target/system.go?s=1496:1533#L68) -``` go -func NewABSystem() (*ABSystem, error) -``` -NewABSystem creates a new system - - - - - -### func (\*ABSystem) [AddToCleanUpQueue](/src/target/system.go?s=7633:7719#L288) -``` go -func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{}) -``` -AddToCleanUpQueue adds a function to the queue - - - - -### func (\*ABSystem) [CheckAll](/src/target/system.go?s=1903:1938#L90) -``` go -func (s *ABSystem) CheckAll() error -``` -CheckAll performs all checks from the Checks struct - - - - -### func (\*ABSystem) [CheckUpdate](/src/target/system.go?s=2231:2278#L104) -``` go -func (s *ABSystem) CheckUpdate() (string, bool) -``` -CheckUpdate checks if there is an update available - - - - -### func (\*ABSystem) [CreateStageFile](/src/target/system.go?s=29265:29307#L1039) -``` go -func (s *ABSystem) CreateStageFile() error -``` - - - -### func (\*ABSystem) [GenerateCrypttab](/src/target/system.go?s=9297:9355#L349) -``` go -func (s *ABSystem) GenerateCrypttab(rootPath string) error -``` -GenerateCrypttab identifies which devices are encrypted and generates -the /etc/crypttab file for the specified root - - - - -### func (\*ABSystem) [GenerateFstab](/src/target/system.go?s=8227:8304#L312) -``` go -func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error -``` -GenerateFstab generates a fstab file for the future root - - - - -### func (\*ABSystem) [GenerateSystemdUnits](/src/target/system.go?s=10698:10782#L398) -``` go -func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error -``` -GenerateSystemdUnits generates systemd units that mount the mutable parts of the system - - - - -### func (\*ABSystem) [LockUpgrade](/src/target/system.go?s=28810:28848#L1017) -``` go -func (s *ABSystem) LockUpgrade() error -``` - - - -### func (\*ABSystem) [MergeUserEtcFiles](/src/target/system.go?s=2546:2634#L111) -``` go -func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error -``` -MergeUserEtcFiles merges user-related files from the new lower etc (/.system/etc) -with the old upper etc, if present, saving the result in the new upper etc. - - - - -### func (\*ABSystem) [RemoveFromCleanUpQueue](/src/target/system.go?s=7888:7942#L297) -``` go -func (s *ABSystem) RemoveFromCleanUpQueue(name string) -``` -RemoveFromCleanUpQueue removes a function from the queue - - - - -### func (\*ABSystem) [RemoveStageFile](/src/target/system.go?s=29505:29547#L1050) -``` go -func (s *ABSystem) RemoveStageFile() error -``` - - - -### func (\*ABSystem) [ResetQueue](/src/target/system.go?s=8102:8133#L307) -``` go -func (s *ABSystem) ResetQueue() -``` -ResetQueue resets the queue - - - - -### func (\*ABSystem) [RunCleanUpQueue](/src/target/system.go?s=4882:4937#L199) -``` go -func (s *ABSystem) RunCleanUpQueue(fnName string) error -``` -RunCleanUpQueue runs the functions in the queue or only the specified one - - - - -### func (\*ABSystem) [RunOperation](/src/target/system.go?s=13435:13501#L477) -``` go -func (s *ABSystem) RunOperation(operation ABSystemOperation) error -``` -RunOperation executes a root-switching operation from the options below: - - - UPGRADE: Upgrades to a new image, if available, - FORCE_UPGRADE: Forces the upgrade operation, even if no new image is available, - APPLY: Applies package changes, but doesn't update the system. - INITRAMFS: Updates the initramfs for the future root, but doesn't update the system. - - - - -### func (\*ABSystem) [SyncUpperEtc](/src/target/system.go?s=3834:3886#L158) -``` go -func (s *ABSystem) SyncUpperEtc(newEtc string) error -``` -SyncUpperEtc syncs the mutable etc directories from /var/lib/abroot/etc - - - - -### func (\*ABSystem) [UnlockUpgrade](/src/target/system.go?s=29036:29076#L1028) -``` go -func (s *ABSystem) UnlockUpgrade() error -``` - - - -### func (\*ABSystem) [UpgradeLockExists](/src/target/system.go?s=28613:28656#L1008) -``` go -func (s *ABSystem) UpgradeLockExists() bool -``` - - - -### func (\*ABSystem) [UserLockRequested](/src/target/system.go?s=28412:28455#L999) -``` go -func (s *ABSystem) UserLockRequested() bool -``` - - - -## type [ABSystemOperation](/src/target/system.go?s=1116:1145#L57) -``` go -type ABSystemOperation string -``` - - - - - - - - - -## type [Checks](/src/target/checks.go?s=616:636#L27) -``` go -type Checks struct{} - -``` -Represents a Checks struct which contains all the checks which can -be performed one by one or all at once using PerformAllChecks() - - - - - - - -### func [NewChecks](/src/target/checks.go?s=679:703#L30) -``` go -func NewChecks() *Checks -``` -NewChecks returns a new Checks struct - - - - - -### func (\*Checks) [CheckCompatibilityFS](/src/target/checks.go?s=1074:1119#L55) -``` go -func (c *Checks) CheckCompatibilityFS() error -``` -CheckCompatibilityFS checks if the filesystem is compatible - - - - -### func (\*Checks) [CheckConnectivity](/src/target/checks.go?s=2252:2294#L93) -``` go -func (c *Checks) CheckConnectivity() error -``` -CheckConnectivity checks if the system is connected to the internet - - - - -### func (\*Checks) [CheckRoot](/src/target/checks.go?s=2598:2632#L107) -``` go -func (c *Checks) CheckRoot() error -``` -CheckRoot checks if the user is root - - - - -### func (\*Checks) [PerformAllChecks](/src/target/checks.go?s=767:808#L35) -``` go -func (c *Checks) PerformAllChecks() error -``` -PerformAllChecks performs all checks - - - - -## type [Children](/src/target/disk-manager.go?s=1735:2089#L61) -``` go -type Children struct { - MountPoint string `json:"mountpoint"` - FsType string `json:"fstype"` - Label string `json:"label"` - Uuid string `json:"uuid"` - LogicalName string `json:"name"` - Size string `json:"size"` - MountOptions string `json:"mountopts"` - Children []Children `json:"children"` -} - -``` -The children a block device or partition may have - - - - - - - - - - -## type [Chroot](/src/target/chroot.go?s=542:621#L25) -``` go -type Chroot struct { - // contains filtered or unexported fields -} - -``` -Chroot is a struct which represents a chroot environment - - - - - - - -### func [NewChroot](/src/target/chroot.go?s=753:833#L40) -``` go -func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error) -``` -NewChroot creates a new chroot environment - - - - - -### func (\*Chroot) [Close](/src/target/chroot.go?s=1759:1789#L78) -``` go -func (c *Chroot) Close() error -``` -Close unmounts all the bind mounts - - - - -### func (\*Chroot) [Execute](/src/target/chroot.go?s=2473:2530#L109) -``` go -func (c *Chroot) Execute(cmd string, args []string) error -``` -Execute runs a command in the chroot environment - - - - -### func (\*Chroot) [ExecuteCmds](/src/target/chroot.go?s=3078:3127#L130) -``` go -func (c *Chroot) ExecuteCmds(cmds []string) error -``` -ExecuteCmds runs a list of commands in the chroot environment, -stops at the first error - - - - -## type [DiskManager](/src/target/disk-manager.go?s=532:557#L27) -``` go -type DiskManager struct{} - -``` -DiskManager represents a disk - - - - - - - -### func [NewDiskManager](/src/target/disk-manager.go?s=2135:2169#L73) -``` go -func NewDiskManager() *DiskManager -``` -NewDiskManager creates a new DiskManager - - - - - -### func (\*DiskManager) [GetPartitionByLabel](/src/target/disk-manager.go?s=2339:2413#L80) -``` go -func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error) -``` -GetPartitionByLabel finds a partition by searching for its label. - -If no partition can be found with the given label, returns error. - - - - -## type [GPUInfo](/src/target/specs.go?s=596:659#L31) -``` go -type GPUInfo struct { - Address string - Description string -} - -``` - - - - - - - - - -## type [Grub](/src/target/grub.go?s=519:579#L26) -``` go -type Grub struct { - PresentRoot string - FutureRoot string -} - -``` - - - - - - -### func [NewGrub](/src/target/grub.go?s=3047:3094#L126) -``` go -func NewGrub(bootPart Partition) (*Grub, error) -``` -NewGrub creates a new Grub instance - - - - - -### func (\*Grub) [IsBootedIntoPresentRoot](/src/target/grub.go?s=4101:4155#L168) -``` go -func (g *Grub) IsBootedIntoPresentRoot() (bool, error) -``` - - - -## type [ImageRecipe](/src/target/image-recipe.go?s=439:552#L21) -``` go -type ImageRecipe struct { - From string - Labels map[string]string - Args map[string]string - Content string -} - -``` - - - - - - -### func [NewImageRecipe](/src/target/image-recipe.go?s=605:717#L29) -``` go -func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe -``` -NewImageRecipe creates a new ImageRecipe struct - - - - - -### func (\*ImageRecipe) [Write](/src/target/image-recipe.go?s=907:953#L41) -``` go -func (c *ImageRecipe) Write(path string) error -``` -Write writes a ImageRecipe to a path - - - - -## type [IntegrityCheck](/src/target/integrity.go?s=498:644#L24) -``` go -type IntegrityCheck struct { - // contains filtered or unexported fields -} - -``` - - - - - - -### func [NewIntegrityCheck](/src/target/integrity.go?s=705:787#L33) -``` go -func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error) -``` -NewIntegrityCheck creates a new IntegrityCheck instance - - - - - -### func (\*IntegrityCheck) [Repair](/src/target/integrity.go?s=3427:3467#L151) -``` go -func (ic *IntegrityCheck) Repair() error -``` -Repair repairs the system - - - - -## type [Manifest](/src/target/registry.go?s=585:662#L30) -``` go -type Manifest struct { - Manifest []byte - Digest string - Layers []string -} - -``` -Manifest struct - - - - - - - - - - -## type [PCSpecs](/src/target/specs.go?s=524:594#L25) -``` go -type PCSpecs struct { - CPU string - GPU []string - Memory string -} - -``` - - - - - - -### func [GetPCSpecs](/src/target/specs.go?s=1838:1863#L93) -``` go -func GetPCSpecs() PCSpecs -``` - - - - -## type [PackageManager](/src/target/packages.go?s=590:650#L31) -``` go -type PackageManager struct { - // contains filtered or unexported fields -} - -``` -PackageManager struct - - - - - - - -### func [NewPackageManager](/src/target/packages.go?s=1250:1301#L60) -``` go -func NewPackageManager(dryRun bool) *PackageManager -``` -NewPackageManager returns a new PackageManager struct - - - - - -### func (\*PackageManager) [Add](/src/target/packages.go?s=2539:2585#L117) -``` go -func (p *PackageManager) Add(pkg string) error -``` -Add adds a package to the packages.add file - - - - -### func (\*PackageManager) [ClearUnstagedPackages](/src/target/packages.go?s=6419:6473#L252) -``` go -func (p *PackageManager) ClearUnstagedPackages() error -``` -ClearUnstagedPackages removes all packages from the unstaged list - - - - -### func (\*PackageManager) [ExistsInRepo](/src/target/packages.go?s=13359:13414#L490) -``` go -func (p *PackageManager) ExistsInRepo(pkg string) error -``` - - - -### func (\*PackageManager) [GetAddPackages](/src/target/packages.go?s=4767:4826#L200) -``` go -func (p *PackageManager) GetAddPackages() ([]string, error) -``` -GetAddPackages returns the packages in the packages.add file - - - - -### func (\*PackageManager) [GetAddPackagesString](/src/target/packages.go?s=6672:6745#L258) -``` go -func (p *PackageManager) GetAddPackagesString(sep string) (string, error) -``` -GetAddPackages returns the packages in the packages.add file as string - - - - -### func (\*PackageManager) [GetFinalCmd](/src/target/packages.go?s=11425:11497#L432) -``` go -func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string -``` - - - -### func (\*PackageManager) [GetRemovePackages](/src/target/packages.go?s=5000:5062#L206) -``` go -func (p *PackageManager) GetRemovePackages() ([]string, error) -``` -GetRemovePackages returns the packages in the packages.remove file - - - - -### func (\*PackageManager) [GetRemovePackagesString](/src/target/packages.go?s=7137:7213#L271) -``` go -func (p *PackageManager) GetRemovePackagesString(sep string) (string, error) -``` -GetRemovePackages returns the packages in the packages.remove file as string - - - - -### func (\*PackageManager) [GetUnstagedPackages](/src/target/packages.go?s=5250:5323#L212) -``` go -func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error) -``` -GetUnstagedPackages returns the package changes that are yet to be applied - - - - -### func (\*PackageManager) [GetUnstagedPackagesPlain](/src/target/packages.go?s=5917:5986#L235) -``` go -func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error) -``` -GetUnstagedPackagesPlain returns the package changes that are yet to be applied -as strings - - - - -### func (\*PackageManager) [Remove](/src/target/packages.go?s=3654:3703#L163) -``` go -func (p *PackageManager) Remove(pkg string) error -``` -Remove removes a package from the packages.add file - - - - -## type [Partition](/src/target/disk-manager.go?s=641:1680#L30) -``` go -type Partition struct { - Label string - MountPoint string - MountOptions string - Uuid string - FsType string - - // If standard partition, Device will be the partition's name (e.g. sda1, nvme0n1p1). - // If LUKS-encrypted or LVM volume, Device will be the name in device-mapper. - Device string - - // If the partition is LUKS-encrypted or an LVM volume, the logical volume - // opened in /dev/mapper will be a child of the physical partition in /dev. - // Otherwise, the partition will be a direct child of the block device, and - // Parent will be nil. - // - // The same logic applies for encrypted LVM volumes. When this is the case, - // the filesystem hirearchy is as follows: - // - // NAME FSTYPE - // -- sda1 LVM2_member - // |-- myVG-myLV crypto_LUKS - // |-- luks-volume btrfs - // - // In this case, the parent of "luks-volume" is "myVG-myLV", which, - // in turn, has "sda1" as parent. Since "sda1" is a physical partition, - // its parent is nil. - Parent *Partition -} - -``` -Partition represents either a standard partition or a device-mapper partition. - - - - - - - - - - -### func (\*Partition) [IsDevMapper](/src/target/disk-manager.go?s=6054:6092#L211) -``` go -func (p *Partition) IsDevMapper() bool -``` -Returns whether the partition is a device-mapper virtual partition - - - - -### func (\*Partition) [IsEncrypted](/src/target/disk-manager.go?s=6180:6218#L216) -``` go -func (p *Partition) IsEncrypted() bool -``` -IsEncrypted returns whether the partition is encrypted - - - - -### func (\*Partition) [Mount](/src/target/disk-manager.go?s=4757:4808#L161) -``` go -func (p *Partition) Mount(destination string) error -``` -Mount mounts a partition to a directory - - - - -### func (\*Partition) [Unmount](/src/target/disk-manager.go?s=5459:5494#L189) -``` go -func (p *Partition) Unmount() error -``` -Unmount unmounts a partition - - - - -## type [QueuedFunction](/src/target/system.go?s=706:791#L37) -``` go -type QueuedFunction struct { - Name string - Values []interface{} - Priority int -} - -``` - - - - - - - - - -## type [Registry](/src/target/registry.go?s=528:564#L25) -``` go -type Registry struct { - API string -} - -``` -Registry struct - - - - - - - -### func [NewRegistry](/src/target/registry.go?s=709:737#L37) -``` go -func NewRegistry() *Registry -``` -NewRegistry returns a new Registry struct - - - - - -### func (\*Registry) [GetManifest](/src/target/registry.go?s=2507:2570#L107) -``` go -func (r *Registry) GetManifest(token string) (*Manifest, error) -``` -GetManifest returns the manifest of the image - - - - -### func (\*Registry) [HasUpdate](/src/target/registry.go?s=977:1035#L45) -``` go -func (r *Registry) HasUpdate(digest string) (string, bool) -``` -HasUpdate checks if the image/tag from the registry has a different digest - - - - -## type [UnstagedPackage](/src/target/packages.go?s=1139:1191#L55) -``` go -type UnstagedPackage struct { - Name, Status string -} - -``` -An unstaged package is a package that is waiting to be applied -to the next root. - -Every time a `pkg apply` or `upgrade` operation -is executed, all unstaged packages are consumed and added/removed -in the next root. - - - - - - - - - - - - - - -- - - -Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) diff --git a/docs/settings.md b/docs/settings.md index 88f90b79..77a55e60 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -1,7 +1,7 @@ -# core -`import "github.com/vanilla-os/abroot/core"` +# settings +`import "github.com/vanilla-os/abroot/settings"` * [Overview](#pkg-overview) * [Index](#pkg-index) @@ -11,1380 +11,69 @@ ## Index -* [Constants](#pkg-constants) * [Variables](#pkg-variables) -* [func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error](#AtomicRsync) -* [func AtomicSwap(src, dst string) error](#AtomicSwap) -* [func BaseImagePackageDiff(currentDigest, newDigest string) (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#BaseImagePackageDiff) -* [func CopyFile(source, dest string) error](#CopyFile) -* [func DeleteImageForRoot(root string) error](#DeleteImageForRoot) -* [func DiffFiles(sourceFile, destFile string) ([]byte, error)](#DiffFiles) -* [func FindImageWithLabel(key, value string) (string, error)](#FindImageWithLabel) -* [func GetLogFile() *os.File](#GetLogFile) -* [func GetRepoContentsForPkg(pkg string) (map[string]any, error)](#GetRepoContentsForPkg) -* [func GetToken() (string, error)](#GetToken) -* [func IsVerbose() bool](#IsVerbose) -* [func KargsBackup() error](#KargsBackup) -* [func KargsEdit() (bool, error)](#KargsEdit) -* [func KargsFormat(content string) (string, error)](#KargsFormat) -* [func KargsRead() (string, error)](#KargsRead) -* [func KargsWrite(content string) error](#KargsWrite) -* [func LogToFile(msg string, args ...interface{}) error](#LogToFile) -* [func MergeDiff(firstFile, secondFile, destination string) error](#MergeDiff) -* [func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error](#OciExportRootFs) -* [func OverlayPackageDiff() (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#OverlayPackageDiff) -* [func PrintVerbose(msg string, args ...interface{})](#PrintVerbose) -* [func PrintVerboseNoLog(msg string, args ...interface{})](#PrintVerboseNoLog) -* [func RetrieveImageForRoot(root string) (string, error)](#RetrieveImageForRoot) -* [func RootCheck(display bool) bool](#RootCheck) -* [func WriteDiff(destFile string, diffLines []byte) error](#WriteDiff) -* [type ABImage](#ABImage) - * [func NewABImage(digest string, image string) (*ABImage, error)](#NewABImage) - * [func NewABImageFromRoot() (*ABImage, error)](#NewABImageFromRoot) - * [func (a *ABImage) WriteTo(dest string, suffix string) error](#ABImage.WriteTo) -* [type ABRootManager](#ABRootManager) - * [func NewABRootManager() *ABRootManager](#NewABRootManager) - * [func (a *ABRootManager) GetBoot() (partition Partition, err error)](#ABRootManager.GetBoot) - * [func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error)](#ABRootManager.GetFuture) - * [func (a *ABRootManager) GetInit() (partition Partition, err error)](#ABRootManager.GetInit) - * [func (a *ABRootManager) GetOther() (partition ABRootPartition, err error)](#ABRootManager.GetOther) - * [func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error)](#ABRootManager.GetPartition) - * [func (a *ABRootManager) GetPartitions() error](#ABRootManager.GetPartitions) - * [func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error)](#ABRootManager.GetPresent) - * [func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error)](#ABRootManager.IdentifyPartition) - * [func (a *ABRootManager) IsCurrent(partition Partition) bool](#ABRootManager.IsCurrent) -* [type ABRootPartition](#ABRootPartition) -* [type ABSystem](#ABSystem) - * [func NewABSystem() (*ABSystem, error)](#NewABSystem) - * [func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{})](#ABSystem.AddToCleanUpQueue) - * [func (s *ABSystem) CheckAll() error](#ABSystem.CheckAll) - * [func (s *ABSystem) CheckUpdate() (string, bool)](#ABSystem.CheckUpdate) - * [func (s *ABSystem) CreateStageFile() error](#ABSystem.CreateStageFile) - * [func (s *ABSystem) GenerateCrypttab(rootPath string) error](#ABSystem.GenerateCrypttab) - * [func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error](#ABSystem.GenerateFstab) - * [func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error](#ABSystem.GenerateSystemdUnits) - * [func (s *ABSystem) LockUpgrade() error](#ABSystem.LockUpgrade) - * [func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error](#ABSystem.MergeUserEtcFiles) - * [func (s *ABSystem) RemoveFromCleanUpQueue(name string)](#ABSystem.RemoveFromCleanUpQueue) - * [func (s *ABSystem) RemoveStageFile() error](#ABSystem.RemoveStageFile) - * [func (s *ABSystem) ResetQueue()](#ABSystem.ResetQueue) - * [func (s *ABSystem) RunCleanUpQueue(fnName string) error](#ABSystem.RunCleanUpQueue) - * [func (s *ABSystem) RunOperation(operation ABSystemOperation) error](#ABSystem.RunOperation) - * [func (s *ABSystem) SyncUpperEtc(newEtc string) error](#ABSystem.SyncUpperEtc) - * [func (s *ABSystem) UnlockUpgrade() error](#ABSystem.UnlockUpgrade) - * [func (s *ABSystem) UpgradeLockExists() bool](#ABSystem.UpgradeLockExists) - * [func (s *ABSystem) UserLockRequested() bool](#ABSystem.UserLockRequested) -* [type ABSystemOperation](#ABSystemOperation) -* [type Checks](#Checks) - * [func NewChecks() *Checks](#NewChecks) - * [func (c *Checks) CheckCompatibilityFS() error](#Checks.CheckCompatibilityFS) - * [func (c *Checks) CheckConnectivity() error](#Checks.CheckConnectivity) - * [func (c *Checks) CheckRoot() error](#Checks.CheckRoot) - * [func (c *Checks) PerformAllChecks() error](#Checks.PerformAllChecks) -* [type Children](#Children) -* [type Chroot](#Chroot) - * [func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error)](#NewChroot) - * [func (c *Chroot) Close() error](#Chroot.Close) - * [func (c *Chroot) Execute(cmd string, args []string) error](#Chroot.Execute) - * [func (c *Chroot) ExecuteCmds(cmds []string) error](#Chroot.ExecuteCmds) -* [type DiskManager](#DiskManager) - * [func NewDiskManager() *DiskManager](#NewDiskManager) - * [func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error)](#DiskManager.GetPartitionByLabel) -* [type GPUInfo](#GPUInfo) -* [type Grub](#Grub) - * [func NewGrub(bootPart Partition) (*Grub, error)](#NewGrub) - * [func (g *Grub) IsBootedIntoPresentRoot() (bool, error)](#Grub.IsBootedIntoPresentRoot) -* [type ImageRecipe](#ImageRecipe) - * [func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe](#NewImageRecipe) - * [func (c *ImageRecipe) Write(path string) error](#ImageRecipe.Write) -* [type IntegrityCheck](#IntegrityCheck) - * [func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error)](#NewIntegrityCheck) - * [func (ic *IntegrityCheck) Repair() error](#IntegrityCheck.Repair) -* [type Manifest](#Manifest) -* [type PCSpecs](#PCSpecs) - * [func GetPCSpecs() PCSpecs](#GetPCSpecs) -* [type PackageManager](#PackageManager) - * [func NewPackageManager(dryRun bool) *PackageManager](#NewPackageManager) - * [func (p *PackageManager) Add(pkg string) error](#PackageManager.Add) - * [func (p *PackageManager) ClearUnstagedPackages() error](#PackageManager.ClearUnstagedPackages) - * [func (p *PackageManager) ExistsInRepo(pkg string) error](#PackageManager.ExistsInRepo) - * [func (p *PackageManager) GetAddPackages() ([]string, error)](#PackageManager.GetAddPackages) - * [func (p *PackageManager) GetAddPackagesString(sep string) (string, error)](#PackageManager.GetAddPackagesString) - * [func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string](#PackageManager.GetFinalCmd) - * [func (p *PackageManager) GetRemovePackages() ([]string, error)](#PackageManager.GetRemovePackages) - * [func (p *PackageManager) GetRemovePackagesString(sep string) (string, error)](#PackageManager.GetRemovePackagesString) - * [func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error)](#PackageManager.GetUnstagedPackages) - * [func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error)](#PackageManager.GetUnstagedPackagesPlain) - * [func (p *PackageManager) Remove(pkg string) error](#PackageManager.Remove) -* [type Partition](#Partition) - * [func (p *Partition) IsDevMapper() bool](#Partition.IsDevMapper) - * [func (p *Partition) IsEncrypted() bool](#Partition.IsEncrypted) - * [func (p *Partition) Mount(destination string) error](#Partition.Mount) - * [func (p *Partition) Unmount() error](#Partition.Unmount) -* [type QueuedFunction](#QueuedFunction) -* [type Registry](#Registry) - * [func NewRegistry() *Registry](#NewRegistry) - * [func (r *Registry) GetManifest(token string) (*Manifest, error)](#Registry.GetManifest) - * [func (r *Registry) HasUpdate(digest string) (string, bool)](#Registry.HasUpdate) -* [type UnstagedPackage](#UnstagedPackage) +* [type Config](#Config) #### Package files -[atomic-io.go](/src/github.com/vanilla-os/abroot/core/atomic-io.go) [checks.go](/src/github.com/vanilla-os/abroot/core/checks.go) [chroot.go](/src/github.com/vanilla-os/abroot/core/chroot.go) [diff.go](/src/github.com/vanilla-os/abroot/core/diff.go) [disk-manager.go](/src/github.com/vanilla-os/abroot/core/disk-manager.go) [grub.go](/src/github.com/vanilla-os/abroot/core/grub.go) [image-recipe.go](/src/github.com/vanilla-os/abroot/core/image-recipe.go) [image.go](/src/github.com/vanilla-os/abroot/core/image.go) [integrity.go](/src/github.com/vanilla-os/abroot/core/integrity.go) [kargs.go](/src/github.com/vanilla-os/abroot/core/kargs.go) [logging.go](/src/github.com/vanilla-os/abroot/core/logging.go) [oci.go](/src/github.com/vanilla-os/abroot/core/oci.go) [package-diff.go](/src/github.com/vanilla-os/abroot/core/package-diff.go) [packages.go](/src/github.com/vanilla-os/abroot/core/packages.go) [registry.go](/src/github.com/vanilla-os/abroot/core/registry.go) [root.go](/src/github.com/vanilla-os/abroot/core/root.go) [rsync.go](/src/github.com/vanilla-os/abroot/core/rsync.go) [specs.go](/src/github.com/vanilla-os/abroot/core/specs.go) [system.go](/src/github.com/vanilla-os/abroot/core/system.go) [utils.go](/src/github.com/vanilla-os/abroot/core/utils.go) +[config.go](/src/github.com/vanilla-os/abroot/settings/config.go) -## Constants -``` go -const ( - DefaultKargs = "quiet splash bgrt_disable $vt_handoff" - KargsTmpFile = "/tmp/kargs-temp" -) -``` -``` go -const ( - PackagesBaseDir = "/etc/abroot" - DryRunPackagesBaseDir = "/tmp/abroot" - PackagesAddFile = "packages.add" - PackagesRemoveFile = "packages.remove" - PackagesUnstagedFile = "packages.unstaged" -) -``` -``` go -const ( - ADD = "+" - REMOVE = "-" -) -``` -``` go -const ( - UPGRADE = "upgrade" - FORCE_UPGRADE = "force-upgrade" - DRY_RUN_UPGRADE = "dry-run-upgrade" - APPLY = "package-apply" - DRY_RUN_APPLY = "dry-run-package-apply" - INITRAMFS = "initramfs" - DRY_RUN_INITRAMFS = "dry-run-initramfs" -) -``` -``` go -const ( - MountUnitDir = "/etc/systemd/system" -) -``` ## Variables ``` go -var ( - ErrNoUpdate error = errors.New("no update available") -) -``` -``` go -var KargsPath = "/etc/abroot/kargs" -``` -``` go -var ReservedMounts = []string{ - "/dev", - "/dev/pts", - "/proc", - "/run", - "/sys", -} -``` - - -## func [AtomicRsync](/src/target/rsync.go?s=3049:3169#L120) -``` go -func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error -``` -AtomicRsync executes the rsync command in an atomic-like manner. -It does so by dry-running the rsync, and if it succeeds, it runs -the rsync again performing changes. -If the keepUnwanted option -is set to true, it will omit the --delete option, so that the already -existing and unwanted files will not be deleted. -To ensure the changes are applied atomically, we rsync on a _new directory first, -and use atomicSwap to replace the _new with the dst directory. - - - -## func [AtomicSwap](/src/target/atomic-io.go?s=686:724#L26) -``` go -func AtomicSwap(src, dst string) error -``` -atomicSwap allows swapping 2 files or directories in-place and atomically, -using the renameat2 syscall. This should be used instead of os.Rename, -which is not atomic at all. - - - -## func [BaseImagePackageDiff](/src/target/package-diff.go?s=732:864#L30) -``` go -func BaseImagePackageDiff(currentDigest, newDigest string) ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -BaseImagePackageDiff retrieves the added, removed, upgraded and downgraded -base packages (the ones bundled with the image). - - - -## func [CopyFile](/src/target/utils.go?s=1376:1416#L74) -``` go -func CopyFile(source, dest string) error -``` -CopyFile copies a file from source to dest - - - -## func [DeleteImageForRoot](/src/target/oci.go?s=4047:4089#L164) -``` go -func DeleteImageForRoot(root string) error -``` -DeleteImageForRoot deletes the image created for the provided root ("vos-a"|"vos-b") - - - -## func [DiffFiles](/src/target/diff.go?s=1442:1501#L57) -``` go -func DiffFiles(sourceFile, destFile string) ([]byte, error) -``` -DiffFiles returns the diff lines between source and dest files. - - - -## func [FindImageWithLabel](/src/target/oci.go?s=2711:2769#L114) -``` go -func FindImageWithLabel(key, value string) (string, error) -``` -FindImageWithLabel returns the name of the first image containinig the provided key-value pair -or an empty string if none was found - - - -## func [GetLogFile](/src/target/logging.go?s=1980:2006#L98) -``` go -func GetLogFile() *os.File -``` - - -## func [GetRepoContentsForPkg](/src/target/packages.go?s=14199:14261#L520) -``` go -func GetRepoContentsForPkg(pkg string) (map[string]any, error) -``` -GetRepoContentsForPkg retrieves package information from the repository API - - - -## func [GetToken](/src/target/registry.go?s=1685:1716#L70) -``` go -func GetToken() (string, error) -``` -GetToken generates a token using the provided tokenURL and returns it - - - -## func [IsVerbose](/src/target/logging.go?s=1338:1359#L64) -``` go -func IsVerbose() bool -``` - - -## func [KargsBackup](/src/target/kargs.go?s=1884:1908#L84) -``` go -func KargsBackup() error -``` -KargsBackup makes a backup of the current kargs file - - - -## func [KargsEdit](/src/target/kargs.go?s=3643:3673#L159) -``` go -func KargsEdit() (bool, error) -``` -KargsEdit copies the kargs file to a temporary file and opens it in the -user's preferred editor by querying the $EDITOR environment variable. -Once closed, its contents are written back to the main kargs file. -This function returns a boolean parameter indicating whether any changes -were made to the kargs file. - - - -## func [KargsFormat](/src/target/kargs.go?s=2768:2816#L123) -``` go -func KargsFormat(content string) (string, error) -``` -KargsFormat formats the contents of the kargs file, ensuring that -there are no duplicate entries, multiple spaces or trailing newline - - - -## func [KargsRead](/src/target/kargs.go?s=2275:2307#L103) -``` go -func KargsRead() (string, error) -``` -KargsRead reads the content of the kargs file - - - -## func [KargsWrite](/src/target/kargs.go?s=1243:1280#L53) -``` go -func KargsWrite(content string) error -``` -KargsWrite makes a backup of the current kargs file and then -writes the new content to it - - - -## func [LogToFile](/src/target/logging.go?s=1739:1792#L85) -``` go -func LogToFile(msg string, args ...interface{}) error -``` - - -## func [MergeDiff](/src/target/diff.go?s=539:602#L23) -``` go -func MergeDiff(firstFile, secondFile, destination string) error -``` -MergeDiff merges the diff lines between the first and second files into destination - - - -## func [OciExportRootFs](/src/target/oci.go?s=691:796#L29) -``` go -func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error -``` -OciExportRootFs generates a rootfs from a image recipe file - - - -## func [OverlayPackageDiff](/src/target/package-diff.go?s=2565:2664#L88) -``` go -func OverlayPackageDiff() ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -OverlayPackageDiff retrieves the added, removed, upgraded and downgraded -overlay packages (the ones added manually via `abroot pkg add`). - - - -## func [PrintVerbose](/src/target/logging.go?s=1464:1514#L70) -``` go -func PrintVerbose(msg string, args ...interface{}) -``` - - -## func [PrintVerboseNoLog](/src/target/logging.go?s=1604:1659#L78) -``` go -func PrintVerboseNoLog(msg string, args ...interface{}) -``` - - -## func [RetrieveImageForRoot](/src/target/oci.go?s=3686:3740#L151) -``` go -func RetrieveImageForRoot(root string) (string, error) -``` -RetrieveImageForRoot retrieves the image created for the provided root ("vos-a"|"vos-b") - - - -## func [RootCheck](/src/target/utils.go?s=690:723#L39) -``` go -func RootCheck(display bool) bool -``` - - -## func [WriteDiff](/src/target/diff.go?s=2023:2078#L81) -``` go -func WriteDiff(destFile string, diffLines []byte) error -``` -WriteDiff applies the diff lines to the destination file. - - - - -## type [ABImage](/src/target/image.go?s=499:635#L25) -``` go -type ABImage struct { - Digest string `json:"digest"` - Timestamp time.Time `json:"timestamp"` - Image string `json:"image"` -} - -``` -ABImage struct - - - - - - - -### func [NewABImage](/src/target/image.go?s=680:742#L32) -``` go -func NewABImage(digest string, image string) (*ABImage, error) -``` -NewABImage returns a new ABImage struct - - -### func [NewABImageFromRoot](/src/target/image.go?s=987:1030#L45) -``` go -func NewABImageFromRoot() (*ABImage, error) -``` -NewABImageFromRoot returns the current ABImage from /abimage.abr - - - - - -### func (\*ABImage) [WriteTo](/src/target/image.go?s=1501:1560#L66) -``` go -func (a *ABImage) WriteTo(dest string, suffix string) error -``` -WriteTo writes the json to a dest path - - - - -## type [ABRootManager](/src/target/root.go?s=525:610#L23) -``` go -type ABRootManager struct { - Partitions []ABRootPartition - VarPartition Partition -} - -``` -ABRootManager represents the ABRoot manager - - - - - - - -### func [NewABRootManager](/src/target/root.go?s=1002:1040#L41) -``` go -func NewABRootManager() *ABRootManager -``` -NewABRootManager creates a new ABRootManager - - - - - -### func (\*ABRootManager) [GetBoot](/src/target/root.go?s=5676:5742#L194) -``` go -func (a *ABRootManager) GetBoot() (partition Partition, err error) -``` -GetBoot gets the boot partition from the current device - - - - -### func (\*ABRootManager) [GetFuture](/src/target/root.go?s=4037:4111#L143) -``` go -func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error) -``` -GetFuture gets the future partition - - - - -### func (\*ABRootManager) [GetInit](/src/target/root.go?s=6201:6267#L211) -``` go -func (a *ABRootManager) GetInit() (partition Partition, err error) -``` -GetInit gets the init volume when using LVM Thin-Provisioning - - - - -### func (\*ABRootManager) [GetOther](/src/target/root.go?s=4539:4612#L159) -``` go -func (a *ABRootManager) GetOther() (partition ABRootPartition, err error) -``` -GetOther gets the other partition - - - - -### func (\*ABRootManager) [GetPartition](/src/target/root.go?s=5152:5241#L178) -``` go -func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error) -``` -GetPartition gets a partition by label - - - - -### func (\*ABRootManager) [GetPartitions](/src/target/root.go?s=1212:1257#L51) -``` go -func (a *ABRootManager) GetPartitions() error -``` -GetPartitions gets the root partitions from the current device - - - - -### func (\*ABRootManager) [GetPresent](/src/target/root.go?s=3526:3601#L127) -``` go -func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error) -``` -GetPresent gets the present partition - - - - -### func (\*ABRootManager) [IdentifyPartition](/src/target/root.go?s=2854:2949#L108) -``` go -func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error) -``` -IdentifyPartition identifies a partition - - - - -### func (\*ABRootManager) [IsCurrent](/src/target/root.go?s=2494:2553#L95) -``` go -func (a *ABRootManager) IsCurrent(partition Partition) bool +var CnfFileUsed string ``` -IsCurrent checks if a partition is the current one - -## type [ABRootPartition](/src/target/root.go?s=662:952#L29) +## type [Config](/src/target/config.go?s=470:1583#L23) ``` go -type ABRootPartition struct { - Label string // Matches `partLabelA` and `partLabelB` settings entries - IdentifiedAs string // Either `present` or `future` - Partition Partition - MountPoint string - MountOptions string - Uuid string - FsType string - Current bool -} - -``` -ABRootPartition represents an ABRoot partition - - - +type Config struct { + // Common + AutoRepair bool `json:"autoRepair"` + MaxParallelDownloads uint `json:"maxParallelDownloads"` + // Registry + Registry string `json:"registry"` + RegistryAPIVersion string `json:"registryAPIVersion"` + RegistryService string `json:"registryService"` + Name string `json:"name"` + Tag string `json:"tag"` + // Package manager + IPkgMngPre string `json:"iPkgMngPre"` + IPkgMngPost string `json:"iPkgMngPost"` + IPkgMngAdd string `json:"iPkgMngAdd"` + IPkgMngRm string `json:"iPkgMngRm"` + IPkgMngApi string `json:"iPkgMngApi"` + // Package diff API (Differ) + DifferURL string `json:"differURL"` + // Partitions + PartLabelVar string `json:"partLabelVar"` + PartLabelA string `json:"partLabelA"` + PartLabelB string `json:"partLabelB"` + PartLabelBoot string `json:"partLabelBoot"` + PartLabelEfi string `json:"partLabelEfivar"` + // Structure + ThinProvisioning bool `json:"thinProvisioning"` + ThinInitVolume string `json:"thinInitVolume"` + // Lib + LibPathStates string `json:"libPathStates"` -## type [ABSystem](/src/target/system.go?s=598:704#L30) -``` go -type ABSystem struct { - Checks *Checks - RootM *ABRootManager - Registry *Registry - CurImage *ABImage + // Virtual + FullImageName string } ``` -ABSystem represents the system - - - - - - - -### func [NewABSystem](/src/target/system.go?s=1496:1533#L68) -``` go -func NewABSystem() (*ABSystem, error) -``` -NewABSystem creates a new system - - - - -### func (\*ABSystem) [AddToCleanUpQueue](/src/target/system.go?s=7633:7719#L288) ``` go -func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{}) +var Cnf *Config ``` -AddToCleanUpQueue adds a function to the queue - - - - -### func (\*ABSystem) [CheckAll](/src/target/system.go?s=1903:1938#L90) -``` go -func (s *ABSystem) CheckAll() error -``` -CheckAll performs all checks from the Checks struct - - - - -### func (\*ABSystem) [CheckUpdate](/src/target/system.go?s=2231:2278#L104) -``` go -func (s *ABSystem) CheckUpdate() (string, bool) -``` -CheckUpdate checks if there is an update available - - - - -### func (\*ABSystem) [CreateStageFile](/src/target/system.go?s=29265:29307#L1039) -``` go -func (s *ABSystem) CreateStageFile() error -``` - - - -### func (\*ABSystem) [GenerateCrypttab](/src/target/system.go?s=9297:9355#L349) -``` go -func (s *ABSystem) GenerateCrypttab(rootPath string) error -``` -GenerateCrypttab identifies which devices are encrypted and generates -the /etc/crypttab file for the specified root - - - - -### func (\*ABSystem) [GenerateFstab](/src/target/system.go?s=8227:8304#L312) -``` go -func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error -``` -GenerateFstab generates a fstab file for the future root - - - - -### func (\*ABSystem) [GenerateSystemdUnits](/src/target/system.go?s=10698:10782#L398) -``` go -func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error -``` -GenerateSystemdUnits generates systemd units that mount the mutable parts of the system - - - - -### func (\*ABSystem) [LockUpgrade](/src/target/system.go?s=28810:28848#L1017) -``` go -func (s *ABSystem) LockUpgrade() error -``` - - - -### func (\*ABSystem) [MergeUserEtcFiles](/src/target/system.go?s=2546:2634#L111) -``` go -func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error -``` -MergeUserEtcFiles merges user-related files from the new lower etc (/.system/etc) -with the old upper etc, if present, saving the result in the new upper etc. - - - - -### func (\*ABSystem) [RemoveFromCleanUpQueue](/src/target/system.go?s=7888:7942#L297) -``` go -func (s *ABSystem) RemoveFromCleanUpQueue(name string) -``` -RemoveFromCleanUpQueue removes a function from the queue - - - - -### func (\*ABSystem) [RemoveStageFile](/src/target/system.go?s=29505:29547#L1050) -``` go -func (s *ABSystem) RemoveStageFile() error -``` - - - -### func (\*ABSystem) [ResetQueue](/src/target/system.go?s=8102:8133#L307) -``` go -func (s *ABSystem) ResetQueue() -``` -ResetQueue resets the queue - - - - -### func (\*ABSystem) [RunCleanUpQueue](/src/target/system.go?s=4882:4937#L199) -``` go -func (s *ABSystem) RunCleanUpQueue(fnName string) error -``` -RunCleanUpQueue runs the functions in the queue or only the specified one - - - - -### func (\*ABSystem) [RunOperation](/src/target/system.go?s=13435:13501#L477) -``` go -func (s *ABSystem) RunOperation(operation ABSystemOperation) error -``` -RunOperation executes a root-switching operation from the options below: - - - UPGRADE: Upgrades to a new image, if available, - FORCE_UPGRADE: Forces the upgrade operation, even if no new image is available, - APPLY: Applies package changes, but doesn't update the system. - INITRAMFS: Updates the initramfs for the future root, but doesn't update the system. - - - - -### func (\*ABSystem) [SyncUpperEtc](/src/target/system.go?s=3834:3886#L158) -``` go -func (s *ABSystem) SyncUpperEtc(newEtc string) error -``` -SyncUpperEtc syncs the mutable etc directories from /var/lib/abroot/etc - - - - -### func (\*ABSystem) [UnlockUpgrade](/src/target/system.go?s=29036:29076#L1028) -``` go -func (s *ABSystem) UnlockUpgrade() error -``` - - - -### func (\*ABSystem) [UpgradeLockExists](/src/target/system.go?s=28613:28656#L1008) -``` go -func (s *ABSystem) UpgradeLockExists() bool -``` - - - -### func (\*ABSystem) [UserLockRequested](/src/target/system.go?s=28412:28455#L999) -``` go -func (s *ABSystem) UserLockRequested() bool -``` - - - -## type [ABSystemOperation](/src/target/system.go?s=1116:1145#L57) -``` go -type ABSystemOperation string -``` - - - - - - - - - -## type [Checks](/src/target/checks.go?s=616:636#L27) -``` go -type Checks struct{} - -``` -Represents a Checks struct which contains all the checks which can -be performed one by one or all at once using PerformAllChecks() - - - - - - - -### func [NewChecks](/src/target/checks.go?s=679:703#L30) -``` go -func NewChecks() *Checks -``` -NewChecks returns a new Checks struct - - - - - -### func (\*Checks) [CheckCompatibilityFS](/src/target/checks.go?s=1074:1119#L55) -``` go -func (c *Checks) CheckCompatibilityFS() error -``` -CheckCompatibilityFS checks if the filesystem is compatible - - - - -### func (\*Checks) [CheckConnectivity](/src/target/checks.go?s=2252:2294#L93) -``` go -func (c *Checks) CheckConnectivity() error -``` -CheckConnectivity checks if the system is connected to the internet - - - - -### func (\*Checks) [CheckRoot](/src/target/checks.go?s=2598:2632#L107) -``` go -func (c *Checks) CheckRoot() error -``` -CheckRoot checks if the user is root - - - - -### func (\*Checks) [PerformAllChecks](/src/target/checks.go?s=767:808#L35) -``` go -func (c *Checks) PerformAllChecks() error -``` -PerformAllChecks performs all checks - - - - -## type [Children](/src/target/disk-manager.go?s=1735:2089#L61) -``` go -type Children struct { - MountPoint string `json:"mountpoint"` - FsType string `json:"fstype"` - Label string `json:"label"` - Uuid string `json:"uuid"` - LogicalName string `json:"name"` - Size string `json:"size"` - MountOptions string `json:"mountopts"` - Children []Children `json:"children"` -} - -``` -The children a block device or partition may have - - - - - - - - - - -## type [Chroot](/src/target/chroot.go?s=542:621#L25) -``` go -type Chroot struct { - // contains filtered or unexported fields -} - -``` -Chroot is a struct which represents a chroot environment - - - - - - - -### func [NewChroot](/src/target/chroot.go?s=753:833#L40) -``` go -func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error) -``` -NewChroot creates a new chroot environment - - - - - -### func (\*Chroot) [Close](/src/target/chroot.go?s=1759:1789#L78) -``` go -func (c *Chroot) Close() error -``` -Close unmounts all the bind mounts - - - - -### func (\*Chroot) [Execute](/src/target/chroot.go?s=2473:2530#L109) -``` go -func (c *Chroot) Execute(cmd string, args []string) error -``` -Execute runs a command in the chroot environment - - - - -### func (\*Chroot) [ExecuteCmds](/src/target/chroot.go?s=3078:3127#L130) -``` go -func (c *Chroot) ExecuteCmds(cmds []string) error -``` -ExecuteCmds runs a list of commands in the chroot environment, -stops at the first error - - - - -## type [DiskManager](/src/target/disk-manager.go?s=532:557#L27) -``` go -type DiskManager struct{} - -``` -DiskManager represents a disk - - - - - - - -### func [NewDiskManager](/src/target/disk-manager.go?s=2135:2169#L73) -``` go -func NewDiskManager() *DiskManager -``` -NewDiskManager creates a new DiskManager - - - - - -### func (\*DiskManager) [GetPartitionByLabel](/src/target/disk-manager.go?s=2339:2413#L80) -``` go -func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error) -``` -GetPartitionByLabel finds a partition by searching for its label. - -If no partition can be found with the given label, returns error. - - - - -## type [GPUInfo](/src/target/specs.go?s=596:659#L31) -``` go -type GPUInfo struct { - Address string - Description string -} - -``` - - - - - - - - - -## type [Grub](/src/target/grub.go?s=519:579#L26) -``` go -type Grub struct { - PresentRoot string - FutureRoot string -} - -``` - - - - - - -### func [NewGrub](/src/target/grub.go?s=3047:3094#L126) -``` go -func NewGrub(bootPart Partition) (*Grub, error) -``` -NewGrub creates a new Grub instance - - - - - -### func (\*Grub) [IsBootedIntoPresentRoot](/src/target/grub.go?s=4101:4155#L168) -``` go -func (g *Grub) IsBootedIntoPresentRoot() (bool, error) -``` - - - -## type [ImageRecipe](/src/target/image-recipe.go?s=439:552#L21) -``` go -type ImageRecipe struct { - From string - Labels map[string]string - Args map[string]string - Content string -} - -``` - - - - - - -### func [NewImageRecipe](/src/target/image-recipe.go?s=605:717#L29) -``` go -func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe -``` -NewImageRecipe creates a new ImageRecipe struct - - - - - -### func (\*ImageRecipe) [Write](/src/target/image-recipe.go?s=907:953#L41) -``` go -func (c *ImageRecipe) Write(path string) error -``` -Write writes a ImageRecipe to a path - - - - -## type [IntegrityCheck](/src/target/integrity.go?s=498:644#L24) -``` go -type IntegrityCheck struct { - // contains filtered or unexported fields -} - -``` - - - - - - -### func [NewIntegrityCheck](/src/target/integrity.go?s=705:787#L33) -``` go -func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error) -``` -NewIntegrityCheck creates a new IntegrityCheck instance - - - - - -### func (\*IntegrityCheck) [Repair](/src/target/integrity.go?s=3427:3467#L151) -``` go -func (ic *IntegrityCheck) Repair() error -``` -Repair repairs the system - - - - -## type [Manifest](/src/target/registry.go?s=585:662#L30) -``` go -type Manifest struct { - Manifest []byte - Digest string - Layers []string -} - -``` -Manifest struct - - - - - - - - - - -## type [PCSpecs](/src/target/specs.go?s=524:594#L25) -``` go -type PCSpecs struct { - CPU string - GPU []string - Memory string -} - -``` - - - - - - -### func [GetPCSpecs](/src/target/specs.go?s=1838:1863#L93) -``` go -func GetPCSpecs() PCSpecs -``` - - - - -## type [PackageManager](/src/target/packages.go?s=590:650#L31) -``` go -type PackageManager struct { - // contains filtered or unexported fields -} - -``` -PackageManager struct - - - - - - - -### func [NewPackageManager](/src/target/packages.go?s=1250:1301#L60) -``` go -func NewPackageManager(dryRun bool) *PackageManager -``` -NewPackageManager returns a new PackageManager struct - - - - - -### func (\*PackageManager) [Add](/src/target/packages.go?s=2539:2585#L117) -``` go -func (p *PackageManager) Add(pkg string) error -``` -Add adds a package to the packages.add file - - - - -### func (\*PackageManager) [ClearUnstagedPackages](/src/target/packages.go?s=6419:6473#L252) -``` go -func (p *PackageManager) ClearUnstagedPackages() error -``` -ClearUnstagedPackages removes all packages from the unstaged list - - - - -### func (\*PackageManager) [ExistsInRepo](/src/target/packages.go?s=13359:13414#L490) -``` go -func (p *PackageManager) ExistsInRepo(pkg string) error -``` - - - -### func (\*PackageManager) [GetAddPackages](/src/target/packages.go?s=4767:4826#L200) -``` go -func (p *PackageManager) GetAddPackages() ([]string, error) -``` -GetAddPackages returns the packages in the packages.add file - - - - -### func (\*PackageManager) [GetAddPackagesString](/src/target/packages.go?s=6672:6745#L258) -``` go -func (p *PackageManager) GetAddPackagesString(sep string) (string, error) -``` -GetAddPackages returns the packages in the packages.add file as string - - - - -### func (\*PackageManager) [GetFinalCmd](/src/target/packages.go?s=11425:11497#L432) -``` go -func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string -``` - - - -### func (\*PackageManager) [GetRemovePackages](/src/target/packages.go?s=5000:5062#L206) -``` go -func (p *PackageManager) GetRemovePackages() ([]string, error) -``` -GetRemovePackages returns the packages in the packages.remove file - - - - -### func (\*PackageManager) [GetRemovePackagesString](/src/target/packages.go?s=7137:7213#L271) -``` go -func (p *PackageManager) GetRemovePackagesString(sep string) (string, error) -``` -GetRemovePackages returns the packages in the packages.remove file as string - - - - -### func (\*PackageManager) [GetUnstagedPackages](/src/target/packages.go?s=5250:5323#L212) -``` go -func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error) -``` -GetUnstagedPackages returns the package changes that are yet to be applied - - - - -### func (\*PackageManager) [GetUnstagedPackagesPlain](/src/target/packages.go?s=5917:5986#L235) -``` go -func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error) -``` -GetUnstagedPackagesPlain returns the package changes that are yet to be applied -as strings - - - - -### func (\*PackageManager) [Remove](/src/target/packages.go?s=3654:3703#L163) -``` go -func (p *PackageManager) Remove(pkg string) error -``` -Remove removes a package from the packages.add file - - - - -## type [Partition](/src/target/disk-manager.go?s=641:1680#L30) -``` go -type Partition struct { - Label string - MountPoint string - MountOptions string - Uuid string - FsType string - - // If standard partition, Device will be the partition's name (e.g. sda1, nvme0n1p1). - // If LUKS-encrypted or LVM volume, Device will be the name in device-mapper. - Device string - - // If the partition is LUKS-encrypted or an LVM volume, the logical volume - // opened in /dev/mapper will be a child of the physical partition in /dev. - // Otherwise, the partition will be a direct child of the block device, and - // Parent will be nil. - // - // The same logic applies for encrypted LVM volumes. When this is the case, - // the filesystem hirearchy is as follows: - // - // NAME FSTYPE - // -- sda1 LVM2_member - // |-- myVG-myLV crypto_LUKS - // |-- luks-volume btrfs - // - // In this case, the parent of "luks-volume" is "myVG-myLV", which, - // in turn, has "sda1" as parent. Since "sda1" is a physical partition, - // its parent is nil. - Parent *Partition -} - -``` -Partition represents either a standard partition or a device-mapper partition. - - - - - - - - - - -### func (\*Partition) [IsDevMapper](/src/target/disk-manager.go?s=6054:6092#L211) -``` go -func (p *Partition) IsDevMapper() bool -``` -Returns whether the partition is a device-mapper virtual partition - - - - -### func (\*Partition) [IsEncrypted](/src/target/disk-manager.go?s=6180:6218#L216) -``` go -func (p *Partition) IsEncrypted() bool -``` -IsEncrypted returns whether the partition is encrypted - - - - -### func (\*Partition) [Mount](/src/target/disk-manager.go?s=4757:4808#L161) -``` go -func (p *Partition) Mount(destination string) error -``` -Mount mounts a partition to a directory - - - - -### func (\*Partition) [Unmount](/src/target/disk-manager.go?s=5459:5494#L189) -``` go -func (p *Partition) Unmount() error -``` -Unmount unmounts a partition - - - - -## type [QueuedFunction](/src/target/system.go?s=706:791#L37) -``` go -type QueuedFunction struct { - Name string - Values []interface{} - Priority int -} - -``` - - - - - - - - - -## type [Registry](/src/target/registry.go?s=528:564#L25) -``` go -type Registry struct { - API string -} - -``` -Registry struct - - - - - - - -### func [NewRegistry](/src/target/registry.go?s=709:737#L37) -``` go -func NewRegistry() *Registry -``` -NewRegistry returns a new Registry struct - - - - - -### func (\*Registry) [GetManifest](/src/target/registry.go?s=2507:2570#L107) -``` go -func (r *Registry) GetManifest(token string) (*Manifest, error) -``` -GetManifest returns the manifest of the image - - - - -### func (\*Registry) [HasUpdate](/src/target/registry.go?s=977:1035#L45) -``` go -func (r *Registry) HasUpdate(digest string) (string, bool) -``` -HasUpdate checks if the image/tag from the registry has a different digest - - - - -## type [UnstagedPackage](/src/target/packages.go?s=1139:1191#L55) -``` go -type UnstagedPackage struct { - Name, Status string -} - -``` -An unstaged package is a package that is waiting to be applied -to the next root. - -Every time a `pkg apply` or `upgrade` operation -is executed, all unstaged packages are consumed and added/removed -in the next root. - diff --git a/docs/tests.md b/docs/tests.md index 88f90b79..a09cdf8d 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -1,1402 +1,3 @@ - -# core -`import "github.com/vanilla-os/abroot/core"` - -* [Overview](#pkg-overview) -* [Index](#pkg-index) - -## Overview - - - -## Index -* [Constants](#pkg-constants) -* [Variables](#pkg-variables) -* [func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error](#AtomicRsync) -* [func AtomicSwap(src, dst string) error](#AtomicSwap) -* [func BaseImagePackageDiff(currentDigest, newDigest string) (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#BaseImagePackageDiff) -* [func CopyFile(source, dest string) error](#CopyFile) -* [func DeleteImageForRoot(root string) error](#DeleteImageForRoot) -* [func DiffFiles(sourceFile, destFile string) ([]byte, error)](#DiffFiles) -* [func FindImageWithLabel(key, value string) (string, error)](#FindImageWithLabel) -* [func GetLogFile() *os.File](#GetLogFile) -* [func GetRepoContentsForPkg(pkg string) (map[string]any, error)](#GetRepoContentsForPkg) -* [func GetToken() (string, error)](#GetToken) -* [func IsVerbose() bool](#IsVerbose) -* [func KargsBackup() error](#KargsBackup) -* [func KargsEdit() (bool, error)](#KargsEdit) -* [func KargsFormat(content string) (string, error)](#KargsFormat) -* [func KargsRead() (string, error)](#KargsRead) -* [func KargsWrite(content string) error](#KargsWrite) -* [func LogToFile(msg string, args ...interface{}) error](#LogToFile) -* [func MergeDiff(firstFile, secondFile, destination string) error](#MergeDiff) -* [func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error](#OciExportRootFs) -* [func OverlayPackageDiff() (added, upgraded, downgraded, removed []diff.PackageDiff, err error)](#OverlayPackageDiff) -* [func PrintVerbose(msg string, args ...interface{})](#PrintVerbose) -* [func PrintVerboseNoLog(msg string, args ...interface{})](#PrintVerboseNoLog) -* [func RetrieveImageForRoot(root string) (string, error)](#RetrieveImageForRoot) -* [func RootCheck(display bool) bool](#RootCheck) -* [func WriteDiff(destFile string, diffLines []byte) error](#WriteDiff) -* [type ABImage](#ABImage) - * [func NewABImage(digest string, image string) (*ABImage, error)](#NewABImage) - * [func NewABImageFromRoot() (*ABImage, error)](#NewABImageFromRoot) - * [func (a *ABImage) WriteTo(dest string, suffix string) error](#ABImage.WriteTo) -* [type ABRootManager](#ABRootManager) - * [func NewABRootManager() *ABRootManager](#NewABRootManager) - * [func (a *ABRootManager) GetBoot() (partition Partition, err error)](#ABRootManager.GetBoot) - * [func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error)](#ABRootManager.GetFuture) - * [func (a *ABRootManager) GetInit() (partition Partition, err error)](#ABRootManager.GetInit) - * [func (a *ABRootManager) GetOther() (partition ABRootPartition, err error)](#ABRootManager.GetOther) - * [func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error)](#ABRootManager.GetPartition) - * [func (a *ABRootManager) GetPartitions() error](#ABRootManager.GetPartitions) - * [func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error)](#ABRootManager.GetPresent) - * [func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error)](#ABRootManager.IdentifyPartition) - * [func (a *ABRootManager) IsCurrent(partition Partition) bool](#ABRootManager.IsCurrent) -* [type ABRootPartition](#ABRootPartition) -* [type ABSystem](#ABSystem) - * [func NewABSystem() (*ABSystem, error)](#NewABSystem) - * [func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{})](#ABSystem.AddToCleanUpQueue) - * [func (s *ABSystem) CheckAll() error](#ABSystem.CheckAll) - * [func (s *ABSystem) CheckUpdate() (string, bool)](#ABSystem.CheckUpdate) - * [func (s *ABSystem) CreateStageFile() error](#ABSystem.CreateStageFile) - * [func (s *ABSystem) GenerateCrypttab(rootPath string) error](#ABSystem.GenerateCrypttab) - * [func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error](#ABSystem.GenerateFstab) - * [func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error](#ABSystem.GenerateSystemdUnits) - * [func (s *ABSystem) LockUpgrade() error](#ABSystem.LockUpgrade) - * [func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error](#ABSystem.MergeUserEtcFiles) - * [func (s *ABSystem) RemoveFromCleanUpQueue(name string)](#ABSystem.RemoveFromCleanUpQueue) - * [func (s *ABSystem) RemoveStageFile() error](#ABSystem.RemoveStageFile) - * [func (s *ABSystem) ResetQueue()](#ABSystem.ResetQueue) - * [func (s *ABSystem) RunCleanUpQueue(fnName string) error](#ABSystem.RunCleanUpQueue) - * [func (s *ABSystem) RunOperation(operation ABSystemOperation) error](#ABSystem.RunOperation) - * [func (s *ABSystem) SyncUpperEtc(newEtc string) error](#ABSystem.SyncUpperEtc) - * [func (s *ABSystem) UnlockUpgrade() error](#ABSystem.UnlockUpgrade) - * [func (s *ABSystem) UpgradeLockExists() bool](#ABSystem.UpgradeLockExists) - * [func (s *ABSystem) UserLockRequested() bool](#ABSystem.UserLockRequested) -* [type ABSystemOperation](#ABSystemOperation) -* [type Checks](#Checks) - * [func NewChecks() *Checks](#NewChecks) - * [func (c *Checks) CheckCompatibilityFS() error](#Checks.CheckCompatibilityFS) - * [func (c *Checks) CheckConnectivity() error](#Checks.CheckConnectivity) - * [func (c *Checks) CheckRoot() error](#Checks.CheckRoot) - * [func (c *Checks) PerformAllChecks() error](#Checks.PerformAllChecks) -* [type Children](#Children) -* [type Chroot](#Chroot) - * [func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error)](#NewChroot) - * [func (c *Chroot) Close() error](#Chroot.Close) - * [func (c *Chroot) Execute(cmd string, args []string) error](#Chroot.Execute) - * [func (c *Chroot) ExecuteCmds(cmds []string) error](#Chroot.ExecuteCmds) -* [type DiskManager](#DiskManager) - * [func NewDiskManager() *DiskManager](#NewDiskManager) - * [func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error)](#DiskManager.GetPartitionByLabel) -* [type GPUInfo](#GPUInfo) -* [type Grub](#Grub) - * [func NewGrub(bootPart Partition) (*Grub, error)](#NewGrub) - * [func (g *Grub) IsBootedIntoPresentRoot() (bool, error)](#Grub.IsBootedIntoPresentRoot) -* [type ImageRecipe](#ImageRecipe) - * [func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe](#NewImageRecipe) - * [func (c *ImageRecipe) Write(path string) error](#ImageRecipe.Write) -* [type IntegrityCheck](#IntegrityCheck) - * [func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error)](#NewIntegrityCheck) - * [func (ic *IntegrityCheck) Repair() error](#IntegrityCheck.Repair) -* [type Manifest](#Manifest) -* [type PCSpecs](#PCSpecs) - * [func GetPCSpecs() PCSpecs](#GetPCSpecs) -* [type PackageManager](#PackageManager) - * [func NewPackageManager(dryRun bool) *PackageManager](#NewPackageManager) - * [func (p *PackageManager) Add(pkg string) error](#PackageManager.Add) - * [func (p *PackageManager) ClearUnstagedPackages() error](#PackageManager.ClearUnstagedPackages) - * [func (p *PackageManager) ExistsInRepo(pkg string) error](#PackageManager.ExistsInRepo) - * [func (p *PackageManager) GetAddPackages() ([]string, error)](#PackageManager.GetAddPackages) - * [func (p *PackageManager) GetAddPackagesString(sep string) (string, error)](#PackageManager.GetAddPackagesString) - * [func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string](#PackageManager.GetFinalCmd) - * [func (p *PackageManager) GetRemovePackages() ([]string, error)](#PackageManager.GetRemovePackages) - * [func (p *PackageManager) GetRemovePackagesString(sep string) (string, error)](#PackageManager.GetRemovePackagesString) - * [func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error)](#PackageManager.GetUnstagedPackages) - * [func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error)](#PackageManager.GetUnstagedPackagesPlain) - * [func (p *PackageManager) Remove(pkg string) error](#PackageManager.Remove) -* [type Partition](#Partition) - * [func (p *Partition) IsDevMapper() bool](#Partition.IsDevMapper) - * [func (p *Partition) IsEncrypted() bool](#Partition.IsEncrypted) - * [func (p *Partition) Mount(destination string) error](#Partition.Mount) - * [func (p *Partition) Unmount() error](#Partition.Unmount) -* [type QueuedFunction](#QueuedFunction) -* [type Registry](#Registry) - * [func NewRegistry() *Registry](#NewRegistry) - * [func (r *Registry) GetManifest(token string) (*Manifest, error)](#Registry.GetManifest) - * [func (r *Registry) HasUpdate(digest string) (string, bool)](#Registry.HasUpdate) -* [type UnstagedPackage](#UnstagedPackage) - - -#### Package files -[atomic-io.go](/src/github.com/vanilla-os/abroot/core/atomic-io.go) [checks.go](/src/github.com/vanilla-os/abroot/core/checks.go) [chroot.go](/src/github.com/vanilla-os/abroot/core/chroot.go) [diff.go](/src/github.com/vanilla-os/abroot/core/diff.go) [disk-manager.go](/src/github.com/vanilla-os/abroot/core/disk-manager.go) [grub.go](/src/github.com/vanilla-os/abroot/core/grub.go) [image-recipe.go](/src/github.com/vanilla-os/abroot/core/image-recipe.go) [image.go](/src/github.com/vanilla-os/abroot/core/image.go) [integrity.go](/src/github.com/vanilla-os/abroot/core/integrity.go) [kargs.go](/src/github.com/vanilla-os/abroot/core/kargs.go) [logging.go](/src/github.com/vanilla-os/abroot/core/logging.go) [oci.go](/src/github.com/vanilla-os/abroot/core/oci.go) [package-diff.go](/src/github.com/vanilla-os/abroot/core/package-diff.go) [packages.go](/src/github.com/vanilla-os/abroot/core/packages.go) [registry.go](/src/github.com/vanilla-os/abroot/core/registry.go) [root.go](/src/github.com/vanilla-os/abroot/core/root.go) [rsync.go](/src/github.com/vanilla-os/abroot/core/rsync.go) [specs.go](/src/github.com/vanilla-os/abroot/core/specs.go) [system.go](/src/github.com/vanilla-os/abroot/core/system.go) [utils.go](/src/github.com/vanilla-os/abroot/core/utils.go) - - -## Constants -``` go -const ( - DefaultKargs = "quiet splash bgrt_disable $vt_handoff" - KargsTmpFile = "/tmp/kargs-temp" -) -``` -``` go -const ( - PackagesBaseDir = "/etc/abroot" - DryRunPackagesBaseDir = "/tmp/abroot" - PackagesAddFile = "packages.add" - PackagesRemoveFile = "packages.remove" - PackagesUnstagedFile = "packages.unstaged" -) -``` -``` go -const ( - ADD = "+" - REMOVE = "-" -) -``` -``` go -const ( - UPGRADE = "upgrade" - FORCE_UPGRADE = "force-upgrade" - DRY_RUN_UPGRADE = "dry-run-upgrade" - APPLY = "package-apply" - DRY_RUN_APPLY = "dry-run-package-apply" - INITRAMFS = "initramfs" - DRY_RUN_INITRAMFS = "dry-run-initramfs" -) -``` -``` go -const ( - MountUnitDir = "/etc/systemd/system" -) -``` - -## Variables -``` go -var ( - ErrNoUpdate error = errors.New("no update available") -) -``` -``` go -var KargsPath = "/etc/abroot/kargs" -``` -``` go -var ReservedMounts = []string{ - "/dev", - "/dev/pts", - "/proc", - "/run", - "/sys", -} -``` - - -## func [AtomicRsync](/src/target/rsync.go?s=3049:3169#L120) -``` go -func AtomicRsync(src, dst string, transitionalPath string, finalPath string, excluded []string, keepUnwanted bool) error -``` -AtomicRsync executes the rsync command in an atomic-like manner. -It does so by dry-running the rsync, and if it succeeds, it runs -the rsync again performing changes. -If the keepUnwanted option -is set to true, it will omit the --delete option, so that the already -existing and unwanted files will not be deleted. -To ensure the changes are applied atomically, we rsync on a _new directory first, -and use atomicSwap to replace the _new with the dst directory. - - - -## func [AtomicSwap](/src/target/atomic-io.go?s=686:724#L26) -``` go -func AtomicSwap(src, dst string) error -``` -atomicSwap allows swapping 2 files or directories in-place and atomically, -using the renameat2 syscall. This should be used instead of os.Rename, -which is not atomic at all. - - - -## func [BaseImagePackageDiff](/src/target/package-diff.go?s=732:864#L30) -``` go -func BaseImagePackageDiff(currentDigest, newDigest string) ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -BaseImagePackageDiff retrieves the added, removed, upgraded and downgraded -base packages (the ones bundled with the image). - - - -## func [CopyFile](/src/target/utils.go?s=1376:1416#L74) -``` go -func CopyFile(source, dest string) error -``` -CopyFile copies a file from source to dest - - - -## func [DeleteImageForRoot](/src/target/oci.go?s=4047:4089#L164) -``` go -func DeleteImageForRoot(root string) error -``` -DeleteImageForRoot deletes the image created for the provided root ("vos-a"|"vos-b") - - - -## func [DiffFiles](/src/target/diff.go?s=1442:1501#L57) -``` go -func DiffFiles(sourceFile, destFile string) ([]byte, error) -``` -DiffFiles returns the diff lines between source and dest files. - - - -## func [FindImageWithLabel](/src/target/oci.go?s=2711:2769#L114) -``` go -func FindImageWithLabel(key, value string) (string, error) -``` -FindImageWithLabel returns the name of the first image containinig the provided key-value pair -or an empty string if none was found - - - -## func [GetLogFile](/src/target/logging.go?s=1980:2006#L98) -``` go -func GetLogFile() *os.File -``` - - -## func [GetRepoContentsForPkg](/src/target/packages.go?s=14199:14261#L520) -``` go -func GetRepoContentsForPkg(pkg string) (map[string]any, error) -``` -GetRepoContentsForPkg retrieves package information from the repository API - - - -## func [GetToken](/src/target/registry.go?s=1685:1716#L70) -``` go -func GetToken() (string, error) -``` -GetToken generates a token using the provided tokenURL and returns it - - - -## func [IsVerbose](/src/target/logging.go?s=1338:1359#L64) -``` go -func IsVerbose() bool -``` - - -## func [KargsBackup](/src/target/kargs.go?s=1884:1908#L84) -``` go -func KargsBackup() error -``` -KargsBackup makes a backup of the current kargs file - - - -## func [KargsEdit](/src/target/kargs.go?s=3643:3673#L159) -``` go -func KargsEdit() (bool, error) -``` -KargsEdit copies the kargs file to a temporary file and opens it in the -user's preferred editor by querying the $EDITOR environment variable. -Once closed, its contents are written back to the main kargs file. -This function returns a boolean parameter indicating whether any changes -were made to the kargs file. - - - -## func [KargsFormat](/src/target/kargs.go?s=2768:2816#L123) -``` go -func KargsFormat(content string) (string, error) -``` -KargsFormat formats the contents of the kargs file, ensuring that -there are no duplicate entries, multiple spaces or trailing newline - - - -## func [KargsRead](/src/target/kargs.go?s=2275:2307#L103) -``` go -func KargsRead() (string, error) -``` -KargsRead reads the content of the kargs file - - - -## func [KargsWrite](/src/target/kargs.go?s=1243:1280#L53) -``` go -func KargsWrite(content string) error -``` -KargsWrite makes a backup of the current kargs file and then -writes the new content to it - - - -## func [LogToFile](/src/target/logging.go?s=1739:1792#L85) -``` go -func LogToFile(msg string, args ...interface{}) error -``` - - -## func [MergeDiff](/src/target/diff.go?s=539:602#L23) -``` go -func MergeDiff(firstFile, secondFile, destination string) error -``` -MergeDiff merges the diff lines between the first and second files into destination - - - -## func [OciExportRootFs](/src/target/oci.go?s=691:796#L29) -``` go -func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir string, dest string) error -``` -OciExportRootFs generates a rootfs from a image recipe file - - - -## func [OverlayPackageDiff](/src/target/package-diff.go?s=2565:2664#L88) -``` go -func OverlayPackageDiff() ( - added, upgraded, downgraded, removed []diff.PackageDiff, - err error, -) -``` -OverlayPackageDiff retrieves the added, removed, upgraded and downgraded -overlay packages (the ones added manually via `abroot pkg add`). - - - -## func [PrintVerbose](/src/target/logging.go?s=1464:1514#L70) -``` go -func PrintVerbose(msg string, args ...interface{}) -``` - - -## func [PrintVerboseNoLog](/src/target/logging.go?s=1604:1659#L78) -``` go -func PrintVerboseNoLog(msg string, args ...interface{}) -``` - - -## func [RetrieveImageForRoot](/src/target/oci.go?s=3686:3740#L151) -``` go -func RetrieveImageForRoot(root string) (string, error) -``` -RetrieveImageForRoot retrieves the image created for the provided root ("vos-a"|"vos-b") - - - -## func [RootCheck](/src/target/utils.go?s=690:723#L39) -``` go -func RootCheck(display bool) bool -``` - - -## func [WriteDiff](/src/target/diff.go?s=2023:2078#L81) -``` go -func WriteDiff(destFile string, diffLines []byte) error -``` -WriteDiff applies the diff lines to the destination file. - - - - -## type [ABImage](/src/target/image.go?s=499:635#L25) -``` go -type ABImage struct { - Digest string `json:"digest"` - Timestamp time.Time `json:"timestamp"` - Image string `json:"image"` -} - -``` -ABImage struct - - - - - - - -### func [NewABImage](/src/target/image.go?s=680:742#L32) -``` go -func NewABImage(digest string, image string) (*ABImage, error) -``` -NewABImage returns a new ABImage struct - - -### func [NewABImageFromRoot](/src/target/image.go?s=987:1030#L45) -``` go -func NewABImageFromRoot() (*ABImage, error) -``` -NewABImageFromRoot returns the current ABImage from /abimage.abr - - - - - -### func (\*ABImage) [WriteTo](/src/target/image.go?s=1501:1560#L66) -``` go -func (a *ABImage) WriteTo(dest string, suffix string) error -``` -WriteTo writes the json to a dest path - - - - -## type [ABRootManager](/src/target/root.go?s=525:610#L23) -``` go -type ABRootManager struct { - Partitions []ABRootPartition - VarPartition Partition -} - -``` -ABRootManager represents the ABRoot manager - - - - - - - -### func [NewABRootManager](/src/target/root.go?s=1002:1040#L41) -``` go -func NewABRootManager() *ABRootManager -``` -NewABRootManager creates a new ABRootManager - - - - - -### func (\*ABRootManager) [GetBoot](/src/target/root.go?s=5676:5742#L194) -``` go -func (a *ABRootManager) GetBoot() (partition Partition, err error) -``` -GetBoot gets the boot partition from the current device - - - - -### func (\*ABRootManager) [GetFuture](/src/target/root.go?s=4037:4111#L143) -``` go -func (a *ABRootManager) GetFuture() (partition ABRootPartition, err error) -``` -GetFuture gets the future partition - - - - -### func (\*ABRootManager) [GetInit](/src/target/root.go?s=6201:6267#L211) -``` go -func (a *ABRootManager) GetInit() (partition Partition, err error) -``` -GetInit gets the init volume when using LVM Thin-Provisioning - - - - -### func (\*ABRootManager) [GetOther](/src/target/root.go?s=4539:4612#L159) -``` go -func (a *ABRootManager) GetOther() (partition ABRootPartition, err error) -``` -GetOther gets the other partition - - - - -### func (\*ABRootManager) [GetPartition](/src/target/root.go?s=5152:5241#L178) -``` go -func (a *ABRootManager) GetPartition(label string) (partition ABRootPartition, err error) -``` -GetPartition gets a partition by label - - - - -### func (\*ABRootManager) [GetPartitions](/src/target/root.go?s=1212:1257#L51) -``` go -func (a *ABRootManager) GetPartitions() error -``` -GetPartitions gets the root partitions from the current device - - - - -### func (\*ABRootManager) [GetPresent](/src/target/root.go?s=3526:3601#L127) -``` go -func (a *ABRootManager) GetPresent() (partition ABRootPartition, err error) -``` -GetPresent gets the present partition - - - - -### func (\*ABRootManager) [IdentifyPartition](/src/target/root.go?s=2854:2949#L108) -``` go -func (a *ABRootManager) IdentifyPartition(partition Partition) (identifiedAs string, err error) -``` -IdentifyPartition identifies a partition - - - - -### func (\*ABRootManager) [IsCurrent](/src/target/root.go?s=2494:2553#L95) -``` go -func (a *ABRootManager) IsCurrent(partition Partition) bool -``` -IsCurrent checks if a partition is the current one - - - - -## type [ABRootPartition](/src/target/root.go?s=662:952#L29) -``` go -type ABRootPartition struct { - Label string // Matches `partLabelA` and `partLabelB` settings entries - IdentifiedAs string // Either `present` or `future` - Partition Partition - MountPoint string - MountOptions string - Uuid string - FsType string - Current bool -} - -``` -ABRootPartition represents an ABRoot partition - - - - - - - - - - -## type [ABSystem](/src/target/system.go?s=598:704#L30) -``` go -type ABSystem struct { - Checks *Checks - RootM *ABRootManager - Registry *Registry - CurImage *ABImage -} - -``` -ABSystem represents the system - - - - - - - -### func [NewABSystem](/src/target/system.go?s=1496:1533#L68) -``` go -func NewABSystem() (*ABSystem, error) -``` -NewABSystem creates a new system - - - - - -### func (\*ABSystem) [AddToCleanUpQueue](/src/target/system.go?s=7633:7719#L288) -``` go -func (s *ABSystem) AddToCleanUpQueue(name string, priority int, values ...interface{}) -``` -AddToCleanUpQueue adds a function to the queue - - - - -### func (\*ABSystem) [CheckAll](/src/target/system.go?s=1903:1938#L90) -``` go -func (s *ABSystem) CheckAll() error -``` -CheckAll performs all checks from the Checks struct - - - - -### func (\*ABSystem) [CheckUpdate](/src/target/system.go?s=2231:2278#L104) -``` go -func (s *ABSystem) CheckUpdate() (string, bool) -``` -CheckUpdate checks if there is an update available - - - - -### func (\*ABSystem) [CreateStageFile](/src/target/system.go?s=29265:29307#L1039) -``` go -func (s *ABSystem) CreateStageFile() error -``` - - - -### func (\*ABSystem) [GenerateCrypttab](/src/target/system.go?s=9297:9355#L349) -``` go -func (s *ABSystem) GenerateCrypttab(rootPath string) error -``` -GenerateCrypttab identifies which devices are encrypted and generates -the /etc/crypttab file for the specified root - - - - -### func (\*ABSystem) [GenerateFstab](/src/target/system.go?s=8227:8304#L312) -``` go -func (s *ABSystem) GenerateFstab(rootPath string, root ABRootPartition) error -``` -GenerateFstab generates a fstab file for the future root - - - - -### func (\*ABSystem) [GenerateSystemdUnits](/src/target/system.go?s=10698:10782#L398) -``` go -func (s *ABSystem) GenerateSystemdUnits(rootPath string, root ABRootPartition) error -``` -GenerateSystemdUnits generates systemd units that mount the mutable parts of the system - - - - -### func (\*ABSystem) [LockUpgrade](/src/target/system.go?s=28810:28848#L1017) -``` go -func (s *ABSystem) LockUpgrade() error -``` - - - -### func (\*ABSystem) [MergeUserEtcFiles](/src/target/system.go?s=2546:2634#L111) -``` go -func (s *ABSystem) MergeUserEtcFiles(oldUpperEtc, newLowerEtc, newUpperEtc string) error -``` -MergeUserEtcFiles merges user-related files from the new lower etc (/.system/etc) -with the old upper etc, if present, saving the result in the new upper etc. - - - - -### func (\*ABSystem) [RemoveFromCleanUpQueue](/src/target/system.go?s=7888:7942#L297) -``` go -func (s *ABSystem) RemoveFromCleanUpQueue(name string) -``` -RemoveFromCleanUpQueue removes a function from the queue - - - - -### func (\*ABSystem) [RemoveStageFile](/src/target/system.go?s=29505:29547#L1050) -``` go -func (s *ABSystem) RemoveStageFile() error -``` - - - -### func (\*ABSystem) [ResetQueue](/src/target/system.go?s=8102:8133#L307) -``` go -func (s *ABSystem) ResetQueue() -``` -ResetQueue resets the queue - - - - -### func (\*ABSystem) [RunCleanUpQueue](/src/target/system.go?s=4882:4937#L199) -``` go -func (s *ABSystem) RunCleanUpQueue(fnName string) error -``` -RunCleanUpQueue runs the functions in the queue or only the specified one - - - - -### func (\*ABSystem) [RunOperation](/src/target/system.go?s=13435:13501#L477) -``` go -func (s *ABSystem) RunOperation(operation ABSystemOperation) error -``` -RunOperation executes a root-switching operation from the options below: - - - UPGRADE: Upgrades to a new image, if available, - FORCE_UPGRADE: Forces the upgrade operation, even if no new image is available, - APPLY: Applies package changes, but doesn't update the system. - INITRAMFS: Updates the initramfs for the future root, but doesn't update the system. - - - - -### func (\*ABSystem) [SyncUpperEtc](/src/target/system.go?s=3834:3886#L158) -``` go -func (s *ABSystem) SyncUpperEtc(newEtc string) error -``` -SyncUpperEtc syncs the mutable etc directories from /var/lib/abroot/etc - - - - -### func (\*ABSystem) [UnlockUpgrade](/src/target/system.go?s=29036:29076#L1028) -``` go -func (s *ABSystem) UnlockUpgrade() error -``` - - - -### func (\*ABSystem) [UpgradeLockExists](/src/target/system.go?s=28613:28656#L1008) -``` go -func (s *ABSystem) UpgradeLockExists() bool -``` - - - -### func (\*ABSystem) [UserLockRequested](/src/target/system.go?s=28412:28455#L999) -``` go -func (s *ABSystem) UserLockRequested() bool -``` - - - -## type [ABSystemOperation](/src/target/system.go?s=1116:1145#L57) -``` go -type ABSystemOperation string -``` - - - - - - - - - -## type [Checks](/src/target/checks.go?s=616:636#L27) -``` go -type Checks struct{} - -``` -Represents a Checks struct which contains all the checks which can -be performed one by one or all at once using PerformAllChecks() - - - - - - - -### func [NewChecks](/src/target/checks.go?s=679:703#L30) -``` go -func NewChecks() *Checks -``` -NewChecks returns a new Checks struct - - - - - -### func (\*Checks) [CheckCompatibilityFS](/src/target/checks.go?s=1074:1119#L55) -``` go -func (c *Checks) CheckCompatibilityFS() error -``` -CheckCompatibilityFS checks if the filesystem is compatible - - - - -### func (\*Checks) [CheckConnectivity](/src/target/checks.go?s=2252:2294#L93) -``` go -func (c *Checks) CheckConnectivity() error -``` -CheckConnectivity checks if the system is connected to the internet - - - - -### func (\*Checks) [CheckRoot](/src/target/checks.go?s=2598:2632#L107) -``` go -func (c *Checks) CheckRoot() error -``` -CheckRoot checks if the user is root - - - - -### func (\*Checks) [PerformAllChecks](/src/target/checks.go?s=767:808#L35) -``` go -func (c *Checks) PerformAllChecks() error -``` -PerformAllChecks performs all checks - - - - -## type [Children](/src/target/disk-manager.go?s=1735:2089#L61) -``` go -type Children struct { - MountPoint string `json:"mountpoint"` - FsType string `json:"fstype"` - Label string `json:"label"` - Uuid string `json:"uuid"` - LogicalName string `json:"name"` - Size string `json:"size"` - MountOptions string `json:"mountopts"` - Children []Children `json:"children"` -} - -``` -The children a block device or partition may have - - - - - - - - - - -## type [Chroot](/src/target/chroot.go?s=542:621#L25) -``` go -type Chroot struct { - // contains filtered or unexported fields -} - -``` -Chroot is a struct which represents a chroot environment - - - - - - - -### func [NewChroot](/src/target/chroot.go?s=753:833#L40) -``` go -func NewChroot(root string, rootUuid string, rootDevice string) (*Chroot, error) -``` -NewChroot creates a new chroot environment - - - - - -### func (\*Chroot) [Close](/src/target/chroot.go?s=1759:1789#L78) -``` go -func (c *Chroot) Close() error -``` -Close unmounts all the bind mounts - - - - -### func (\*Chroot) [Execute](/src/target/chroot.go?s=2473:2530#L109) -``` go -func (c *Chroot) Execute(cmd string, args []string) error -``` -Execute runs a command in the chroot environment - - - - -### func (\*Chroot) [ExecuteCmds](/src/target/chroot.go?s=3078:3127#L130) -``` go -func (c *Chroot) ExecuteCmds(cmds []string) error -``` -ExecuteCmds runs a list of commands in the chroot environment, -stops at the first error - - - - -## type [DiskManager](/src/target/disk-manager.go?s=532:557#L27) -``` go -type DiskManager struct{} - -``` -DiskManager represents a disk - - - - - - - -### func [NewDiskManager](/src/target/disk-manager.go?s=2135:2169#L73) -``` go -func NewDiskManager() *DiskManager -``` -NewDiskManager creates a new DiskManager - - - - - -### func (\*DiskManager) [GetPartitionByLabel](/src/target/disk-manager.go?s=2339:2413#L80) -``` go -func (d *DiskManager) GetPartitionByLabel(label string) (Partition, error) -``` -GetPartitionByLabel finds a partition by searching for its label. - -If no partition can be found with the given label, returns error. - - - - -## type [GPUInfo](/src/target/specs.go?s=596:659#L31) -``` go -type GPUInfo struct { - Address string - Description string -} - -``` - - - - - - - - - -## type [Grub](/src/target/grub.go?s=519:579#L26) -``` go -type Grub struct { - PresentRoot string - FutureRoot string -} - -``` - - - - - - -### func [NewGrub](/src/target/grub.go?s=3047:3094#L126) -``` go -func NewGrub(bootPart Partition) (*Grub, error) -``` -NewGrub creates a new Grub instance - - - - - -### func (\*Grub) [IsBootedIntoPresentRoot](/src/target/grub.go?s=4101:4155#L168) -``` go -func (g *Grub) IsBootedIntoPresentRoot() (bool, error) -``` - - - -## type [ImageRecipe](/src/target/image-recipe.go?s=439:552#L21) -``` go -type ImageRecipe struct { - From string - Labels map[string]string - Args map[string]string - Content string -} - -``` - - - - - - -### func [NewImageRecipe](/src/target/image-recipe.go?s=605:717#L29) -``` go -func NewImageRecipe(image string, labels map[string]string, args map[string]string, content string) *ImageRecipe -``` -NewImageRecipe creates a new ImageRecipe struct - - - - - -### func (\*ImageRecipe) [Write](/src/target/image-recipe.go?s=907:953#L41) -``` go -func (c *ImageRecipe) Write(path string) error -``` -Write writes a ImageRecipe to a path - - - - -## type [IntegrityCheck](/src/target/integrity.go?s=498:644#L24) -``` go -type IntegrityCheck struct { - // contains filtered or unexported fields -} - -``` - - - - - - -### func [NewIntegrityCheck](/src/target/integrity.go?s=705:787#L33) -``` go -func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, error) -``` -NewIntegrityCheck creates a new IntegrityCheck instance - - - - - -### func (\*IntegrityCheck) [Repair](/src/target/integrity.go?s=3427:3467#L151) -``` go -func (ic *IntegrityCheck) Repair() error -``` -Repair repairs the system - - - - -## type [Manifest](/src/target/registry.go?s=585:662#L30) -``` go -type Manifest struct { - Manifest []byte - Digest string - Layers []string -} - -``` -Manifest struct - - - - - - - - - - -## type [PCSpecs](/src/target/specs.go?s=524:594#L25) -``` go -type PCSpecs struct { - CPU string - GPU []string - Memory string -} - -``` - - - - - - -### func [GetPCSpecs](/src/target/specs.go?s=1838:1863#L93) -``` go -func GetPCSpecs() PCSpecs -``` - - - - -## type [PackageManager](/src/target/packages.go?s=590:650#L31) -``` go -type PackageManager struct { - // contains filtered or unexported fields -} - -``` -PackageManager struct - - - - - - - -### func [NewPackageManager](/src/target/packages.go?s=1250:1301#L60) -``` go -func NewPackageManager(dryRun bool) *PackageManager -``` -NewPackageManager returns a new PackageManager struct - - - - - -### func (\*PackageManager) [Add](/src/target/packages.go?s=2539:2585#L117) -``` go -func (p *PackageManager) Add(pkg string) error -``` -Add adds a package to the packages.add file - - - - -### func (\*PackageManager) [ClearUnstagedPackages](/src/target/packages.go?s=6419:6473#L252) -``` go -func (p *PackageManager) ClearUnstagedPackages() error -``` -ClearUnstagedPackages removes all packages from the unstaged list - - - - -### func (\*PackageManager) [ExistsInRepo](/src/target/packages.go?s=13359:13414#L490) -``` go -func (p *PackageManager) ExistsInRepo(pkg string) error -``` - - - -### func (\*PackageManager) [GetAddPackages](/src/target/packages.go?s=4767:4826#L200) -``` go -func (p *PackageManager) GetAddPackages() ([]string, error) -``` -GetAddPackages returns the packages in the packages.add file - - - - -### func (\*PackageManager) [GetAddPackagesString](/src/target/packages.go?s=6672:6745#L258) -``` go -func (p *PackageManager) GetAddPackagesString(sep string) (string, error) -``` -GetAddPackages returns the packages in the packages.add file as string - - - - -### func (\*PackageManager) [GetFinalCmd](/src/target/packages.go?s=11425:11497#L432) -``` go -func (p *PackageManager) GetFinalCmd(operation ABSystemOperation) string -``` - - - -### func (\*PackageManager) [GetRemovePackages](/src/target/packages.go?s=5000:5062#L206) -``` go -func (p *PackageManager) GetRemovePackages() ([]string, error) -``` -GetRemovePackages returns the packages in the packages.remove file - - - - -### func (\*PackageManager) [GetRemovePackagesString](/src/target/packages.go?s=7137:7213#L271) -``` go -func (p *PackageManager) GetRemovePackagesString(sep string) (string, error) -``` -GetRemovePackages returns the packages in the packages.remove file as string - - - - -### func (\*PackageManager) [GetUnstagedPackages](/src/target/packages.go?s=5250:5323#L212) -``` go -func (p *PackageManager) GetUnstagedPackages() ([]UnstagedPackage, error) -``` -GetUnstagedPackages returns the package changes that are yet to be applied - - - - -### func (\*PackageManager) [GetUnstagedPackagesPlain](/src/target/packages.go?s=5917:5986#L235) -``` go -func (p *PackageManager) GetUnstagedPackagesPlain() ([]string, error) -``` -GetUnstagedPackagesPlain returns the package changes that are yet to be applied -as strings - - - - -### func (\*PackageManager) [Remove](/src/target/packages.go?s=3654:3703#L163) -``` go -func (p *PackageManager) Remove(pkg string) error -``` -Remove removes a package from the packages.add file - - - - -## type [Partition](/src/target/disk-manager.go?s=641:1680#L30) -``` go -type Partition struct { - Label string - MountPoint string - MountOptions string - Uuid string - FsType string - - // If standard partition, Device will be the partition's name (e.g. sda1, nvme0n1p1). - // If LUKS-encrypted or LVM volume, Device will be the name in device-mapper. - Device string - - // If the partition is LUKS-encrypted or an LVM volume, the logical volume - // opened in /dev/mapper will be a child of the physical partition in /dev. - // Otherwise, the partition will be a direct child of the block device, and - // Parent will be nil. - // - // The same logic applies for encrypted LVM volumes. When this is the case, - // the filesystem hirearchy is as follows: - // - // NAME FSTYPE - // -- sda1 LVM2_member - // |-- myVG-myLV crypto_LUKS - // |-- luks-volume btrfs - // - // In this case, the parent of "luks-volume" is "myVG-myLV", which, - // in turn, has "sda1" as parent. Since "sda1" is a physical partition, - // its parent is nil. - Parent *Partition -} - -``` -Partition represents either a standard partition or a device-mapper partition. - - - - - - - - - - -### func (\*Partition) [IsDevMapper](/src/target/disk-manager.go?s=6054:6092#L211) -``` go -func (p *Partition) IsDevMapper() bool -``` -Returns whether the partition is a device-mapper virtual partition - - - - -### func (\*Partition) [IsEncrypted](/src/target/disk-manager.go?s=6180:6218#L216) -``` go -func (p *Partition) IsEncrypted() bool -``` -IsEncrypted returns whether the partition is encrypted - - - - -### func (\*Partition) [Mount](/src/target/disk-manager.go?s=4757:4808#L161) -``` go -func (p *Partition) Mount(destination string) error -``` -Mount mounts a partition to a directory - - - - -### func (\*Partition) [Unmount](/src/target/disk-manager.go?s=5459:5494#L189) -``` go -func (p *Partition) Unmount() error -``` -Unmount unmounts a partition - - - - -## type [QueuedFunction](/src/target/system.go?s=706:791#L37) -``` go -type QueuedFunction struct { - Name string - Values []interface{} - Priority int -} - -``` - - - - - - - - - -## type [Registry](/src/target/registry.go?s=528:564#L25) -``` go -type Registry struct { - API string -} - -``` -Registry struct - - - - - - - -### func [NewRegistry](/src/target/registry.go?s=709:737#L37) -``` go -func NewRegistry() *Registry -``` -NewRegistry returns a new Registry struct - - - - - -### func (\*Registry) [GetManifest](/src/target/registry.go?s=2507:2570#L107) -``` go -func (r *Registry) GetManifest(token string) (*Manifest, error) -``` -GetManifest returns the manifest of the image - - - - -### func (\*Registry) [HasUpdate](/src/target/registry.go?s=977:1035#L45) -``` go -func (r *Registry) HasUpdate(digest string) (string, bool) -``` -HasUpdate checks if the image/tag from the registry has a different digest - - - - -## type [UnstagedPackage](/src/target/packages.go?s=1139:1191#L55) -``` go -type UnstagedPackage struct { - Name, Status string -} - -``` -An unstaged package is a package that is waiting to be applied -to the next root. - -Every time a `pkg apply` or `upgrade` operation -is executed, all unstaged packages are consumed and added/removed -in the next root. - - - - - - - - - - - - - - - - - Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) diff --git a/docs/update.sh b/docs/update.sh index a04aa827..ae8a9c53 100644 --- a/docs/update.sh +++ b/docs/update.sh @@ -5,7 +5,7 @@ if [ $(basename $(pwd)) == "docs" ]; then fi godoc2md github.com/vanilla-os/abroot/core > docs/core.md -godoc2md github.com/vanilla-os/abroot/core > docs/cmd.md -godoc2md github.com/vanilla-os/abroot/core > docs/extras.md -godoc2md github.com/vanilla-os/abroot/core > docs/settings.md -godoc2md github.com/vanilla-os/abroot/core > docs/tests.md +godoc2md github.com/vanilla-os/abroot/cmd > docs/cmd.md +godoc2md github.com/vanilla-os/abroot/extras > docs/extras.md +godoc2md github.com/vanilla-os/abroot/settings > docs/settings.md +godoc2md github.com/vanilla-os/abroot/tests > docs/tests.md