forked from Plemya-x/ALR
		
	Merge branch 'Maks1mS-master'
# Conflicts: # pkg/build/build.go
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| /* | ||||
|  * ALR - Any Linux Repository | ||||
|  * Любая Linux репозитория | ||||
|  * Copyright (C) 2024 Евгений Храмов | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
| @@ -47,6 +46,9 @@ import ( | ||||
| 	_ "github.com/goreleaser/nfpm/v2/arch" | ||||
| 	_ "github.com/goreleaser/nfpm/v2/deb" | ||||
| 	_ "github.com/goreleaser/nfpm/v2/rpm" | ||||
| 	"mvdan.cc/sh/v3/expand" | ||||
| 	"mvdan.cc/sh/v3/interp" | ||||
| 	"mvdan.cc/sh/v3/syntax" | ||||
|  | ||||
| 	"github.com/goreleaser/nfpm/v2" | ||||
| 	"github.com/goreleaser/nfpm/v2/files" | ||||
| @@ -63,9 +65,6 @@ import ( | ||||
| 	"plemya-x.ru/alr/pkg/loggerctx" | ||||
| 	"plemya-x.ru/alr/pkg/manager" | ||||
| 	"plemya-x.ru/alr/pkg/repos" | ||||
| 	"mvdan.cc/sh/v3/expand" | ||||
| 	"mvdan.cc/sh/v3/interp" | ||||
| 	"mvdan.cc/sh/v3/syntax" | ||||
| ) | ||||
|  | ||||
| // Функция BuildPackage выполняет сборку скрипта по указанному пути. Возвращает два среза. | ||||
| @@ -171,7 +170,7 @@ func BuildPackage(ctx context.Context, opts types.BuildOpts) ([]string, []string | ||||
|  | ||||
| 	pkgFormat := getPkgFormat(opts.Manager) // Получаем формат пакета | ||||
|  | ||||
| 	pkgInfo, err := buildPkgMetadata(vars, dirs, pkgFormat, append(repoDeps, builtNames...)) // Собираем метаданные пакета | ||||
| 	pkgInfo, err := buildPkgMetadata(vars, dirs, pkgFormat, info, append(repoDeps, builtNames...)) // Собираем метаданные пакета | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| @@ -503,23 +502,18 @@ func executeFunctions(ctx context.Context, dec *decoder.Decoder, dirs types.Dire | ||||
| } | ||||
|  | ||||
| // Функция buildPkgMetadata создает метаданные для пакета, который будет собран. | ||||
| func buildPkgMetadata(vars *types.BuildVars, dirs types.Directories, pkgFormat string, deps []string) (*nfpm.Info, error) { | ||||
| 	pkgInfo := &nfpm.Info{ | ||||
| 		Name:        vars.Name, | ||||
| 		Description: vars.Description, | ||||
| 		Arch:        cpu.Arch(), | ||||
| 		Platform:    "linux", | ||||
| 		Version:     vars.Version, | ||||
| 		Release:     strconv.Itoa(vars.Release), | ||||
| 		Homepage:    vars.Homepage, | ||||
| 		License:     strings.Join(vars.Licenses, ", "), | ||||
| 		Maintainer:  vars.Maintainer, | ||||
| 		Overridables: nfpm.Overridables{ | ||||
| 			Conflicts: vars.Conflicts, | ||||
| 			Replaces:  vars.Replaces, | ||||
| 			Provides:  vars.Provides, | ||||
| 			Depends:   deps, | ||||
| 		}, | ||||
| func buildPkgMetadata(vars *types.BuildVars, dirs types.Directories, pkgFormat string, info *distro.OSRelease, deps []string) (*nfpm.Info, error) { | ||||
| 	pkgInfo := getBasePkgInfo(vars) | ||||
| 	pkgInfo.Description = vars.Description | ||||
| 	pkgInfo.Platform = "linux" | ||||
| 	pkgInfo.Homepage = vars.Homepage | ||||
| 	pkgInfo.License = strings.Join(vars.Licenses, ", ") | ||||
| 	pkgInfo.Maintainer = vars.Maintainer | ||||
| 	pkgInfo.Overridables = nfpm.Overridables{ | ||||
| 		Conflicts: vars.Conflicts, | ||||
| 		Replaces:  vars.Replaces, | ||||
| 		Provides:  vars.Provides, | ||||
| 		Depends:   deps, | ||||
| 	} | ||||
|  | ||||
| 	if pkgFormat == "apk" { | ||||
| @@ -529,6 +523,10 @@ func buildPkgMetadata(vars *types.BuildVars, dirs types.Directories, pkgFormat s | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| 	if pkgFormat == "rpm" && info.ID == "altlinux" { | ||||
| 		pkgInfo.Release = "alt" + pkgInfo.Release | ||||
| 	} | ||||
|  | ||||
| 	if vars.Epoch != 0 { | ||||
| 		pkgInfo.Epoch = strconv.FormatUint(uint64(vars.Epoch), 10) | ||||
| 	} | ||||
| @@ -665,16 +663,20 @@ func checkForBuiltPackage(mgr manager.Manager, vars *types.BuildVars, pkgFormat, | ||||
| 	return pkgPath, true, nil | ||||
| } | ||||
|  | ||||
| // Функция pkgFileName возвращает имя файла пакета, если оно было бы создано. | ||||
| // Это используется для проверки, был ли пакет уже собран. | ||||
| func pkgFileName(vars *types.BuildVars, pkgFormat string) (string, error) { | ||||
| 	pkgInfo := &nfpm.Info{ | ||||
| func getBasePkgInfo(vars *types.BuildVars) *nfpm.Info { | ||||
| 	return &nfpm.Info{ | ||||
| 		Name:    vars.Name, | ||||
| 		Arch:    cpu.Arch(), | ||||
| 		Version: vars.Version, | ||||
| 		Release: strconv.Itoa(vars.Release), | ||||
| 		Epoch:   strconv.FormatUint(uint64(vars.Epoch), 10), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // pkgFileName returns the filename of the package if it were to be built. | ||||
| // This is used to check if the package has already been built. | ||||
| func pkgFileName(vars *types.BuildVars, pkgFormat string) (string, error) { | ||||
| 	pkgInfo := getBasePkgInfo(vars) | ||||
|  | ||||
| 	packager, err := nfpm.Get(pkgFormat) | ||||
| 	if err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user