Skip to content

Commit

Permalink
fix: installation structs and config
Browse files Browse the repository at this point in the history
still had legacy pkgdl structs that the compiler caught
  • Loading branch information
dpastoor committed Nov 28, 2018
1 parent 5f68773 commit 6923ab3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
22 changes: 7 additions & 15 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ package cmd

import (
"fmt"
"os"
"path/filepath"
"time"

"github.com/dpastoor/rpackagemanager/configlib"
"github.com/dpastoor/rpackagemanager/cran"
"github.com/dpastoor/rpackagemanager/gpsr"
"github.com/dpastoor/rpackagemanager/rcmd"
"github.com/sajari/fuzzy"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -41,26 +36,23 @@ var installCmd = &cobra.Command{
}

func rInstall(cmd *cobra.Command, args []string) error {
ip := planInstall()
startTime := time.Now()
cdb, ip := planInstall()

var toDl []cran.PkgDl
// starting packages
for _, p := range ip.StartingPackages {
pkg, repo, _ := cdb.GetPackage(p)
toDl = append(toDl, cran.PkgDl{Package: pkg, Repo: repo})
pkg, cfg, _ := cdb.GetPackage(p)
toDl = append(toDl, cran.PkgDl{Package: pkg, Config: cfg})
}
// all other packages
for p := range ip.DepDb {
pkg, repo, _ := cdb.GetPackage(p)
toDl = append(toDl, cran.PkgDl{Package: pkg, Repo: repo})
pkg, cfg, _ := cdb.GetPackage(p)
toDl = append(toDl, cran.PkgDl{Package: pkg, Config: cfg})
}
// // want to download the packages and return the full path of any downloaded package
pc := rcmd.NewPackageCache(userCache(cfg.Cache), false)
pkgType := cran.Source
if cran.SupportsCranBinary() {
pkgType = cran.Binary
}
dl, err := cran.DownloadPackages(fs, toDl, pkgType, pc.BaseDir)
dl, err := cran.DownloadPackages(fs, toDl, pc.BaseDir)
if err != nil {
fmt.Println(err)
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {
RootCmd.AddCommand(planCmd)
}

func planInstall() gpsr.InstallPlan {
func planInstall() (*cran.PkgDb, gpsr.InstallPlan) {
startTime := time.Now()
var repos []cran.RepoURL
for _, r := range cfg.Repos {
Expand Down Expand Up @@ -138,5 +138,5 @@ func planInstall() gpsr.InstallPlan {
}
fmt.Println("total packages required:", len(ip.StartingPackages)+len(ip.DepDb))
fmt.Println(time.Since(startTime))
return ip
return cdb, ip
}
4 changes: 2 additions & 2 deletions rcmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func isInCache(
// if not in cache just pass back
meta := ir.Metadata
pkg := ir.Metadata.Metadata.Package
bpath := filepath.Join(pc.BaseDir, meta.Metadata.Repo.Name, "binary", binaryName(pkg.Package, pkg.Version))
bpath := filepath.Join(pc.BaseDir, meta.Metadata.Config.Repo.Name, "binary", binaryName(pkg.Package, pkg.Version))
lg.WithFields(logrus.Fields{
"path": bpath,
"package": pkg.Package,
Expand All @@ -220,7 +220,7 @@ func isInCache(
}
lg.WithField("package", pkg.Package).Trace("found in cache")
ir.Metadata.Path = bpath
ir.Metadata.Type = cran.Binary
ir.Metadata.Metadata.Config.Type = cran.Binary
return true, ir
}

Expand Down

0 comments on commit 6923ab3

Please sign in to comment.