2024-02-18 17:52:09 -08:00
|
|
|
// Copyright (C) 2024 Jared Allard
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// Package updater contains the main code for determining if an update
|
|
|
|
// is available for the given ebuild.
|
|
|
|
package updater
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-05-10 12:42:43 -07:00
|
|
|
"github.com/jaredallard/overlay/.tools/internal/config/packages"
|
2024-02-18 17:52:09 -08:00
|
|
|
)
|
|
|
|
|
2024-05-10 12:42:43 -07:00
|
|
|
// GetLatestVersion returns the latest version available for the given
|
|
|
|
// package.
|
|
|
|
func GetLatestVersion(ce *packages.Package) (string, error) {
|
2024-02-18 17:52:09 -08:00
|
|
|
switch ce.Resolver {
|
2024-05-10 12:42:43 -07:00
|
|
|
case packages.GitResolver:
|
2024-02-18 17:52:09 -08:00
|
|
|
return getGitVersion(ce)
|
2024-05-10 12:42:43 -07:00
|
|
|
case packages.APTResolver:
|
2024-02-18 17:52:09 -08:00
|
|
|
return getAPTVersion(ce)
|
|
|
|
case "":
|
|
|
|
return "", fmt.Errorf("no resolver specified")
|
|
|
|
default:
|
|
|
|
return "", fmt.Errorf("unknown resolver: %s", ce.Resolver)
|
|
|
|
}
|
|
|
|
}
|