1
0
forked from ALHP/ALHP.GO

increase our own build-version if rebuild

This commit is contained in:
2021-11-27 01:28:42 +01:00
parent 1bff197ce9
commit be276f9ead
10 changed files with 350 additions and 30 deletions

View File

@@ -43,6 +43,8 @@ type DbPackage struct {
Hash string `json:"hash,omitempty"` Hash string `json:"hash,omitempty"`
// Lto holds the value of the "lto" field. // Lto holds the value of the "lto" field.
Lto dbpackage.Lto `json:"lto,omitempty"` 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. // 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) values[i] = new([]byte)
case dbpackage.FieldID: case dbpackage.FieldID:
values[i] = new(sql.NullInt64) 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) values[i] = new(sql.NullString)
case dbpackage.FieldBuildTimeStart, dbpackage.FieldBuildTimeEnd, dbpackage.FieldUpdated: case dbpackage.FieldBuildTimeStart, dbpackage.FieldBuildTimeEnd, dbpackage.FieldUpdated:
values[i] = new(sql.NullTime) values[i] = new(sql.NullTime)
@@ -159,6 +161,12 @@ func (dp *DbPackage) assignValues(columns []string, values []interface{}) error
} else if value.Valid { } else if value.Valid {
dp.Lto = dbpackage.Lto(value.String) 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 return nil
@@ -213,6 +221,8 @@ func (dp *DbPackage) String() string {
builder.WriteString(dp.Hash) builder.WriteString(dp.Hash)
builder.WriteString(", lto=") builder.WriteString(", lto=")
builder.WriteString(fmt.Sprintf("%v", dp.Lto)) builder.WriteString(fmt.Sprintf("%v", dp.Lto))
builder.WriteString(", last_version_build=")
builder.WriteString(dp.LastVersionBuild)
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -37,6 +37,8 @@ const (
FieldHash = "hash" FieldHash = "hash"
// FieldLto holds the string denoting the lto field in the database. // FieldLto holds the string denoting the lto field in the database.
FieldLto = "lto" 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 holds the table name of the dbpackage in the database.
Table = "db_packages" Table = "db_packages"
) )
@@ -57,6 +59,7 @@ var Columns = []string{
FieldUpdated, FieldUpdated,
FieldHash, FieldHash,
FieldLto, FieldLto,
FieldLastVersionBuild,
} }
// ValidColumn reports if the column name is valid (part of the table columns). // ValidColumn reports if the column name is valid (part of the table columns).

View File

