Skip to content

Commit

Permalink
chore: improve architecture detection
Browse files Browse the repository at this point in the history
  • Loading branch information
M0Rf30 committed Oct 10, 2023
1 parent 026f584 commit bad5aba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion debian/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var buildEnvironmentDeps = []string{
"ca-certificates",
}

var ArchToDebian = map[string]string{
var DebianArchs = map[string]string{
"any": "all",
"x86_64": "amd64",
"i686": "386",
Expand Down
2 changes: 1 addition & 1 deletion debian/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Debian struct {

func (d *Debian) getArch() {
for index, arch := range d.PKGBUILD.Arch {
d.PKGBUILD.Arch[index] = ArchToDebian[arch]
d.PKGBUILD.Arch[index] = DebianArchs[arch]
}
}

Expand Down
5 changes: 4 additions & 1 deletion redhat/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var (
"x11": "User Interface/X",
}

ArchToRPM = map[string]string{
RPMArchs = map[string]string{
"x86_64": "x86_64",
"i686": "i686",
"aarch64": "aarch64",
Expand All @@ -76,6 +76,9 @@ Epoch: {{.Epoch}}
{{- end }}
Version: {{.PkgVer}}
Release: {{.PkgRel}}
{{- with .Arch}}
BuildArch: {{join .}}
{{- end }}
{{- if .Section}}
Group: {{.Section}}
{{- end }}
Expand Down
11 changes: 9 additions & 2 deletions redhat/redhat.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ type Redhat struct {
srpmsDir string
}

func (r *Redhat) getRPMArch() {
for index, arch := range r.PKGBUILD.Arch {
r.PKGBUILD.Arch[index] = RPMArchs[arch]
}
}

func (r *Redhat) getRPMGroup() {
r.PKGBUILD.Section = RPMGroups[r.PKGBUILD.Section]
}
Expand Down Expand Up @@ -141,6 +147,7 @@ func (r *Redhat) makeDirs() error {
}

func (r *Redhat) Build(artifactsPath string) error {
r.getRPMArch()
r.getRPMGroup()
r.PKGBUILD.PkgDest, _ = filepath.Abs(artifactsPath)

Expand Down Expand Up @@ -193,10 +200,10 @@ func (r *Redhat) Install(artifactsPath string) error {
"-" +
r.PKGBUILD.PkgRel +
"." +
ArchToRPM[arch] +
RPMArchs[arch] +
".rpm"

pkgFilePath := filepath.Join(artifactsPath, ArchToRPM[arch], pkgName)
pkgFilePath := filepath.Join(artifactsPath, RPMArchs[arch], pkgName)

if err := utils.Exec("", "yum", "install", "-y", pkgFilePath); err != nil {
return err
Expand Down

0 comments on commit bad5aba

Please sign in to comment.