1
0

feat: show both release number and name for debian

This commit is contained in:
dump_stack() 2023-05-18 22:26:42 +00:00
parent f0c82f9289
commit e767299222
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 10 additions and 5 deletions

View File

@ -191,7 +191,12 @@ type DistroListCmd struct{}
func (cmd *DistroListCmd) Run() (err error) { func (cmd *DistroListCmd) Run() (err error) {
for _, d := range distro.List() { for _, d := range distro.List() {
fmt.Println(d.ID, strings.Title(d.Release)) if d.ID == distro.Debian {
d.Release = fmt.Sprintf("%d %s",
debian.ReleaseFromString(d.Release),
strings.Title(d.Release))
}
fmt.Println(d.ID, d.Release)
} }
return return
} }

View File

@ -56,7 +56,7 @@ func (d Debian) Equal(dd distro.Distro) bool {
return false return false
} }
return releaseFromString(dd.Release) == d.release return ReleaseFromString(dd.Release) == d.release
} }
func (d Debian) Packages() (packages []string, err error) { func (d Debian) Packages() (packages []string, err error) {
@ -123,7 +123,7 @@ func (cn Release) String() string {
return ReleaseStrings[cn] return ReleaseStrings[cn]
} }
func releaseFromString(s string) (r Release) { func ReleaseFromString(s string) (r Release) {
switch strings.ToLower(s) { switch strings.ToLower(s) {
case "7", "wheezy": case "7", "wheezy":
r = Wheezy r = Wheezy
@ -186,7 +186,7 @@ func Envs(km config.Target) (envs []string) {
func ContainerImage(km config.Target) (image string) { func ContainerImage(km config.Target) (image string) {
image += "debian:" image += "debian:"
switch releaseFromString(km.Distro.Release) { switch ReleaseFromString(km.Distro.Release) {
case Wheezy: case Wheezy:
image += "wheezy-20190228" image += "wheezy-20190228"
case Jessie: case Jessie:
@ -232,7 +232,7 @@ func repositories(release Release) (repos []string) {
} }
func Runs(km config.Target) (commands []string) { func Runs(km config.Target) (commands []string) {
release := releaseFromString(km.Distro.Release) release := ReleaseFromString(km.Distro.Release)
cmdf := func(f string, s ...interface{}) { cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...)) commands = append(commands, fmt.Sprintf(f, s...))