MCPcopy Create free account
hub / github.com/celer-pkg/celer / doInstallFromPackage

Method doInstallFromPackage

configs/port_install.go:581–619  ·  view source on GitHub ↗
(destDir string)

Source from the content-addressed store, hash-verified

579}
580
581func (p Port) doInstallFromPackage(destDir string) error {
582 // Check and repair current port.
583 files, err := p.PackageFiles(
584 p.PackageDir,
585 p.ctx.Platform().GetName(),
586 p.ctx.Project().GetName(),
587 )
588 if err != nil {
589 return err
590 }
591
592 // Copy files from package to installed dir.
593 for _, file := range files {
594 if p.DevDep || p.HostDep {
595 file = strings.TrimPrefix(file, p.ctx.Platform().GetHostName()+"-dev"+string(os.PathSeparator))
596 } else {
597 file = strings.TrimPrefix(file, filepath.Join(p.ctx.LibraryFolder(), string(os.PathSeparator)))
598 }
599
600 src := filepath.Join(p.PackageDir, file)
601 dest := filepath.Join(destDir, file)
602
603 // Rename meta file as new name in meta folder.
604 if strings.HasSuffix(file, ".meta") {
605 dest = p.metaFile
606 }
607
608 // Ensure dest dir exists.
609 if err := fileio.MkdirAll(filepath.Dir(dest), os.ModePerm); err != nil {
610 return err
611 }
612
613 if err := fileio.CopyFile(src, dest); err != nil {
614 return fmt.Errorf("failed to copy file.\n%w", err)
615 }
616 }
617
618 return nil
619}
620
621func (p *Port) doInstallFromDevCache(options InstallOptions) (bool, error) {
622 // Try to install dependencies first.

Callers 5

InstallFromPackageMethod · 0.95
InstallFromPkgCacheMethod · 0.95
InstallFromDevCacheMethod · 0.95
InstallFromSourceMethod · 0.95
prepareTmpDepsMethod · 0.95

Calls 8

PackageFilesMethod · 0.95
MkdirAllFunction · 0.92
CopyFileFunction · 0.92
GetNameMethod · 0.65
PlatformMethod · 0.65
ProjectMethod · 0.65
GetHostNameMethod · 0.65
LibraryFolderMethod · 0.65

Tested by

no test coverage detected