Unexport functions
This commit is contained in:
parent
68291e2666
commit
9485248d8e
@ -23,8 +23,8 @@ type BPMHook struct {
|
||||
Run string `yaml:"run"`
|
||||
}
|
||||
|
||||
// CreateHook returns a BPMHook instance based on the content of the given string
|
||||
func CreateHook(sourcePath string) (*BPMHook, error) {
|
||||
// createHook returns a BPMHook instance based on the content of the given string
|
||||
func createHook(sourcePath string) (*BPMHook, error) {
|
||||
// Read hook from source path
|
||||
bytes, err := os.ReadFile(sourcePath)
|
||||
if err != nil {
|
||||
|
@ -372,12 +372,12 @@ func (operation *BPMOperation) ShowOperationSummary() {
|
||||
fmt.Println("Warning: Operating in " + operation.RootDir)
|
||||
}
|
||||
if operation.GetTotalDownloadSize() > 0 {
|
||||
fmt.Printf("%s will be downloaded to complete this operation\n", UnsignedBytesToHumanReadable(operation.GetTotalDownloadSize()))
|
||||
fmt.Printf("%s will be downloaded to complete this operation\n", unsignedBytesToHumanReadable(operation.GetTotalDownloadSize()))
|
||||
}
|
||||
if operation.GetFinalActionSize(operation.RootDir) > 0 {
|
||||
fmt.Printf("A total of %s will be installed after the operation finishes\n", BytesToHumanReadable(operation.GetFinalActionSize(operation.RootDir)))
|
||||
fmt.Printf("A total of %s will be installed after the operation finishes\n", bytesToHumanReadable(operation.GetFinalActionSize(operation.RootDir)))
|
||||
} else if operation.GetFinalActionSize(operation.RootDir) < 0 {
|
||||
fmt.Printf("A total of %s will be freed after the operation finishes\n", strings.TrimPrefix(BytesToHumanReadable(operation.GetFinalActionSize(operation.RootDir)), "-"))
|
||||
fmt.Printf("A total of %s will be freed after the operation finishes\n", strings.TrimPrefix(bytesToHumanReadable(operation.GetFinalActionSize(operation.RootDir)), "-"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ func (operation *BPMOperation) RunHooks(verbose bool) error {
|
||||
// Find all hooks, validate and execute them
|
||||
for _, entry := range dirEntries {
|
||||
if entry.Type().IsRegular() && strings.HasSuffix(entry.Name(), ".bpmhook") {
|
||||
hook, err := CreateHook(path.Join(operation.RootDir, "var/lib/bpm/hooks", entry.Name()))
|
||||
hook, err := createHook(path.Join(operation.RootDir, "var/lib/bpm/hooks", entry.Name()))
|
||||
if err != nil {
|
||||
log.Printf("Error while reading hook (%s): %s", entry.Name(), err)
|
||||
}
|
||||
@ -458,7 +458,7 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
|
||||
for _, action := range operation.Actions {
|
||||
if action.GetActionType() == "remove" {
|
||||
pkgInfo := action.(*RemovePackageAction).BpmPackage.PkgInfo
|
||||
err := RemovePackage(pkgInfo.Name, verbose, operation.RootDir)
|
||||
err := removePackage(pkgInfo.Name, verbose, operation.RootDir)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("could not remove package (%s): %s\n", pkgInfo.Name, err))
|
||||
}
|
||||
@ -468,9 +468,9 @@ func (operation *BPMOperation) Execute(verbose, force bool) error {
|
||||
isReinstall := IsPackageInstalled(bpmpkg.PkgInfo.Name, operation.RootDir)
|
||||
var err error
|
||||
if value.IsDependency {
|
||||
err = InstallPackage(value.File, operation.RootDir, verbose, true, false, false, false)
|
||||
err = installPackage(value.File, operation.RootDir, verbose, true, false, false, false)
|
||||
} else {
|
||||
err = InstallPackage(value.File, operation.RootDir, verbose, force, false, false, false)
|
||||
err = installPackage(value.File, operation.RootDir, verbose, force, false, false, false)
|
||||
}
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("could not install package (%s): %s\n", bpmpkg.PkgInfo.Name, err))
|
||||
|
@ -288,7 +288,7 @@ const (
|
||||
Remove = 2
|
||||
)
|
||||
|
||||
func ExecutePackageScripts(filename, rootDir string, operation Operation, postOperation bool) error {
|
||||
func executePackageScripts(filename, rootDir string, operation Operation, postOperation bool) error {
|
||||
pkgInfo, err := ReadPackage(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -478,12 +478,12 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations bool, p
|
||||
|
||||
func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string) error {
|
||||
if !IsPackageInstalled(bpmpkg.PkgInfo.Name, rootDir) {
|
||||
err := ExecutePackageScripts(filename, rootDir, Install, false)
|
||||
err := executePackageScripts(filename, rootDir, Install, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err := ExecutePackageScripts(filename, rootDir, Update, false)
|
||||
err := executePackageScripts(filename, rootDir, Update, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -494,7 +494,7 @@ func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string)
|
||||
return err
|
||||
}
|
||||
|
||||
tarballFile, err := ReadTarballContent(filename, "files.tar.gz")
|
||||
tarballFile, err := readTarballContent(filename, "files.tar.gz")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -629,12 +629,12 @@ func isSplitPackage(filename string) bool {
|
||||
func compilePackage(bpmpkg *BPMPackage, filename, rootDir string, verbose, binaryPkgFromSrc, skipCheck, keepTempDir bool) (error, []string) {
|
||||
var files []string
|
||||
if !IsPackageInstalled(bpmpkg.PkgInfo.Name, rootDir) {
|
||||
err := ExecutePackageScripts(filename, rootDir, Install, false)
|
||||
err := executePackageScripts(filename, rootDir, Install, false)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
} else {
|
||||
err := ExecutePackageScripts(filename, rootDir, Update, false)
|
||||
err := executePackageScripts(filename, rootDir, Update, false)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
@ -747,12 +747,12 @@ func compilePackage(bpmpkg *BPMPackage, filename, rootDir string, verbose, binar
|
||||
}
|
||||
fmt.Println("Running source.sh file...")
|
||||
if !IsPackageInstalled(bpmpkg.PkgInfo.Name, rootDir) {
|
||||
err = ExecutePackageScripts(filename, rootDir, Install, false)
|
||||
err = executePackageScripts(filename, rootDir, Install, false)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
} else {
|
||||
err = ExecutePackageScripts(filename, rootDir, Update, false)
|
||||
err = executePackageScripts(filename, rootDir, Update, false)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
@ -1051,7 +1051,7 @@ fi
|
||||
return nil, files
|
||||
}
|
||||
|
||||
func InstallPackage(filename, rootDir string, verbose, force, binaryPkgFromSrc, skipCheck, keepTempDir bool) error {
|
||||
func installPackage(filename, rootDir string, verbose, force, binaryPkgFromSrc, skipCheck, keepTempDir bool) error {
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
@ -1198,7 +1198,7 @@ func InstallPackage(filename, rootDir string, verbose, force, binaryPkgFromSrc,
|
||||
return err
|
||||
}
|
||||
|
||||
tarballFile, err := ReadTarballContent(filename, "pkg.files")
|
||||
tarballFile, err := readTarballContent(filename, "pkg.files")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1246,12 +1246,12 @@ func InstallPackage(filename, rootDir string, verbose, force, binaryPkgFromSrc,
|
||||
}
|
||||
|
||||
if !packageInstalled {
|
||||
err = ExecutePackageScripts(filename, rootDir, Install, true)
|
||||
err = executePackageScripts(filename, rootDir, Install, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = ExecutePackageScripts(filename, rootDir, Update, true)
|
||||
err = executePackageScripts(filename, rootDir, Update, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1552,7 +1552,7 @@ func GetAllPackageFiles(rootDir string, excludePackages ...string) (map[string][
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func RemovePackage(pkg string, verbose bool, rootDir string) error {
|
||||
func removePackage(pkg string, verbose bool, rootDir string) error {
|
||||
installedDir := path.Join(rootDir, "var/lib/bpm/installed/")
|
||||
pkgDir := path.Join(installedDir, pkg)
|
||||
pkgInfo := GetPackageInfo(pkg, rootDir)
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type TarballFileReader struct {
|
||||
type tarballFileReader struct {
|
||||
tarReader *tar.Reader
|
||||
file *os.File
|
||||
}
|
||||
|
||||
func ReadTarballContent(tarballPath, fileToExtract string) (*TarballFileReader, error) {
|
||||
func readTarballContent(tarballPath, fileToExtract string) (*tarballFileReader, error) {
|
||||
file, err := os.Open(tarballPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -32,7 +32,7 @@ func ReadTarballContent(tarballPath, fileToExtract string) (*TarballFileReader,
|
||||
return nil, errors.New("file to extract must be a regular file")
|
||||
}
|
||||
|
||||
return &TarballFileReader{
|
||||
return &tarballFileReader{
|
||||
tarReader: tr,
|
||||
file: file,
|
||||
}, nil
|
||||
|
@ -55,7 +55,7 @@ func stringSliceRemove(s []string, r string) []string {
|
||||
return s
|
||||
}
|
||||
|
||||
func UnsignedBytesToHumanReadable(b uint64) string {
|
||||
func unsignedBytesToHumanReadable(b uint64) string {
|
||||
bf := float64(b)
|
||||
for _, unit := range []string{"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"} {
|
||||
if math.Abs(bf) < 1024.0 {
|
||||
@ -66,7 +66,7 @@ func UnsignedBytesToHumanReadable(b uint64) string {
|
||||
return fmt.Sprintf("%.1fYiB", bf)
|
||||
}
|
||||
|
||||
func BytesToHumanReadable(b int64) string {
|
||||
func bytesToHumanReadable(b int64) string {
|
||||
bf := float64(b)
|
||||
for _, unit := range []string{"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"} {
|
||||
if math.Abs(bf) < 1024.0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user