Skip to content
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
4 changes: 3 additions & 1 deletion .deb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
- amd64
- arm64
maintainer: The OSSPkg Team <github@osspkg.com>
homepage: https://deb.osspkg.com/
homepage: https://dl.osspkg.com/
description:
- Debian package builder
section: web
Expand All @@ -16,3 +16,5 @@ packages:
build: goppy build --arch=%arch%
data:
usr/bin/deb-builder: build/deb-builder_%arch%
ignore:
- .git/
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.25' ]
go: [ '1.26' ]
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

.PHONY: install
install:
go install go.osspkg.com/goppy/v2/cmd/goppy@latest
go install go.osspkg.com/goppy/v3/cmd/goppy@latest

.PHONY: setup
setup:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ data: # A list of files that will be packaged during the build, where the file i
demo/file: 'c:write file content'
demo/dir: 'd:/build'
demo/dir1: 'e:/build/.*.(go|js)'
ignore:
- .git/
- .gitignore
```

data prefix:
Expand Down
2 changes: 1 addition & 1 deletion cmd/deb-builder/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module github.com/osspkg/deb-builder

go 1.25.3
go 1.26.3

require (
github.com/stretchr/testify v1.11.1
go.osspkg.com/archives v1.1.0
go.osspkg.com/console v0.3.3
go.osspkg.com/encrypt v0.5.1
go.osspkg.com/ioutils v0.7.3
go.osspkg.com/encrypt v0.5.3
go.osspkg.com/ioutils v0.7.4
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.osspkg.com/errors v0.4.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/crypto v0.53.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ go.osspkg.com/casecheck v0.3.0 h1:x15blEszElbrHrEH5H02JIIhGIg/lGZzIt1kQlD3pwM=
go.osspkg.com/casecheck v0.3.0/go.mod h1:TRFXDMFJEOtnlp3ET2Hix3osbxwPWhvaiT/HfD3+gBA=
go.osspkg.com/console v0.3.3 h1:UB/pPoPsgWbyNFix8pEMQHbsXdMv/UK/dgsbRknCH2A=
go.osspkg.com/console v0.3.3/go.mod h1:IknBCliH6mX/ogHa6wbycnGDFYixCGH3WuNc5W5tQe8=
go.osspkg.com/encrypt v0.5.1 h1:DaYhos4Si9Mzi1LBW2mkin7TPQGkKvlwI+aq/a8Z6ko=
go.osspkg.com/encrypt v0.5.1/go.mod h1:mGDe5PTd+i6cntpiOaesAaD7498ypqPbbMPbI89PK4c=
go.osspkg.com/encrypt v0.5.3 h1:/DnWw1zVETxErZa0UD0Xwh7LSPWDHptLvayPSdEAaY4=
go.osspkg.com/encrypt v0.5.3/go.mod h1:xqTL2V0utimVtrL4i86czYe4llQzwDMFx5NWF8pJmxk=
go.osspkg.com/errors v0.4.0 h1:E17+WyUzTXEHCTxGm8lOMPOOojzHG1lsOuQtTVGoATQ=
go.osspkg.com/errors v0.4.0/go.mod h1:s75ZovPemYtrCtRPVsbQNq9MgMbmLMK1NEypr+uwjXI=
go.osspkg.com/ioutils v0.7.3 h1:QF+Ra0bHoU3MGMGH5PGdV2lRLq1rWPdv/OB+v5UTjkI=
go.osspkg.com/ioutils v0.7.3/go.mod h1:RO/43IM//Wq8RnLvEzivDAuM37mnLW3eWxTCVmkUaY4=
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
go.osspkg.com/ioutils v0.7.4 h1:Z8Y4jYYmLGWcvHZMLjbai+s48GmHxjMuepsxZcjF5X4=
go.osspkg.com/ioutils v0.7.4/go.mod h1:pPIsTL1w1+ESrGTeHDCd6cKsujeWvschxGGP5FqrAqc=
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
90 changes: 37 additions & 53 deletions internal/commands/build.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

package commands

import (
"fmt"
iofs "io/fs"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -35,6 +34,8 @@ func Build() console.CommandGetter {
flag.Bool("no-revision", "Don`t build revision deb package")
})
setter.ExecFunc(func(_ []string, debConf, baseDir, tmpDir string, noRevision bool) {
curr := fs.CurrentDir()

configs, err := config.Detect(debConf)
console.FatalIfErr(err, "deb config not found")

Expand All @@ -48,6 +49,11 @@ func Build() console.CommandGetter {
console.FatalIfErr(os.MkdirAll(storeDir, 0755), "creating storage directory")

exec.Build(conf.Control.Build, conf.Version, conf.Architecture, func(arch string, replacer exec.Replacer) {
defer func() {
if r := recover(); r != nil {
console.Fatalf("build failed: %v", r)
}
}()

// check file version

Expand All @@ -71,92 +77,69 @@ func Build() console.CommandGetter {
err1 error
)

switch true {
case strings.HasPrefix(src, "+"):
f, h, err1 = tg.WriteData(dst, []byte(src)[1:])
console.FatalIfErr(err1, "write %s to data.tar.gz", src)
md5sum.Add(f, h)
console.Infof("Add: %s", dst)
if prefix, ok := utils.MultiPrefix(src, "+", "c:"); ok {

case strings.HasPrefix(src, "c:"):
f, h, err1 = tg.WriteData(dst, []byte(src)[2:])
f, h, err1 = tg.WriteData(dst, []byte(utils.MustValueAfterPrefix(src, prefix)))
console.FatalIfErr(err1, "write %s to data.tar.gz", src)

md5sum.Add(f, h)
console.Infof("Add: %s", dst)

case strings.HasPrefix(src, "~"):
fullpath, err0 := filepath.Abs(src[1:])
console.FatalIfErr(err0, "get full path for %s", src[1:])
} else if prefix, ok := utils.MultiPrefix(src, "~", "d:"); ok {

err2 := filepath.Walk(fullpath, func(path string, info iofs.FileInfo, e error) error {
if e != nil {
return e
}
if info.IsDir() {
return nil
}
walkedFile := strings.ReplaceAll(path, fullpath, dst)
ff, hh, ee := tg.WriteFile(path, walkedFile)
console.FatalIfErr(ee, "write %s to data.tar.gz", src)
md5sum.Add(ff, hh)
console.Infof("Add: %s", walkedFile)
return nil
})
console.FatalIfErr(err2, "write %s to data.tar.gz", src)
srcPath := utils.MustValueAfterPrefix(src, prefix)
fullpath, err0 := filepath.Abs(srcPath)
console.FatalIfErr(err0, "get full path for %s", srcPath)

case strings.HasPrefix(src, "d:"):
fullpath, err0 := filepath.Abs(src[2:])
console.FatalIfErr(err0, "get full path for %s", src[2:])
if !strings.HasPrefix(fullpath, curr) {
console.Fatalf("full path for %s is incorrect", srcPath)
}

err2 := filepath.Walk(fullpath, func(path string, info iofs.FileInfo, e error) error {
if e != nil {
return e
}
if info.IsDir() {
return nil
}
err2 := utils.DirWalk(fullpath, func(path string) error {
walkedFile := strings.ReplaceAll(path, fullpath, dst)

ff, hh, ee := tg.WriteFile(path, walkedFile)
console.FatalIfErr(ee, "write %s to data.tar.gz", src)

md5sum.Add(ff, hh)
console.Infof("Add: %s", walkedFile)

return nil
})
}, conf.Ignore...)
console.FatalIfErr(err2, "write %s to data.tar.gz", src)

case strings.HasPrefix(src, "e:"):
} else if _, ok := utils.MultiPrefix(src, "e:"); ok {

rex, err0 := regexp.Compile(`(?Us)^` + src[2:] + `$`)
console.FatalIfErr(err0, "build regexp `%s`", src[2:])

fullpath := fs.CurrentDir()
err2 := filepath.Walk(fullpath, func(path string, info iofs.FileInfo, e error) error {
if e != nil {
return e
}
if info.IsDir() {
return nil
}

if !rex.MatchString(strings.TrimPrefix(path, fullpath)) {
err2 := utils.DirWalk(curr, func(path string) error {
if !rex.MatchString(strings.TrimPrefix(path, curr)) {
return nil
}

walkedFile := strings.ReplaceAll(path, fullpath, dst)
walkedFile := strings.ReplaceAll(path, curr, dst)
ff, hh, ee := tg.WriteFile(path, walkedFile)
console.FatalIfErr(ee, "write %s to data.tar.gz", src)

md5sum.Add(ff, hh)
console.Infof("Add: %s", walkedFile)

return nil
})
}, conf.Ignore...)
console.FatalIfErr(err2, "write %s to data.tar.gz", src)

default:
} else {

f, h, err1 = tg.WriteFile(src, dst)
console.FatalIfErr(err1, "write %s to data.tar.gz", src)

md5sum.Add(f, h)
console.Infof("Add: %s", dst)

}
}

console.FatalIfErr(tg.Close(), "close data.tar.gz")

md5file, err := md5sum.Save(buildDir)
Expand Down Expand Up @@ -204,6 +187,7 @@ func Build() console.CommandGetter {
console.FatalIfErr(deb.Close(), "close file %s", debFile)

console.Infof("Result: %s", debFile)

})

}
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/pgp.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/release.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/archive/gzwriter.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/archive/reader.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/archive/writer.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/buffer/buffer.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
7 changes: 6 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down Expand Up @@ -41,6 +41,7 @@ type (
Priority string `yaml:"priority"`
Control Control `yaml:"control"`
Data map[string]string `yaml:"data"`
Ignore []string `yaml:"ignore"`
}
Control struct {
Depends []string `yaml:"depends"`
Expand Down Expand Up @@ -125,6 +126,10 @@ func Create() error {
"etc/" + filepath.Base(dir) + "/config.yaml": "configs/config.yaml",
"var/log/" + filepath.Base(dir) + ".log": "+Write contents of file here after '+'",
},
Ignore: []string{
".git/",
".gitignore",
},
}

cfg := Multi{
Expand Down
2 changes: 1 addition & 1 deletion pkg/control/control.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/control/controlpkg.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/control/md5sums.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/control/other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/exec/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/hash/hash.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/packages/codec.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/packages/name.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/packages/packages.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2025 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Copyright (c) 2021-2026 Mikhail Knyazhev <markus621@gmail.com>. All rights reserved.
* Use of this source code is governed by a BSD-3-Clause license that can be found in the LICENSE file.
*/

Expand Down
Loading
Loading