42 lines
783 B
Go
42 lines
783 B
Go
package release
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type Release struct {
|
|
Architectures []string
|
|
Origin string
|
|
Label string
|
|
Suite string
|
|
Codename string
|
|
Version string
|
|
Components []string
|
|
Date time.Time
|
|
Files []*File
|
|
}
|
|
|
|
func (r *Release) Append(f *File) {
|
|
if r.Files == nil {
|
|
r.Files = make([]*File, 0)
|
|
}
|
|
|
|
r.Files = append(r.Files, f)
|
|
}
|
|
|
|
func (r *Release) Write(w io.Writer) {
|
|
bufw := &writer{bufio.NewWriter(w)}
|
|
|
|
bufw.WriteValue("Suite", r.Suite)
|
|
bufw.WriteSlice("Architectures", r.Architectures)
|
|
bufw.WriteSlice("Components", r.Components)
|
|
bufw.WriteValue("Date", r.Date.In(time.UTC).Format("Mon, 02 Jan 2006 15:04:05 -0700"))
|
|
|
|
bufw.WriteHashTable("MD5Sum", r.Files)
|
|
bufw.WriteHashTable("SHA1", r.Files)
|
|
bufw.WriteHashTable("SHA256", r.Files)
|
|
|
|
bufw.Flush()
|
|
} |