MCPcopy Create free account
hub / github.com/an0nfunc/ALHP / parseFlagSection

Function parseFlagSection

utils.go:477–540  ·  view source on GitHub ↗
(section any, makepkgConf, march string)

Source from the content-addressed store, hash-verified

475 case dispResolve:
476 // a stale row still claims this pkgname; ask the archive who owns it
477 dbPkg, err = resolveOwner(ctx, pkg, march, repo, db)
478 if err != nil {
479 log.Warningf("[MOVE] cannot attribute %s, leaving in %s: %v", pkg.Name(), waitingDir, err)
480 kept[keptReasonUnresolved]++
481 continue
482 }
483 case dispDelete:
484 // nothing claims this pkgname: a genuine orphan
485 log.Warningf("[MOVE] deleting orphan package %s: %v", pkg.Name(), err)
486 discardPackage(file)
487 continue
488 case dispKeep:
489 // a db error or anything else we cannot classify
490 log.Warningf("[MOVE] cannot resolve %s, leaving in %s: %v", pkg.Name(), waitingDir, err)
491 kept[keptReasonUnresolved]++
492 continue
493 case dispPublish:
494 // unreachable: this arm only runs when err != nil
495 }
496 }
497
498 rawState, err := os.ReadFile(filepath.Join(conf.Basedir.Work, stateDir, dbPkg.Repository.String()+"-"+conf.Arch, dbPkg.Pkgbase))
499 if err != nil {
500 if stateDisposition(err) == dispDelete {
501 log.Warningf("[MOVE] state not found for %s->%s, dropping package: %v", fullRepo, dbPkg.Pkgbase, err)
502 discardPackage(file)
503 continue
504 }
505 log.Warningf("[MOVE] state unreadable for %s->%s, leaving in %s: %v",
506 fullRepo, dbPkg.Pkgbase, waitingDir, err)
507 kept[keptReasonState]++
508 continue
509 }
510
511 state, err := parseState(string(rawState))
512 if err != nil {
513 // unlike a missing state file, an unparsable one says nothing about
514 // whether the package still exists upstream, so it never deletes
515 log.Warningf("[MOVE] error parsing state file for %s->%s, leaving in %s: %v",
516 fullRepo, dbPkg.Pkgbase, waitingDir, err)
517 kept[keptReasonState]++
518 continue
519 }
520
521 // both files are copied before either is removed: a package published
522 // without its signature fails verification for everyone pulling it, and
523 // leaves a .sig behind that nothing globs
524 dest := filepath.Join(conf.Basedir.Repo, fullRepo, "os", conf.Arch, filepath.Base(file))
525 if err := Copy(file, dest); err != nil {
526 return err
527 }
528 if err := Copy(file+".sig", dest+".sig"); err != nil {
529 // roll the package back out of the repo dir. repoDBHK re-adds anything
530 // on disk the db does not list, and runs before the signature recheck
531 // that would catch it, so leaving it here publishes it unsigned
532 if rErr := os.Remove(dest); rErr != nil {
533 log.Errorf("[MOVE] unable to roll back unsigned %s, it will be published: %v", dest, rErr)
534 }

Callers 1

setupMakepkgFunction · 0.85

Calls 2

replaceStringsFromMapFunction · 0.85
parseFlagSubSectionFunction · 0.85

Tested by

no test coverage detected