-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathostype.go
45 lines (41 loc) · 2.9 KB
/
ostype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package osmgr
const SIZE_KiB int64 = 1024
const SIZE_MiB int64 = SIZE_KiB * 1024
const SIZE_GiB int64 = SIZE_MiB * 1024
const SIZE_TiB int64 = SIZE_GiB * 1024
const SIZE_PiB int64 = SIZE_TiB * 1024
const SIZE_ZiB int64 = SIZE_PiB * 1024
// OS holds methods to interact with a specific operating system install
type OS interface {
//Filled in by implementation for OS detection and install steps
//- Filesystems not yet understood simply won't be available for use, and returning nothing means that kind of filesystem isn't available for use
//- Returning a size of 0 means no minimum size except the contents of what must exist, usually used for testing a new OS or an upgrade (just don't use small partitions until you know)
GetPartitionTables() []string //Usually just gpt and/or dos
GetBootFilesystems() []string //Return nothing to skip installing/managing a bootloader
GetBootSize() int64
GetSystemFilesystems() []string //Return nothing to skip installing a system image
GetSystemSize() int64
GetRecoveryFilesystems() []string //Return nothing if recovery files cannot be moved, defaults to system
GetRecoverySize() int64
GetHomeFilesystems() []string //Return nothing if home folders cannot be moved, defaults to system
GetHomeSize() int64
GetTempFilesystems() []string //Return nothing if temp folders cannot be moved, defaults to system
GetTempSize() int64
GetSwap() bool //Return true if swap partition/file support is available
//Called during the installation phases
InstallBoot(*Partition) error //Used to install the bootloader, Infer MBR/GPT from *Partition.Disk.Table
InstallSystem(*Partition) error //Used to install or upgrade the main system image
InstallRecovery(*Partition) error //Used to install or upgrade the recovery image, defaults to system partition
InstallHome(*Partition) error //Used to migrate or otherwise be aware of home files, defaults to system partition
InstallTemp(*Partition) error //Defaults to system partition, but useful if alternative temp folders are available
InstallSwap(*Partition) error //Used to make a swap partition if one was specified
//Called to determine if a given disk or a given partition space is valid for install
//- Calculates a default partition layout to fill in the given space
//- Specifying a disk should assume the disk's entire space is available for calculations
//- Specifying one or more partitions should assume the user selected to use the specified space for the install
//- Use either *Disk.GetFreePartitionsAvailable() or *Partition.Disk.GetFreePartitionsAvailable() so you don't exceed absolute capacity
//- Return nil or an empty partition slice to signal an impossible install context
GetFreshTableRecommendsDisk(*Disk) []*Partition
GetFreshTableRecommendsPartitions(...*Partition) []*Partition
AreTableRecommendsFast() bool //Fast calculations may be displayed in real time, otherwise they'll be saved for the install confirmation
}