@@ -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. // PkgbaseEQ applies the EQ predicate on the "pkgbase" field.
func PkgbaseEQ(v string) predicate.DbPackage { func PkgbaseEQ(v string) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) { 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. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.DbPackage) predicate.DbPackage { func And(predicates ...predicate.DbPackage) predicate.DbPackage {
return predicate.DbPackage(func(s *sql.Selector) { return predicate.DbPackage(func(s *sql.Selector) {

View File

@@ -170,6 +170,20 @@ func (dpc *DbPackageCreate) SetNillableLto(d *dbpackage.Lto) *DbPackageCreate {
return dpc 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. // Mutation returns the DbPackageMutation object of the builder.
func (dpc *DbPackageCreate) Mutation() *DbPackageMutation { func (dpc *DbPackageCreate) Mutation() *DbPackageMutation {
return dpc.mutation return dpc.mutation
@@ -418,6 +432,14 @@ func (dpc *DbPackageCreate) createSpec() (*DbPackage, *sqlgraph.CreateSpec) {
}) })
_node.Lto = value _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 return _node, _spec
} }

View File

@@ -231,6 +231,26 @@ func (dpu *DbPackageUpdate) ClearLto() *DbPackageUpdate {
return dpu 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. // Mutation returns the DbPackageMutation object of the builder.
func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation { func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation {
return dpu.mutation return dpu.mutation
@@ -483,6 +503,19 @@ func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) {
Column: dbpackage.FieldLto, 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 n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{dbpackage.Label} err = &NotFoundError{dbpackage.Label}
@@ -706,6 +739,26 @@ func (dpuo *DbPackageUpdateOne) ClearLto() *DbPackageUpdateOne {
return dpuo 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. // Mutation returns the DbPackageMutation object of the builder.
func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation { func (dpuo *DbPackageUpdateOne) Mutation() *DbPackageMutation {
return dpuo.mutation return dpuo.mutation
@@ -982,6 +1035,19 @@ func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage,
Column: dbpackage.FieldLto, 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} _node = &DbPackage{config: dpuo.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _spec.ScanValues = _node.scanValues

View File

@@ -24,6 +24,7 @@ var (
{Name: "updated", Type: field.TypeTime, Nullable: true}, {Name: "updated", Type: field.TypeTime, Nullable: true},
{Name: "hash", Type: field.TypeString, 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: "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 holds the schema information for the "db_packages" table.
DbPackagesTable = &schema.Table{ DbPackagesTable = &schema.Table{

View File

@@ -29,26 +29,27 @@ const (
// DbPackageMutation represents an operation that mutates the DbPackage nodes in the graph. // DbPackageMutation represents an operation that mutates the DbPackage nodes in the graph.
type DbPackageMutation struct { type DbPackageMutation struct {
config config
op Op op Op
typ string typ string
id *int id *int
pkgbase *string pkgbase *string
packages *[]string packages *[]string
status *dbpackage.Status status *dbpackage.Status
skip_reason *string skip_reason *string
repository *dbpackage.Repository repository *dbpackage.Repository
march *string march *string
version *string version *string
repo_version *string repo_version *string
build_time_start *time.Time build_time_start *time.Time
build_time_end *time.Time build_time_end *time.Time
updated *time.Time updated *time.Time
hash *string hash *string
lto *dbpackage.Lto lto *dbpackage.Lto
clearedFields map[string]struct{} last_version_build *string
done bool clearedFields map[string]struct{}
oldValue func(context.Context) (*DbPackage, error) done bool
predicates []predicate.DbPackage oldValue func(context.Context) (*DbPackage, error)
predicates []predicate.DbPackage
} }
var _ ent.Mutation = (*DbPackageMutation)(nil) var _ ent.Mutation = (*DbPackageMutation)(nil)
@@ -728,6 +729,55 @@ func (m *DbPackageMutation) ResetLto() {
delete(m.clearedFields, dbpackage.FieldLto) 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. // Where appends a list predicates to the DbPackageMutation builder.
func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) { func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) {
m.predicates = append(m.predicates, ps...) 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 // order to get all numeric fields that were incremented/decremented, call
// AddedFields(). // AddedFields().
func (m *DbPackageMutation) Fields() []string { func (m *DbPackageMutation) Fields() []string {
fields := make([]string, 0, 13) fields := make([]string, 0, 14)
if m.pkgbase != nil { if m.pkgbase != nil {
fields = append(fields, dbpackage.FieldPkgbase) fields = append(fields, dbpackage.FieldPkgbase)
} }
@@ -787,6 +837,9 @@ func (m *DbPackageMutation) Fields() []string {
if m.lto != nil { if m.lto != nil {
fields = append(fields, dbpackage.FieldLto) fields = append(fields, dbpackage.FieldLto)
} }
if m.last_version_build != nil {
fields = append(fields, dbpackage.FieldLastVersionBuild)
}
return fields return fields
} }
@@ -821,6 +874,8 @@ func (m *DbPackageMutation) Field(name string) (ent.Value, bool) {
return m.Hash() return m.Hash()
case dbpackage.FieldLto: case dbpackage.FieldLto:
return m.Lto() return m.Lto()
case dbpackage.FieldLastVersionBuild:
return m.LastVersionBuild()
} }
return nil, false return nil, false
} }
@@ -856,6 +911,8 @@ func (m *DbPackageMutation) OldField(ctx context.Context, name string) (ent.Valu
return m.OldHash(ctx) return m.OldHash(ctx)
case dbpackage.FieldLto: case dbpackage.FieldLto:
return m.OldLto(ctx) return m.OldLto(ctx)
case dbpackage.FieldLastVersionBuild:
return m.OldLastVersionBuild(ctx)
} }
return nil, fmt.Errorf("unknown DbPackage field %s", name) 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) m.SetLto(v)
return nil 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) return fmt.Errorf("unknown DbPackage field %s", name)
} }
@@ -1016,6 +1080,9 @@ func (m *DbPackageMutation) ClearedFields() []string {
if m.FieldCleared(dbpackage.FieldLto) { if m.FieldCleared(dbpackage.FieldLto) {
fields = append(fields, dbpackage.FieldLto) fields = append(fields, dbpackage.FieldLto)
} }
if m.FieldCleared(dbpackage.FieldLastVersionBuild) {
fields = append(fields, dbpackage.FieldLastVersionBuild)
}
return fields return fields
} }
@@ -1060,6 +1127,9 @@ func (m *DbPackageMutation) ClearField(name string) error {
case dbpackage.FieldLto: case dbpackage.FieldLto:
m.ClearLto() m.ClearLto()
return nil return nil
case dbpackage.FieldLastVersionBuild:
m.ClearLastVersionBuild()
return nil
} }
return fmt.Errorf("unknown DbPackage nullable field %s", name) return fmt.Errorf("unknown DbPackage nullable field %s", name)
} }
@@ -1107,6 +1177,9 @@ func (m *DbPackageMutation) ResetField(name string) error {
case dbpackage.FieldLto: case dbpackage.FieldLto:
m.ResetLto() m.ResetLto()
return nil return nil
case dbpackage.FieldLastVersionBuild:
m.ResetLastVersionBuild()
return nil
} }
return fmt.Errorf("unknown DbPackage field %s", name) return fmt.Errorf("unknown DbPackage field %s", name)
} }

View File

@@ -26,6 +26,7 @@ func (DbPackage) Fields() []ent.Field {
field.Time("updated").Optional(), field.Time("updated").Optional(),
field.String("hash").Optional(), field.String("hash").Optional(),
field.Enum("lto").Values("enabled", "unknown", "disabled", "auto_disabled").Default("unknown").Optional(), field.Enum("lto").Values("enabled", "unknown", "disabled", "auto_disabled").Default("unknown").Optional(),
field.String("last_version_build").Optional(),
} }
} }

