Skip to content

Commit

Permalink
chore: order functions alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
M0Rf30 committed Oct 17, 2023
1 parent ff5399d commit e701b64
Show file tree
Hide file tree
Showing 25 changed files with 832 additions and 820 deletions.
100 changes: 50 additions & 50 deletions apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,6 @@ type Apk struct {
apkDir string
}

func (a *Apk) apkBuild(artifactsPath string) error {
err := utils.Exec(a.apkDir, "abuild-keygen", "-n", "-a")
if err != nil {
return err
}

err = utils.Exec(a.apkDir, "abuild", "-F", "-K", "-P", artifactsPath)
if err != nil {
return err
}

return err
}

func (a *Apk) Prepare(makeDepends []string) error {
args := []string{
"add",
}

err := a.PKGBUILD.GetDepends("apk", args, makeDepends)
if err != nil {
return err
}

return err
}

func (a *Apk) Update() error {
err := a.PKGBUILD.GetUpdates("apk", "update")
if err != nil {
return err
}

return err
}

func (a *Apk) makePackerDir() error {
err := utils.ExistsMakeDir(a.apkDir)
if err != nil {
return err
}

err = utils.ExistsMakeDir(a.apkDir + "/pkg/" + a.PKGBUILD.PkgName)
if err != nil {
return err
}

return err
}

func (a *Apk) Build(artifactsPath string) error {
a.apkDir = filepath.Join(a.PKGBUILD.StartDir, "apk")

Expand Down Expand Up @@ -115,6 +65,19 @@ func (a *Apk) Install(artifactsPath string) error {
return err
}

func (a *Apk) Prepare(makeDepends []string) error {
args := []string{
"add",
}

err := a.PKGBUILD.GetDepends("apk", args, makeDepends)
if err != nil {
return err
}

return err
}

func (a *Apk) PrepareEnvironment(golang bool) error {
var err error

Expand All @@ -136,3 +99,40 @@ func (a *Apk) PrepareEnvironment(golang bool) error {

return err
}

func (a *Apk) Update() error {
err := a.PKGBUILD.GetUpdates("apk", "update")
if err != nil {
return err
}

return err
}

func (a *Apk) apkBuild(artifactsPath string) error {
err := utils.Exec(a.apkDir, "abuild-keygen", "-n", "-a")
if err != nil {
return err
}

err = utils.Exec(a.apkDir, "abuild", "-F", "-K", "-P", artifactsPath)
if err != nil {
return err
}

return err
}

func (a *Apk) makePackerDir() error {
err := utils.ExistsMakeDir(a.apkDir)
if err != nil {
return err
}

err = utils.ExistsMakeDir(a.apkDir + "/pkg/" + a.PKGBUILD.PkgName)
if err != nil {
return err
}

return err
}
65 changes: 33 additions & 32 deletions apk/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,6 @@ var buildEnvironmentDeps = []string{
"alpine-sdk",
}

const specFile = `
{{- /* Mandatory fields */ -}}
pkgname={{.PkgName}}
{{- if .Epoch}}
epoch={{.Epoch}}
{{- end }}
pkgver={{.PkgVer}}
pkgrel={{.PkgRel}}
pkgdesc="{{.PkgDesc}}"
arch="all"
{{- with .Depends}}
depends="{{join .}}"
{{- end }}
{{- with .Conflicts}}
conflicts=({{join .}})
{{- end }}
{{- if .URL}}
url="{{.URL}}"
{{- end }}
{{- if .Install}}
install={{.PkgName}}.install
{{- end }}
{{- if .License}}
license={{.License}}
{{- else }}
license="CUSTOM"
{{- end }}
options="!check !fhs"
package() {{.Package}}
`
const postInstall = `
{{- if .PreInst}}
pre_install() {
Expand Down Expand Up @@ -73,3 +41,36 @@ post_remove() {
}
{{- end }}
`

const specFile = `
{{- /* Mandatory fields */ -}}
pkgname={{.PkgName}}
{{- if .Epoch}}
epoch={{.Epoch}}
{{- end }}
pkgver={{.PkgVer}}
pkgrel={{.PkgRel}}
pkgdesc="{{.PkgDesc}}"
arch="all"
{{- with .Depends}}
depends="{{join .}}"
{{- end }}
{{- with .Conflicts}}
conflicts=({{join .}})
{{- end }}
{{- if .URL}}
url="{{.URL}}"
{{- end }}
{{- if .Install}}
install={{.PkgName}}.install
{{- end }}
{{- if .License}}
license={{.License}}
{{- else }}
license="CUSTOM"
{{- end }}
options="!check !fhs"
package() {{.Package}}
`
90 changes: 45 additions & 45 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,38 @@ type Builder struct {
PKGBUILD *pkgbuild.PKGBUILD
}

func (builder *Builder) initDirs() error {
err := utils.ExistsMakeDir(builder.PKGBUILD.SourceDir)
func (builder *Builder) Compile() error {
err := builder.initDirs()
if err != nil {
return err
}

err = utils.ExistsMakeDir(builder.PKGBUILD.PackageDir)
fmt.Printf("%s🖧 :: %sGetting sources ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))

err = builder.getSources()
if err != nil {
return err
}

return err
}

func (builder *Builder) getSources() error {
var err error

for index, sourceURI := range builder.PKGBUILD.SourceURI {
source := source.Source{
StartDir: builder.PKGBUILD.StartDir,
Hash: builder.PKGBUILD.HashSums[index],
SourceItemURI: sourceURI,
SrcDir: builder.PKGBUILD.SourceDir,
SourceItemPath: "",
}
err = source.Get()
fmt.Printf("%s🏗️ :: %sBuilding ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))

if err != nil {
return err
}
err = builder.build()
if err != nil {
return err
}

return err
}
fmt.Printf("%s📦 :: %sGenerating package ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))

func (builder *Builder) build() error {
err := RunScript(builder.PKGBUILD.Build)
err = builder.Package()
if err != nil {
return err
}
Expand All @@ -66,38 +61,43 @@ func (builder *Builder) Package() error {
return err
}

func (builder *Builder) Compile() error {
err := builder.initDirs()
func (builder *Builder) build() error {
err := RunScript(builder.PKGBUILD.Build)
if err != nil {
return err
}

fmt.Printf("%s🖧 :: %sGetting sources ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))
return err
}

err = builder.getSources()
if err != nil {
return err
func (builder *Builder) getSources() error {
var err error

for index, sourceURI := range builder.PKGBUILD.SourceURI {
source := source.Source{
StartDir: builder.PKGBUILD.StartDir,
Hash: builder.PKGBUILD.HashSums[index],
SourceItemURI: sourceURI,
SrcDir: builder.PKGBUILD.SourceDir,
SourceItemPath: "",
}
err = source.Get()

if err != nil {
return err
}
}

fmt.Printf("%s🏗️ :: %sBuilding ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))
return err
}

err = builder.build()
func (builder *Builder) initDirs() error {
err := utils.ExistsMakeDir(builder.PKGBUILD.SourceDir)
if err != nil {
return err
}

fmt.Printf("%s📦 :: %sGenerating package ...%s\n",
string(constants.ColorBlue),
string(constants.ColorYellow),
string(constants.ColorWhite))

err = builder.Package()
err = utils.ExistsMakeDir(builder.PKGBUILD.PackageDir)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit e701b64

Please sign in to comment.