Skip to content

Commit

Permalink
restore install support for legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Oct 27, 2022
1 parent ba935cc commit 849e8f7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
9 changes: 5 additions & 4 deletions aur_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,23 @@ func (installer *Installer) getNewTargets(pkgdests map[string]string, name strin
return nil, false, &PkgDestNotInListError{name: name}
}

pkgFiles := make([]string, 0, 2)
pkgArchives := make([]string, 0, 2)

if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
return nil, false, &UnableToFindPkgDestError{name: name, pkgDest: pkgdest}
}

pkgFiles = append(pkgFiles, pkgdest)
pkgArchives = append(pkgArchives, pkgdest)

debugName := pkgdest + "-debug"
pkgdestDebug, ok := pkgdests[debugName]
if ok {
if _, errStat := os.Stat(pkgdestDebug); errStat == nil {
pkgFiles = append(pkgFiles, debugName)
pkgArchives = append(pkgArchives, debugName)
}
}

return pkgFiles, ok, nil
return pkgArchives, ok, nil
}

func (*Installer) installSyncPackages(ctx context.Context, cmdArgs *parser.Arguments,
Expand Down Expand Up @@ -243,5 +243,6 @@ func (*Installer) installSyncPackages(ctx context.Context, cmdArgs *parser.Argum
if errE := asexp(ctx, cmdArgs, syncExp.ToSlice()); errE != nil {
return errE
}

return errShow
}
42 changes: 28 additions & 14 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ func buildInstallPkgbuilds(
) error {
deps := make([]string, 0)
exp := make([]string, 0)
pkgArchives := make([]string, 0)
oldConfirm := settings.NoConfirm
settings.NoConfirm = true

Expand Down Expand Up @@ -629,17 +630,23 @@ func buildInstallPkgbuilds(
}

if !satisfied || !config.BatchInstall {
err = installPkgArchive(ctx, cmdArgs, append(deps, exp...))
errArchive := installPkgArchive(ctx, cmdArgs, pkgArchives)
errReason := setInstallReason(ctx, cmdArgs, deps, exp)

deps = make([]string, 0)
exp = make([]string, 0)
pkgArchives = make([]string, 0) // reset the pkgarchives

if err != nil {
if errArchive != nil || errReason != nil {
if i != 0 {
go config.Runtime.VCSStore.RemovePackage([]string{do.Aur[i-1].String()})
}

return err
if errArchive != nil {
return errArchive
}

return errReason
}
}

Expand Down Expand Up @@ -746,8 +753,8 @@ func buildInstallPkgbuilds(

for _, split := range base {
for suffix, optional := range map[string]bool{"": false, "-debug": true} {
deps, exp, errAdd = doAddTarget(dp, localNamesCache, remoteNamesCache,
cmdArgs, pkgdests, deps, exp, split.Name+suffix, optional)
deps, exp, pkgArchives, errAdd = doAddTarget(dp, localNamesCache, remoteNamesCache,
cmdArgs, pkgdests, deps, exp, split.Name+suffix, optional, pkgArchives)
if errAdd != nil {
return errAdd
}
Expand All @@ -768,8 +775,13 @@ func buildInstallPkgbuilds(
wg.Wait()
}

err = installPkgArchive(ctx, cmdArgs, append(deps, exp...))
if err != nil {
errArchive := installPkgArchive(ctx, cmdArgs, pkgArchives)
if errArchive != nil {
go config.Runtime.VCSStore.RemovePackage([]string{do.Aur[len(do.Aur)-1].String()})
}

errReason := setInstallReason(ctx, cmdArgs, deps, exp)
if errReason != nil {
go config.Runtime.VCSStore.RemovePackage([]string{do.Aur[len(do.Aur)-1].String()})
}

Expand Down Expand Up @@ -825,28 +837,30 @@ func setInstallReason(ctx context.Context, cmdArgs *parser.Arguments, deps, exps

func doAddTarget(dp *dep.Pool, localNamesCache, remoteNamesCache stringset.StringSet,
cmdArgs *parser.Arguments, pkgdests map[string]string,
deps, exp []string, name string, optional bool,
) (newDeps, newExp []string, err error) {
deps, exp []string, name string, optional bool, pkgArchives []string,
) (newDeps, newExp, newPkgArchives []string, err error) {
pkgdest, ok := pkgdests[name]
if !ok {
if optional {
return deps, exp, nil
return deps, exp, newPkgArchives, nil
}

return deps, exp, errors.New(gotext.Get("could not find PKGDEST for: %s", name))
return deps, exp, pkgArchives, errors.New(gotext.Get("could not find PKGDEST for: %s", name))
}

if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
if optional {
return deps, exp, nil
return deps, exp, pkgArchives, nil
}

return deps, exp, errors.New(
return deps, exp, pkgArchives, errors.New(
gotext.Get(
"the PKGDEST for %s is listed by makepkg but does not exist: %s",
name, pkgdest))
}

pkgArchives = append(pkgArchives, pkgdest)

switch {
case cmdArgs.ExistsArg("asdeps", "asdep"):
deps = append(deps, name)
Expand All @@ -858,5 +872,5 @@ func doAddTarget(dp *dep.Pool, localNamesCache, remoteNamesCache stringset.Strin
exp = append(exp, name)
}

return deps, exp, nil
return deps, exp, pkgArchives, nil
}

0 comments on commit 849e8f7

Please sign in to comment.