Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/native deb dpkg #82

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/M0Rf30/yap
go 1.23

require (
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
github.com/cavaliergopher/grab/v3 v3.0.1
github.com/github/go-spdx/v2 v2.3.2
github.com/go-git/go-git/v5 v5.12.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuW
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
github.com/bodgit/plumbing v1.3.0 h1:pf9Itz1JOQgn7vEOE7v7nlEfBykYqvUYioC61TwWCFU=
github.com/bodgit/plumbing v1.3.0/go.mod h1:JOTb4XiRu5xfnmdnDJo6GmSbSbtSyufrsyZFByMtKEs=
github.com/bodgit/sevenzip v1.5.1 h1:rVj0baZsooZFy64DJN0zQogPzhPrT8BQ8TTRd1H4WHw=
Expand Down
35 changes: 17 additions & 18 deletions pkg/apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (a *Apk) BuildPackage(artifactsPath string) error {
// It initializes the apkDir, cleans up any existing directory, creates the necessary packer directory,
// and generates the APKBUILD and post-installation script files. The method returns an error if any step fails.
func (a *Apk) PrepareFakeroot(_ string) error {
a.PKGBUILD.ArchComputed = APKArchs[a.PKGBUILD.ArchComputed]
a.apkDir = filepath.Join(a.PKGBUILD.StartDir, "apk")

if err := utils.RemoveAll(a.apkDir); err != nil {
Expand Down Expand Up @@ -62,24 +63,22 @@ func (a *Apk) PrepareFakeroot(_ string) error {
// It takes a string parameter `artifactsPath` which specifies the path where the artifacts are located.
// It returns an error if there was an error during the installation process.
func (a *Apk) Install(artifactsPath string) error {
for _, arch := range a.PKGBUILD.Arch {
pkgName := a.PKGBUILD.PkgName + "-" +
a.PKGBUILD.PkgVer +
"-" +
"r" + a.PKGBUILD.PkgRel +
"-" +
arch +
".apk"

pkgFilePath := filepath.Join(artifactsPath, a.PKGBUILD.PkgName, arch, pkgName)

if err := utils.Exec(true,
"apk",
"add",
"--allow-untrusted",
pkgFilePath); err != nil {
return err
}
pkgName := a.PKGBUILD.PkgName + "-" +
a.PKGBUILD.PkgVer +
"-" +
"r" + a.PKGBUILD.PkgRel +
"-" +
a.PKGBUILD.ArchComputed +
".apk"

pkgFilePath := filepath.Join(artifactsPath, a.PKGBUILD.PkgName, a.PKGBUILD.ArchComputed, pkgName)

if err := utils.Exec(true,
"apk",
"add",
"--allow-untrusted",
pkgFilePath); err != nil {
return err
}

return nil
Expand Down
21 changes: 17 additions & 4 deletions pkg/apk/constants.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package apk

var buildEnvironmentDeps = []string{
"alpine-sdk",
}
var (
APKArchs = map[string]string{
"x86_64": "x86_64",
"i686": "x86",
"aarch64": "aarch64",
"armv7h": "armv7h",
"armv6h": "armv6h",
"any": "all",
}

buildEnvironmentDeps = []string{
"alpine-sdk",
}
)

const postInstall = `
{{- if .PreInst}}
Expand Down Expand Up @@ -51,7 +62,9 @@ epoch={{.Epoch}}
pkgver={{.PkgVer}}
pkgrel={{.PkgRel}}
pkgdesc="{{.PkgDesc}}"
arch="all"
{{- if .ArchComputed}}
arch="{{.ArchComputed}}"
{{- end}}
{{- if .Depends}}
depends="
{{ range .Depends }}{{ . }}
Expand Down
8 changes: 6 additions & 2 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ const (

var (
Releases = [...]string{
"alma",
"alpine",
"amazon",
"arch",
"centos",
"debian",
"fedora",
"rhel",
"rocky",
"ubuntu",
}

DistroToPackageManager = map[string]string{
"alma": "redhat",
"alpine": "alpine",
"arch": "pacman",
"amazon": "redhat",
"fedora": "redhat",
"arch": "pacman",
"centos": "redhat",
"debian": "debian",
"fedora": "redhat",
"oracle": "redhat",
"rhel": "redhat",
"rocky": "redhat",
"ubuntu": "debian",
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/dpkg/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Version: {{ if .Epoch}}{{ .Epoch }}:{{ end }}{{.PkgVer}}
{{- if .PkgRel}}-{{ .PkgRel }}{{- end }}
Section: {{.Section}}
Priority: {{.Priority}}
{{- with .Arch}}
Architecture: {{join .}}
{{- if .ArchComputed}}
Architecture: {{.ArchComputed}}
{{- end }}
{{- /* Optional fields */ -}}
{{- if .Maintainer}}
Expand Down Expand Up @@ -77,3 +77,9 @@ Copyright: {{ range .Copyright}}{{ . }}
License: {{ . }}{{- end }}
{{- end }}
`
const (
binaryContent = "2.0\n"
binaryFilename = "debian-binary"
controlFilename = "control.tar.zst"
dataFilename = "data.tar.zst"
)
Loading
Loading