fix pkgrel buildno not increasing correctly if arch already set one
rename database enum typo build -> built
This commit is contained in:
parent
e3ce572dfa
commit
f66be19131
@ -109,7 +109,7 @@ const DefaultStatus = StatusUnknown
|
||||
const (
|
||||
StatusSkipped Status = "skipped"
|
||||
StatusFailed Status = "failed"
|
||||
StatusBuild Status = "build"
|
||||
StatusBuilt Status = "built"
|
||||
StatusQueued Status = "queued"
|
||||
StatusDelayed Status = "delayed"
|
||||
StatusBuilding Status = "building"
|
||||
@ -125,7 +125,7 @@ func (s Status) String() string {
|
||||
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
|
||||
func StatusValidator(s Status) error {
|
||||
switch s {
|
||||
case StatusSkipped, StatusFailed, StatusBuild, StatusQueued, StatusDelayed, StatusBuilding, StatusLatest, StatusSigning, StatusUnknown:
|
||||
case StatusSkipped, StatusFailed, StatusBuilt, StatusQueued, StatusDelayed, StatusBuilding, StatusLatest, StatusSigning, StatusUnknown:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("dbpackage: invalid enum value for status field: %q", s)
|
||||
|
@ -13,7 +13,7 @@ var (
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "pkgbase", Type: field.TypeString},
|
||||
{Name: "packages", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "status", Type: field.TypeEnum, Nullable: true, Enums: []string{"skipped", "failed", "build", "queued", "delayed", "building", "latest", "signing", "unknown"}, Default: "unknown"},
|
||||
{Name: "status", Type: field.TypeEnum, Nullable: true, Enums: []string{"skipped", "failed", "built", "queued", "delayed", "building", "latest", "signing", "unknown"}, Default: "unknown"},
|
||||
{Name: "skip_reason", Type: field.TypeString, Nullable: true},
|
||||
{Name: "repository", Type: field.TypeEnum, Enums: []string{"extra", "core", "multilib"}},
|
||||
{Name: "march", Type: field.TypeString},
|
||||
|
@ -15,7 +15,7 @@ func (DBPackage) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("pkgbase").NotEmpty().Immutable(),
|
||||
field.Strings("packages").Optional(),
|
||||
field.Enum("status").Values("skipped", "failed", "build", "queued", "delayed", "building",
|
||||
field.Enum("status").Values("skipped", "failed", "built", "queued", "delayed", "building",
|
||||
"latest", "signing", "unknown").Default("unknown").Optional(),
|
||||
field.String("skip_reason").Optional(),
|
||||
field.Enum("repository").Values("extra", "core", "multilib"),
|
||||
|
@ -215,7 +215,7 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) {
|
||||
|
||||
Rusage, ok := cmd.ProcessState.SysUsage().(*syscall.Rusage)
|
||||
if !ok {
|
||||
log.Panicf("Rusage is not of type *syscall.Rusage, are we running on unix-like?")
|
||||
log.Panicf("rusage is not of type *syscall.Rusage, are we running on unix-like?")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@ -226,13 +226,13 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) {
|
||||
if p.DBPackage.Lto != dbpackage.LtoAutoDisabled && p.DBPackage.Lto != dbpackage.LtoDisabled &&
|
||||
(reLdError.MatchString(out.String()) || reRustLTOError.MatchString(out.String())) {
|
||||
p.DBPackage.Update().SetStatus(dbpackage.StatusQueued).SetSkipReason("non-LTO rebuild").SetLto(dbpackage.LtoAutoDisabled).ExecX(ctx)
|
||||
return time.Since(start), errors.New("ld/lto-incomp error detected, LTO disabled")
|
||||
return time.Since(start), errors.New("ld/lto-incompatibility error detected, LTO disabled")
|
||||
}
|
||||
|
||||
if reDownloadError.MatchString(out.String()) || reDownloadError2.MatchString(out.String()) ||
|
||||
rePortError.MatchString(out.String()) || reSigError.MatchString(out.String()) {
|
||||
p.DBPackage.Update().SetStatus(dbpackage.StatusQueued).ExecX(ctx)
|
||||
return time.Since(start), errors.New("known builderror detected")
|
||||
return time.Since(start), errors.New("known build error detected")
|
||||
}
|
||||
|
||||
err = os.MkdirAll(filepath.Join(conf.Basedir.Repo, logDir, p.March), 0o755)
|
||||
@ -306,7 +306,7 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) {
|
||||
}
|
||||
|
||||
updatePkg := p.DBPackage.Update().
|
||||
SetStatus(dbpackage.StatusBuild).
|
||||
SetStatus(dbpackage.StatusBuilt).
|
||||
SetLto(dbpackage.LtoEnabled).
|
||||
SetBuildTimeStart(start).
|
||||
SetLastVersionBuild(p.Version).
|
||||
@ -407,7 +407,24 @@ func (p *ProtoPackage) increasePkgRel(buildNo int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
nStr := rePkgRel.ReplaceAllLiteralString(string(fStr), "pkgrel="+p.Srcinfo.Pkgrel+"."+strconv.Itoa(buildNo))
|
||||
// increase buildno if already existing
|
||||
var nStr string
|
||||
if strings.Contains(p.Srcinfo.Pkgrel, ".") {
|
||||
pkgRelSplit := strings.Split(p.Srcinfo.Pkgrel, ".")
|
||||
pkgRelBuildNo, err := strconv.Atoi(pkgRelSplit[len(pkgRelSplit)-1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nStr = rePkgRel.ReplaceAllLiteralString(string(fStr), "pkgrel="+pkgRelSplit[0]+"."+strconv.Itoa(buildNo+pkgRelBuildNo))
|
||||
versionSplit := strings.Split(p.Version, "-")
|
||||
versionSplit[len(versionSplit)-1] = pkgRelSplit[0] + "." + strconv.Itoa(buildNo+pkgRelBuildNo)
|
||||
p.Version = strings.Join(versionSplit, "-")
|
||||
} else {
|
||||
nStr = rePkgRel.ReplaceAllLiteralString(string(fStr), "pkgrel="+p.Srcinfo.Pkgrel+"."+strconv.Itoa(buildNo))
|
||||
p.Version += "." + strconv.Itoa(buildNo)
|
||||
}
|
||||
|
||||
_, err = f.Seek(0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -422,7 +439,6 @@ func (p *ProtoPackage) increasePkgRel(buildNo int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
p.Version += "." + strconv.Itoa(buildNo)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -684,7 +700,7 @@ func (p *ProtoPackage) exists() (bool, error) {
|
||||
return dbPkg, nil
|
||||
}
|
||||
|
||||
func (p *ProtoPackage) isMirrorLatest(h *alpm.Handle) (latest bool, foundPkg alpm.IPackage, version string, err error) {
|
||||
func (p *ProtoPackage) isMirrorLatest(h *alpm.Handle) (latest bool, foundPkg *alpm.Package, version string, err error) {
|
||||
dbs, err := h.SyncDBs()
|
||||
if err != nil {
|
||||
return false, nil, "", err
|
||||
@ -718,7 +734,12 @@ func (p *ProtoPackage) isMirrorLatest(h *alpm.Handle) (latest bool, foundPkg alp
|
||||
}
|
||||
|
||||
if alpm.VerCmp(svn2gitVer, pkg.Version()) > 0 {
|
||||
return false, pkg, svn2gitVer, nil
|
||||
switch v := pkg.(type) {
|
||||
case *alpm.Package:
|
||||
return false, v, svn2gitVer, nil
|
||||
default:
|
||||
return false, nil, "", fmt.Errorf("invalid package type: %T", pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,55 @@ package() {
|
||||
# vim:set sw=2 et:
|
||||
`
|
||||
|
||||
const PkgbuildTestWithPkgrelSub = `# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
|
||||
|
||||
pkgname=gnome-todo
|
||||
pkgver=41.0+r69+ga9a5b7cd
|
||||
pkgrel=1.1
|
||||
pkgdesc="Task manager for GNOME"
|
||||
url="https://wiki.gnome.org/Apps/Todo"
|
||||
arch=(x86_64)
|
||||
license=(GPL)
|
||||
depends=(evolution-data-server libpeas python gtk4 libportal-gtk4 libadwaita)
|
||||
makedepends=(gobject-introspection appstream-glib git meson yelp-tools)
|
||||
groups=(gnome-extra)
|
||||
_commit=a9a5b7cdde0244331d2d49220f04018be60c018e # master
|
||||
source=("git+https://gitlab.gnome.org/GNOME/gnome-todo.git#commit=$_commit")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd $pkgname
|
||||
git describe --tags | sed 's/^GNOME_TODO_//;s/_/./g;s/[^-]*-g/r&/;s/-/+/g'
|
||||
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd $pkgname
|
||||
}
|
||||
|
||||
build() {
|
||||
arch-meson $pkgname build
|
||||
meson compile -C build
|
||||
}
|
||||
|
||||
check() (
|
||||
glib-compile-schemas "${GSETTINGS_SCHEMA_DIR:=$PWD/$pkgname/data}"
|
||||
export GSETTINGS_SCHEMA_DIR
|
||||
|
||||
meson test -C build --print-errorlogs
|
||||
)
|
||||
|
||||
package() {
|
||||
meson install -C build --destdir "$pkgdir"
|
||||
}
|
||||
|
||||
# vim:set sw=2 et:
|
||||
`
|
||||
|
||||
func TestIncreasePkgRel(t *testing.T) { //nolint:paralleltest
|
||||
pkgbuild, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
t.Fatal("Unable to setup temp. PKGBUILD")
|
||||
t.Fatal("unable to setup temp. PKGBUILD")
|
||||
}
|
||||
defer func(name string) {
|
||||
_ = os.Remove(name)
|
||||
@ -62,7 +107,7 @@ func TestIncreasePkgRel(t *testing.T) { //nolint:paralleltest
|
||||
|
||||
_, err = pkgbuild.WriteString(PkgbuildTest)
|
||||
if err != nil {
|
||||
t.Fatal("Unable to write to temp. PKGBUILD")
|
||||
t.Fatal("unable to write to temp. PKGBUILD")
|
||||
}
|
||||
_ = pkgbuild.Close()
|
||||
|
||||
@ -95,3 +140,48 @@ func TestIncreasePkgRel(t *testing.T) { //nolint:paralleltest
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncreasePkgRelWithPkgSub(t *testing.T) { //nolint:paralleltest
|
||||
pkgbuild, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
t.Fatal("unable to setup temp. PKGBUILD")
|
||||
}
|
||||
defer func(name string) {
|
||||
_ = os.Remove(name)
|
||||
}(pkgbuild.Name())
|
||||
|
||||
_, err = pkgbuild.WriteString(PkgbuildTestWithPkgrelSub)
|
||||
if err != nil {
|
||||
t.Fatal("unable to write to temp. PKGBUILD")
|
||||
}
|
||||
_ = pkgbuild.Close()
|
||||
|
||||
buildPkg := &ProtoPackage{
|
||||
Pkgbase: "gnome-todo",
|
||||
Pkgbuild: pkgbuild.Name(),
|
||||
}
|
||||
|
||||
err = buildPkg.increasePkgRel(1)
|
||||
if err != nil {
|
||||
t.Logf("increasePkgRel: %v", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
versionSplit := strings.Split(buildPkg.Version, "-")
|
||||
if versionSplit[len(versionSplit)-1] != "1.2" {
|
||||
t.Logf("increasePkgRel: expected 1.2 pkgrel, got: %s", buildPkg.Version)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
buildPkg.Srcinfo = nil
|
||||
err = buildPkg.genSrcinfo()
|
||||
if err != nil {
|
||||
t.Logf("increasePkgRel: %v", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if buildPkg.Srcinfo.Pkgrel != "1.2" {
|
||||
t.Logf("increasePkgRel: expected 1.2 pkgrel, got: %s", buildPkg.Srcinfo.Pkgrel)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
4
utils.go
4
utils.go
@ -625,11 +625,11 @@ func Glob(pattern string) ([]string, error) {
|
||||
|
||||
func (globs Globs) Expand() ([]string, error) {
|
||||
var matches = []string{""}
|
||||
for _, glob := range globs {
|
||||
for _, g := range globs {
|
||||
var hits []string
|
||||
var hitMap = map[string]bool{}
|
||||
for _, match := range matches {
|
||||
paths, err := filepath.Glob(match + glob)
|
||||
paths, err := filepath.Glob(match + g)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user