Revert 8ceb61d
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2022-11-29 13:30:58 -08:00
parent 74051861bf
commit 554987325b
2 changed files with 27 additions and 28 deletions

View File

@ -164,30 +164,6 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
dec.LikeDistros = false
}
fn, ok := dec.GetFunc("version")
if ok {
log.Info("Executing version()").Send()
buf := &bytes.Buffer{}
err = fn(
ctx,
interp.Dir(filepath.Dir(script)),
interp.StdIO(os.Stdin, buf, os.Stderr),
)
if err != nil {
return nil, nil, err
}
newVer := strings.TrimSpace(buf.String())
err = setVersion(ctx, runner, newVer)
if err != nil {
return nil, nil, err
}
log.Info("Updating version").Str("new", newVer).Send()
}
var vars BuildVars
err = dec.DecodeVars(&vars)
if err != nil {
@ -277,6 +253,31 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
return nil, nil, err
}
fn, ok := dec.GetFunc("version")
if ok {
log.Info("Executing version()").Send()
buf := &bytes.Buffer{}
err = fn(
ctx,
interp.Dir(filepath.Dir(script)),
interp.StdIO(os.Stdin, buf, os.Stderr),
)
if err != nil {
return nil, nil, err
}
newVer := strings.TrimSpace(buf.String())
err = setVersion(ctx, runner, newVer)
if err != nil {
return nil, nil, err
}
vars.Version = newVer
log.Info("Updating version").Str("new", newVer).Send()
}
fn, ok = dec.GetFunc("prepare")
if ok {
log.Info("Executing prepare()").Send()

View File

@ -242,11 +242,11 @@ The rest of the scripts are available in all packages.
This section documents user-defined functions that can be added to build scripts. Any functions marked with `(*)` are required.
All functions except for `version()` are executed in the `$srcdir` directory
All functions are executed in the `$srcdir` directory
### version
The `version()` function is the first to run. It updates the `version` variable. This allows for automatically deriving the version from sources. This is most useful for git packages, which usually don't need to be changed, so their `version` variable stays the same.
The `version()` function updates the `version` variable. This allows for automatically deriving the version from sources. This is most useful for git packages, which usually don't need to be changed, so their `version` variable stays the same.
An example of using this for git:
@ -259,8 +259,6 @@ version() {
The AUR equivalent is the [`pkgver()` function](https://wiki.archlinux.org/title/VCS_package_guidelines#The_pkgver()_function)
This function does not run in `$srcdir` because it is executed before the source directory is even created. Instead, it runs in `$repodir`.
### prepare
The `prepare()` function is meant to prepare the sources for building and packaging. This is the function in which patches should be applied, for example, by the `patch` command, and where tools like `go generate` should be executed.