22
main.go
View File

@@ -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) 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 { if err != nil {
log.Errorf("[%s/%s] Failed to increase pkgrel: %v", pkg.FullRepo, pkg.Pkgbase, err) log.Errorf("[%s/%s] Failed to increase pkgrel: %v", pkg.FullRepo, pkg.Pkgbase, err)
b.buildWG.Done() b.buildWG.Done()
@@ -93,7 +105,7 @@ func (b *BuildManager) buildWorker(id int) {
} }
cmd := exec.Command("sh", "-c", 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+" -- "+ "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 var out bytes.Buffer
cmd.Stdout = &out cmd.Stdout = &out
cmd.Stderr = &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 { 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 { } 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 b.repoAdd[pkg.FullRepo] <- pkg
gitClean(pkg) gitClean(pkg)

View File

@@ -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) f, err := os.OpenFile(p.Pkgbuild, os.O_RDWR, 0644)
if err != nil { if err != nil {
return err return err
@@ -211,7 +211,7 @@ func (p *BuildPackage) increasePkgRel() error {
return err 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) _, err = f.Seek(0, 0)
if err != nil { if err != nil {
return err return err
@@ -226,7 +226,7 @@ func (p *BuildPackage) increasePkgRel() error {
return err return err
} }
p.Version += ".1" p.Version += "." + strconv.Itoa(buildNo)
return nil return nil
} }