From be276f9eadaf1aab0fdb3e645abf3d5159a7bbcd Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sat, 27 Nov 2021 01:28:42 +0100 Subject: [PATCH] increase our own build-version if rebuild --- ent/dbpackage.go | 12 +++- ent/dbpackage/dbpackage.go | 3 + ent/dbpackage/where.go | 132 +++++++++++++++++++++++++++++++++++++ ent/dbpackage_create.go | 22 +++++++ ent/dbpackage_update.go | 66 +++++++++++++++++++ ent/migrate/schema.go | 1 + ent/mutation.go | 115 ++++++++++++++++++++++++++------ ent/schema/dbpackage.go | 1 + main.go | 22 +++++-- utils.go | 6 +- 10 files changed, 350 insertions(+), 30 deletions(-) diff --git a/ent/dbpackage.go b/ent/dbpackage.go index 7c09de0..907f4fb 100644 --- a/ent/dbpackage.go +++ b/ent/dbpackage.go @@ -43,6 +43,8 @@ type DbPackage struct { Hash string `json:"hash,omitempty"` // Lto holds the value of the "lto" field. Lto dbpackage.Lto `json:"lto,omitempty"` + // LastVersionBuild holds the value of the "last_version_build" field. + LastVersionBuild string `json:"last_version_build,omitempty"` } // scanValues returns the types for scanning values from sql.Rows. @@ -54,7 +56,7 @@ func (*DbPackage) scanValues(columns []string) ([]interface{}, error) { values[i] = new([]byte) case dbpackage.FieldID: values[i] = new(sql.NullInt64) - case dbpackage.FieldPkgbase, dbpackage.FieldStatus, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion, dbpackage.FieldHash, dbpackage.FieldLto: + case dbpackage.FieldPkgbase, dbpackage.FieldStatus, dbpackage.FieldSkipReason, dbpackage.FieldRepository, dbpackage.FieldMarch, dbpackage.FieldVersion, dbpackage.FieldRepoVersion, dbpackage.FieldHash, dbpackage.FieldLto, dbpackage.FieldLastVersionBuild: values[i] = new(sql.NullString) case dbpackage.FieldBuildTimeStart, dbpackage.FieldBuildTimeEnd, dbpackage.FieldUpdated: values[i] = new(sql.NullTime) @@ -159,6 +161,12 @@ func (dp *DbPackage) assignValues(columns []string, values []interface{}) error } else if value.Valid { dp.Lto = dbpackage.Lto(value.String) } + case dbpackage.FieldLastVersionBuild: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field last_version_build", values[i]) + } else if value.Valid { + dp.LastVersionBuild = value.String + } } } return nil @@ -213,6 +221,8 @@ func (dp *DbPackage) String() string { builder.WriteString(dp.Hash) builder.WriteString(", lto=") builder.WriteString(fmt.Sprintf("%v", dp.Lto)) + builder.WriteString(", last_version_build=") + builder.WriteString(dp.LastVersionBuild) builder.WriteByte(')') return builder.String() } diff --git a/ent/dbpackage/dbpackage.go b/ent/dbpackage/dbpackage.go index cfeeecf..26e8c69 100644 --- a/ent/dbpackage/dbpackage.go +++ b/ent/dbpackage/dbpackage.go @@ -37,6 +37,8 @@ const ( FieldHash = "hash" // FieldLto holds the string denoting the lto field in the database. FieldLto = "lto" + // FieldLastVersionBuild holds the string denoting the last_version_build field in the database. + FieldLastVersionBuild = "last_version_build" // Table holds the table name of the dbpackage in the database. Table = "db_packages" ) @@ -57,6 +59,7 @@ var Columns = []string{ FieldUpdated, FieldHash, FieldLto, + FieldLastVersionBuild, } // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/ent/dbpackage/where.go b/ent/dbpackage/where.go index a961733..9ac5b34 100644 --- a/ent/dbpackage/where.go +++ b/ent/dbpackage/where.go @@ -155,6 +155,13 @@ func Hash(v string) predicate.DbPackage { }) } +// LastVersionBuild applies equality check predicate on the "last_version_build" field. It's identical to LastVersionBuildEQ. +func LastVersionBuild(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLastVersionBuild), v)) + }) +} + // PkgbaseEQ applies the EQ predicate on the "pkgbase" field. func PkgbaseEQ(v string) predicate.DbPackage { return predicate.DbPackage(func(s *sql.Selector) { @@ -1333,6 +1340,131 @@ func LtoNotNil() predicate.DbPackage { }) } +// LastVersionBuildEQ applies the EQ predicate on the "last_version_build" field. +func LastVersionBuildEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildNEQ applies the NEQ predicate on the "last_version_build" field. +func LastVersionBuildNEQ(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildIn applies the In predicate on the "last_version_build" field. +func LastVersionBuildIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldLastVersionBuild), v...)) + }) +} + +// LastVersionBuildNotIn applies the NotIn predicate on the "last_version_build" field. +func LastVersionBuildNotIn(vs ...string) predicate.DbPackage { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.DbPackage(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldLastVersionBuild), v...)) + }) +} + +// LastVersionBuildGT applies the GT predicate on the "last_version_build" field. +func LastVersionBuildGT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildGTE applies the GTE predicate on the "last_version_build" field. +func LastVersionBuildGTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildLT applies the LT predicate on the "last_version_build" field. +func LastVersionBuildLT(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildLTE applies the LTE predicate on the "last_version_build" field. +func LastVersionBuildLTE(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildContains applies the Contains predicate on the "last_version_build" field. +func LastVersionBuildContains(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildHasPrefix applies the HasPrefix predicate on the "last_version_build" field. +func LastVersionBuildHasPrefix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildHasSuffix applies the HasSuffix predicate on the "last_version_build" field. +func LastVersionBuildHasSuffix(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildIsNil applies the IsNil predicate on the "last_version_build" field. +func LastVersionBuildIsNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldLastVersionBuild))) + }) +} + +// LastVersionBuildNotNil applies the NotNil predicate on the "last_version_build" field. +func LastVersionBuildNotNil() predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldLastVersionBuild))) + }) +} + +// LastVersionBuildEqualFold applies the EqualFold predicate on the "last_version_build" field. +func LastVersionBuildEqualFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldLastVersionBuild), v)) + }) +} + +// LastVersionBuildContainsFold applies the ContainsFold predicate on the "last_version_build" field. +func LastVersionBuildContainsFold(v string) predicate.DbPackage { + return predicate.DbPackage(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldLastVersionBuild), v)) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.DbPackage) predicate.DbPackage { return predicate.DbPackage(func(s *sql.Selector) { diff --git a/ent/dbpackage_create.go b/ent/dbpackage_create.go index 66134d3..278b389 100644 --- a/ent/dbpackage_create.go +++ b/ent/dbpackage_create.go @@ -170,6 +170,20 @@ func (dpc *DbPackageCreate) SetNillableLto(d *dbpackage.Lto) *DbPackageCreate { return dpc } +// SetLastVersionBuild sets the "last_version_build" field. +func (dpc *DbPackageCreate) SetLastVersionBuild(s string) *DbPackageCreate { + dpc.mutation.SetLastVersionBuild(s) + return dpc +} + +// SetNillableLastVersionBuild sets the "last_version_build" field if the given value is not nil. +func (dpc *DbPackageCreate) SetNillableLastVersionBuild(s *string) *DbPackageCreate { + if s != nil { + dpc.SetLastVersionBuild(*s) + } + return dpc +} + // Mutation returns the DbPackageMutation object of the builder. func (dpc *DbPackageCreate) Mutation() *DbPackageMutation { return dpc.mutation @@ -418,6 +432,14 @@ func (dpc *DbPackageCreate) createSpec() (*DbPackage, *sqlgraph.CreateSpec) { }) _node.Lto = value } + if value, ok := dpc.mutation.LastVersionBuild(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldLastVersionBuild, + }) + _node.LastVersionBuild = value + } return _node, _spec } diff --git a/ent/dbpackage_update.go b/ent/dbpackage_update.go index 5aacb03..874e0d1 100644 --- a/ent/dbpackage_update.go +++ b/ent/dbpackage_update.go @@ -231,6 +231,26 @@ func (dpu *DbPackageUpdate) ClearLto() *DbPackageUpdate { return dpu } +// SetLastVersionBuild sets the "last_version_build" field. +func (dpu *DbPackageUpdate) SetLastVersionBuild(s string) *DbPackageUpdate { + dpu.mutation.SetLastVersionBuild(s) + return dpu +} + +// SetNillableLastVersionBuild sets the "last_version_build" field if the given value is not nil. +func (dpu *DbPackageUpdate) SetNillableLastVersionBuild(s *string) *DbPackageUpdate { + if s != nil { + dpu.SetLastVersionBuild(*s) + } + return dpu +} + +// ClearLastVersionBuild clears the value of the "last_version_build" field. +func (dpu *DbPackageUpdate) ClearLastVersionBuild() *DbPackageUpdate { + dpu.mutation.ClearLastVersionBuild() + return dpu +} + // Mutation returns the DbPackageMutation object of the builder. func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation { return dpu.mutation @@ -483,6 +503,19 @@ func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: dbpackage.FieldLto, }) } + if value, ok := dpu.mutation.LastVersionBuild(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldLastVersionBuild, + }) + } + if dpu.mutation.LastVersionBuildCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldLastVersionBuild, + }) + } if n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{dbpackage.Label} @@ -706,6 +739,26 @@ func (dpuo *DbPackageUpdateOne) ClearLto() *DbPackageUpdateOne { return dpuo } +// SetLastVersionBuild sets the "last_version_build" field. +func (dpuo *DbPackageUpdateOne) SetLastVersionBuild(s string) *DbPackageUpdateOne { + dpuo.mutation.SetLastVersionBuild(s) + return dpuo +} + +// SetNillableLastVersionBuild sets the "last_version_build" field if the given value is not nil. +func (dpuo *DbPackageUpdateOne) SetNillableLastVersionBuild(s *string) *DbPackageUpdateOne { + if s != nil { + dpuo.SetLastVersionBuild(*s) + } + return dpuo +} + +// ClearLastVersionBuild clears the value of the "last_version_build" field. +func (dpuo *DbPackageUpdateOne) ClearLastVersionBuild() *DbPackageUpdateOne { + dpuo.mutation.ClearLastVersionBuild() + return dpuo +} + // Mutation returns the DbPackageMutation object of the builder. func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation { return dpuo.mutation @@ -982,6 +1035,19 @@ func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage, Column: dbpackage.FieldLto, }) } + if value, ok := dpuo.mutation.LastVersionBuild(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: dbpackage.FieldLastVersionBuild, + }) + } + if dpuo.mutation.LastVersionBuildCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: dbpackage.FieldLastVersionBuild, + }) + } _node = &DbPackage{config: dpuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 0a2de87..b2c6de6 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -24,6 +24,7 @@ var ( {Name: "updated", Type: field.TypeTime, Nullable: true}, {Name: "hash", Type: field.TypeString, Nullable: true}, {Name: "lto", Type: field.TypeEnum, Nullable: true, Enums: []string{"enabled", "unknown", "disabled", "auto_disabled"}, Default: "unknown"}, + {Name: "last_version_build", Type: field.TypeString, Nullable: true}, } // DbPackagesTable holds the schema information for the "db_packages" table. DbPackagesTable = &schema.Table{ diff --git a/ent/mutation.go b/ent/mutation.go index 35f7f2e..fc56ccb 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -29,26 +29,27 @@ const ( // DbPackageMutation represents an operation that mutates the DbPackage nodes in the graph. type DbPackageMutation struct { config - op Op - typ string - id *int - pkgbase *string - packages *[]string - status *dbpackage.Status - skip_reason *string - repository *dbpackage.Repository - march *string - version *string - repo_version *string - build_time_start *time.Time - build_time_end *time.Time - updated *time.Time - hash *string - lto *dbpackage.Lto - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*DbPackage, error) - predicates []predicate.DbPackage + op Op + typ string + id *int + pkgbase *string + packages *[]string + status *dbpackage.Status + skip_reason *string + repository *dbpackage.Repository + march *string + version *string + repo_version *string + build_time_start *time.Time + build_time_end *time.Time + updated *time.Time + hash *string + lto *dbpackage.Lto + last_version_build *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*DbPackage, error) + predicates []predicate.DbPackage } var _ ent.Mutation = (*DbPackageMutation)(nil) @@ -728,6 +729,55 @@ func (m *DbPackageMutation) ResetLto() { delete(m.clearedFields, dbpackage.FieldLto) } +// SetLastVersionBuild sets the "last_version_build" field. +func (m *DbPackageMutation) SetLastVersionBuild(s string) { + m.last_version_build = &s +} + +// LastVersionBuild returns the value of the "last_version_build" field in the mutation. +func (m *DbPackageMutation) LastVersionBuild() (r string, exists bool) { + v := m.last_version_build + if v == nil { + return + } + return *v, true +} + +// OldLastVersionBuild returns the old "last_version_build" field's value of the DbPackage entity. +// If the DbPackage object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DbPackageMutation) OldLastVersionBuild(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldLastVersionBuild is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldLastVersionBuild requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastVersionBuild: %w", err) + } + return oldValue.LastVersionBuild, nil +} + +// ClearLastVersionBuild clears the value of the "last_version_build" field. +func (m *DbPackageMutation) ClearLastVersionBuild() { + m.last_version_build = nil + m.clearedFields[dbpackage.FieldLastVersionBuild] = struct{}{} +} + +// LastVersionBuildCleared returns if the "last_version_build" field was cleared in this mutation. +func (m *DbPackageMutation) LastVersionBuildCleared() bool { + _, ok := m.clearedFields[dbpackage.FieldLastVersionBuild] + return ok +} + +// ResetLastVersionBuild resets all changes to the "last_version_build" field. +func (m *DbPackageMutation) ResetLastVersionBuild() { + m.last_version_build = nil + delete(m.clearedFields, dbpackage.FieldLastVersionBuild) +} + // Where appends a list predicates to the DbPackageMutation builder. func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) { m.predicates = append(m.predicates, ps...) @@ -747,7 +797,7 @@ func (m *DbPackageMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *DbPackageMutation) Fields() []string { - fields := make([]string, 0, 13) + fields := make([]string, 0, 14) if m.pkgbase != nil { fields = append(fields, dbpackage.FieldPkgbase) } @@ -787,6 +837,9 @@ func (m *DbPackageMutation) Fields() []string { if m.lto != nil { fields = append(fields, dbpackage.FieldLto) } + if m.last_version_build != nil { + fields = append(fields, dbpackage.FieldLastVersionBuild) + } return fields } @@ -821,6 +874,8 @@ func (m *DbPackageMutation) Field(name string) (ent.Value, bool) { return m.Hash() case dbpackage.FieldLto: return m.Lto() + case dbpackage.FieldLastVersionBuild: + return m.LastVersionBuild() } return nil, false } @@ -856,6 +911,8 @@ func (m *DbPackageMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldHash(ctx) case dbpackage.FieldLto: return m.OldLto(ctx) + case dbpackage.FieldLastVersionBuild: + return m.OldLastVersionBuild(ctx) } return nil, fmt.Errorf("unknown DbPackage field %s", name) } @@ -956,6 +1013,13 @@ func (m *DbPackageMutation) SetField(name string, value ent.Value) error { } m.SetLto(v) return nil + case dbpackage.FieldLastVersionBuild: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastVersionBuild(v) + return nil } return fmt.Errorf("unknown DbPackage field %s", name) } @@ -1016,6 +1080,9 @@ func (m *DbPackageMutation) ClearedFields() []string { if m.FieldCleared(dbpackage.FieldLto) { fields = append(fields, dbpackage.FieldLto) } + if m.FieldCleared(dbpackage.FieldLastVersionBuild) { + fields = append(fields, dbpackage.FieldLastVersionBuild) + } return fields } @@ -1060,6 +1127,9 @@ func (m *DbPackageMutation) ClearField(name string) error { case dbpackage.FieldLto: m.ClearLto() return nil + case dbpackage.FieldLastVersionBuild: + m.ClearLastVersionBuild() + return nil } return fmt.Errorf("unknown DbPackage nullable field %s", name) } @@ -1107,6 +1177,9 @@ func (m *DbPackageMutation) ResetField(name string) error { case dbpackage.FieldLto: m.ResetLto() return nil + case dbpackage.FieldLastVersionBuild: + m.ResetLastVersionBuild() + return nil } return fmt.Errorf("unknown DbPackage field %s", name) } diff --git a/ent/schema/dbpackage.go b/ent/schema/dbpackage.go index 788ad32..be7d8f1 100644 --- a/ent/schema/dbpackage.go +++ b/ent/schema/dbpackage.go @@ -26,6 +26,7 @@ func (DbPackage) Fields() []ent.Field { field.Time("updated").Optional(), field.String("hash").Optional(), field.Enum("lto").Values("enabled", "unknown", "disabled", "auto_disabled").Default("unknown").Optional(), + field.String("last_version_build").Optional(), } } diff --git a/main.go b/main.go index d8f7075..578bfc4 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,19 @@ func (b *BuildManager) buildWorker(id int) { log.Warningf("[%s/%s] Failed to import pgp keys: %v", pkg.FullRepo, pkg.Pkgbase, err) } - err = pkg.increasePkgRel() + buildNo := 1 + if pkg.DbPackage.LastVersionBuild == pkg.Version { + versionSlice := strings.Split(pkg.DbPackage.LastVersionBuild, ".") + buildNo, err = strconv.Atoi(versionSlice[len(versionSlice)-1]) + if err != nil { + log.Errorf("[%s/%s] Failed to read build from pkgrel: %v", pkg.FullRepo, pkg.Pkgbase, err) + b.buildWG.Done() + continue + } + buildNo++ + } + + err = pkg.increasePkgRel(buildNo) if err != nil { log.Errorf("[%s/%s] Failed to increase pkgrel: %v", pkg.FullRepo, pkg.Pkgbase, err) b.buildWG.Done() @@ -93,7 +105,7 @@ func (b *BuildManager) buildWorker(id int) { } cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(pkg.Pkgbuild)+"&&makechrootpkg -c -D "+conf.Basedir.Makepkg+" -l worker-"+strconv.Itoa(id)+" -r "+conf.Basedir.Chroot+" -- "+ - "--config "+filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf(makepkgFile, pkg.March))) + "-m --noprogressbar --config "+filepath.Join(conf.Basedir.Makepkg, fmt.Sprintf(makepkgFile, pkg.March))) var out bytes.Buffer cmd.Stdout = &out cmd.Stderr = &out @@ -187,12 +199,12 @@ func (b *BuildManager) buildWorker(id int) { } if pkg.DbPackage.Lto != dbpackage.LtoDisabled && pkg.DbPackage.Lto != dbpackage.LtoAutoDisabled { - pkg.DbPackage.Update().SetStatus(dbpackage.StatusBuild).SetLto(dbpackage.LtoEnabled).SetBuildTimeStart(start).SetBuildTimeEnd(time.Now().UTC()).ExecX(context.Background()) + pkg.DbPackage.Update().SetStatus(dbpackage.StatusBuild).SetLto(dbpackage.LtoEnabled).SetBuildTimeStart(start).SetLastVersionBuild(pkg.Version).SetBuildTimeEnd(time.Now().UTC()).ExecX(context.Background()) } else { - pkg.DbPackage.Update().SetStatus(dbpackage.StatusBuild).SetBuildTimeStart(start).SetBuildTimeEnd(time.Now().UTC()).ExecX(context.Background()) + pkg.DbPackage.Update().SetStatus(dbpackage.StatusBuild).SetBuildTimeStart(start).SetBuildTimeEnd(time.Now().UTC()).SetLastVersionBuild(pkg.Version).ExecX(context.Background()) } - log.Infof("[%s/%s] Build successful (%s)", pkg.FullRepo, pkg.Pkgbase, time.Now().Sub(start)) + log.Infof("[%s/%s/%s] Build successful (%s)", pkg.FullRepo, pkg.Pkgbase, pkg.Version, time.Since(start)) b.repoAdd[pkg.FullRepo] <- pkg gitClean(pkg) diff --git a/utils.go b/utils.go index 698340d..1a63629 100644 --- a/utils.go +++ b/utils.go @@ -193,7 +193,7 @@ func gitClean(pkg *BuildPackage) { } } -func (p *BuildPackage) increasePkgRel() error { +func (p *BuildPackage) increasePkgRel(buildNo int) error { f, err := os.OpenFile(p.Pkgbuild, os.O_RDWR, 0644) if err != nil { return err @@ -211,7 +211,7 @@ func (p *BuildPackage) increasePkgRel() error { return err } - nStr := rePkgRel.ReplaceAllLiteralString(string(fStr), "pkgrel="+p.Srcinfo.Pkgrel+".1") + nStr := rePkgRel.ReplaceAllLiteralString(string(fStr), "pkgrel="+p.Srcinfo.Pkgrel+"."+strconv.Itoa(buildNo)) _, err = f.Seek(0, 0) if err != nil { return err @@ -226,7 +226,7 @@ func (p *BuildPackage) increasePkgRel() error { return err } - p.Version += ".1" + p.Version += "." + strconv.Itoa(buildNo) return nil }