Skip to content

Commit bed4764

Browse files
authored
Merge pull request #271 from essentialkaos/develop
Version 8.2.0
2 parents b5f90bc + 5b45fb0 commit bed4764

File tree

12 files changed

+155
-38
lines changed

12 files changed

+155
-38
lines changed

.docker/ol8.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN make deps && make all
1818

1919
## FINAL IMAGE #################################################################
2020

21-
FROM ${REGISTRY}/essentialkaos/oraclelinux:8
21+
FROM ${REGISTRY}/essentialkaos/oraclelinux:8 AS final
2222

2323
LABEL org.opencontainers.image.title="bibop" \
2424
org.opencontainers.image.description="Utility for testing command-line tools, daemons, and packages" \

.docker/ol9.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN make deps && make all
1818

1919
## FINAL IMAGE #################################################################
2020

21-
FROM ${REGISTRY}/essentialkaos/oraclelinux:9
21+
FROM ${REGISTRY}/essentialkaos/oraclelinux:9 AS final
2222

2323
LABEL org.opencontainers.image.title="bibop" \
2424
org.opencontainers.image.description="Utility for testing command-line tools, daemons, and packages" \

.github/images/usage.svg

Lines changed: 23 additions & 22 deletions
Loading

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<a href="#license"><img src=".github/images/license.svg"/></a>
1010
</p>
1111

12-
<p align="center"><a href="#usage-demo">Usage demo</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#ci-status">CI Status</a> • <a href="#license">License</a></p>
12+
<p align="center"><a href="#usage-demo">Usage demo</a> • <a href="#installation">Installation</a> • <a href="#upgrading">Upgrading</a> • <a href="#man-documentation">Man documentation</a> • <a href="#usage">Usage</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>
1313

1414
<br/>
1515

@@ -41,6 +41,20 @@ To install the latest prebuilt version of bibop, do:
4141
bash <(curl -fsSL https://apps.kaos.st/get) bibop
4242
```
4343

44+
### Upgrading
45+
46+
Since version `8.2.0` you can update `bibop` to the latest release using [self-update feature](https://github.com/essentialkaos/.github/blob/master/APPS-UPDATE.md):
47+
48+
```bash
49+
bibop --update
50+
```
51+
52+
This command will runs a self-update in interactive mode. If you want to run a quiet update (_no output_), use the following command:
53+
54+
```bash
55+
bibop --update=quiet
56+
```
57+
4458
### Docker support
4559

4660
Official webkaos images available on [GitHub Container Registry](https://kaos.sh/p/bibop) and [Docker Hub](http://kaos.sh/d/bibop). Install the latest version of Docker, then:
@@ -52,7 +66,7 @@ sudo mv bibop-docker /usr/bin/
5266

5367
bibop-docker your.recipe your-package.rpm
5468
# or
55-
bibop-docker --image ghcr.io/essentialkaos/bibop:centos7 your.recipe your-package.rpm
69+
bibop-docker --image ghcr.io/essentialkaos/bibop:ol9 your.recipe your-package.rpm
5670
```
5771

5872
### Recipe syntax highlighting

action/fs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ package action
99

1010
import (
1111
"bytes"
12+
"crypto/sha256"
1213
"fmt"
1314
"os"
1415
"path/filepath"
1516
"strconv"
1617
"strings"
1718

1819
"github.com/essentialkaos/ek/v13/fsutil"
19-
"github.com/essentialkaos/ek/v13/hash"
20+
"github.com/essentialkaos/ek/v13/hashutil"
2021
"github.com/essentialkaos/ek/v13/strutil"
2122
"github.com/essentialkaos/ek/v13/system"
2223

@@ -336,7 +337,7 @@ func Checksum(action *recipe.Action) error {
336337
return err
337338
}
338339

339-
fileHash := hash.FileHash(file)
340+
fileHash := hashutil.File(file, sha256.New()).String()
340341

341342
switch {
342343
case !action.Negative && fileHash != mustHash:
@@ -368,7 +369,7 @@ func ChecksumRead(action *recipe.Action) error {
368369
return err
369370
}
370371

371-
hash := hash.FileHash(file)
372+
hash := hashutil.File(file, sha256.New()).String()
372373

373374
return action.Command.Recipe.SetVariable(variable, hash)
374375
}

action/http.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,16 @@ func HTTPJSON(action *recipe.Action) error {
224224
}
225225

226226
querySlice := parseJSONQuery(query)
227-
jsonValue, _, _, err := jsonparser.Get(resp.Bytes(), querySlice...)
227+
jsonData, err := resp.Bytes()
228228

229229
if err != nil {
230-
return fmt.Errorf("Can't get JSON data: %v", err)
230+
return fmt.Errorf("Can't get response data: %w", err)
231+
}
232+
233+
jsonValue, _, _, err := jsonparser.Get(jsonData, querySlice...)
234+
235+
if err != nil {
236+
return fmt.Errorf("Can't get JSON data: %w", err)
231237
}
232238

233239
containsValue := string(jsonValue) == value

cli/barcode.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ package cli
88
// ////////////////////////////////////////////////////////////////////////////////// //
99

1010
import (
11+
"crypto/sha256"
1112
"fmt"
1213
"os/exec"
1314

1415
"github.com/essentialkaos/ek/v13/env"
1516
"github.com/essentialkaos/ek/v13/fmtutil/barcode"
16-
"github.com/essentialkaos/ek/v13/hash"
17+
"github.com/essentialkaos/ek/v13/hashutil"
1718

1819
"github.com/essentialkaos/bibop/recipe"
1920
)
@@ -28,7 +29,7 @@ func printBarcode(r *recipe.Recipe) {
2829
printErrorAndExit(err.Error())
2930
}
3031

31-
recipeCrc := hash.FileHash(r.File)
32+
recipeCrc := hashutil.File(r.File, sha256.New())
3233

3334
if err != nil {
3435
printErrorAndExit(err.Error())

cli/cli.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import (
4545
// Application info
4646
const (
4747
APP = "bibop"
48-
VER = "8.1.5"
48+
VER = "8.2.0"
4949
DESC = "Utility for testing command-line tools"
5050
)
5151

@@ -73,6 +73,7 @@ const (
7373
OPT_HELP = "h:help"
7474
OPT_VER = "v:version"
7575

76+
OPT_UPDATE = "U:update"
7677
OPT_VERB_VER = "vv:verbose-version"
7778
OPT_COMPLETION = "completion"
7879
OPT_GENERATE_MAN = "generate-man"
@@ -101,6 +102,7 @@ var optMap = options.Map{
101102
OPT_HELP: {Type: options.BOOL},
102103
OPT_VER: {Type: options.MIXED},
103104

105+
OPT_UPDATE: {Type: options.MIXED},
104106
OPT_VERB_VER: {Type: options.BOOL},
105107
OPT_COMPLETION: {},
106108
OPT_GENERATE_MAN: {Type: options.BOOL},
@@ -118,7 +120,7 @@ func Run(gitRev string, gomod []byte) {
118120

119121
if !errs.IsEmpty() {
120122
terminal.Error("Options parsing errors:")
121-
terminal.Error(errs.Error("- "))
123+
terminal.Error(errs.Error(" - "))
122124
os.Exit(1)
123125
}
124126

@@ -145,6 +147,8 @@ func Run(gitRev string, gomod []byte) {
145147
WithResources(resources.Collect()).
146148
Print()
147149
os.Exit(0)
150+
case withSelfUpdate && options.GetB(OPT_UPDATE):
151+
os.Exit(updateBinary())
148152
case options.GetB(OPT_HELP) || len(args) == 0:
149153
genUsage().Print()
150154
os.Exit(0)
@@ -445,6 +449,11 @@ func genUsage() *usage.Info {
445449
info.AddOption(OPT_QUIET, "Quiet mode")
446450
info.AddOption(OPT_IGNORE_PACKAGES, "Do not check system for installed packages")
447451
info.AddOption(OPT_NO_CLEANUP, "Disable deleting files created during tests")
452+
453+
if withSelfUpdate {
454+
info.AddOption(OPT_UPDATE, "Update application to the latest version")
455+
}
456+
448457
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
449458
info.AddOption(OPT_HELP, "Show this help message")
450459
info.AddOption(OPT_VER, "Show version")

cli/with_selfupdate.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//go:build selfupdate
2+
// +build selfupdate
3+
4+
package cli
5+
6+
// ////////////////////////////////////////////////////////////////////////////////// //
7+
// //
8+
// Copyright (c) 2025 ESSENTIAL KAOS //
9+
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
10+
// //
11+
// ////////////////////////////////////////////////////////////////////////////////// //
12+
13+
import (
14+
"strings"
15+
16+
"github.com/essentialkaos/ek/v13/fmtc"
17+
"github.com/essentialkaos/ek/v13/options"
18+
"github.com/essentialkaos/ek/v13/selfupdate"
19+
"github.com/essentialkaos/ek/v13/selfupdate/interactive"
20+
storage "github.com/essentialkaos/ek/v13/selfupdate/storage/basic"
21+
"github.com/essentialkaos/ek/v13/terminal"
22+
)
23+
24+
// ////////////////////////////////////////////////////////////////////////////////// //
25+
26+
var withSelfUpdate = true
27+
28+
// ////////////////////////////////////////////////////////////////////////////////// //
29+
30+
// updateBinary updates current binary to the latest version
31+
func updateBinary() int {
32+
quiet := strings.ToLower(options.GetS(OPT_UPDATE)) == "quiet"
33+
updInfo, hasUpdate, err := storage.NewStorage("https://apps.kaos.ws").Check(APP, VER)
34+
35+
if err != nil {
36+
if !quiet {
37+
terminal.Error("Can't update binary: %v", err)
38+
}
39+
40+
return 1
41+
}
42+
43+
if !hasUpdate {
44+
fmtc.If(!quiet).Println("{g}You are using the latest version of the app{!}")
45+
return 0
46+
}
47+
48+
pubKey := "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnYHsOTvrKqeE97dsEt7Ge97+yUcvQJn1++s++FqShDyqwV8CcoKp0E6nDTc8SxInZ5wxwcScxSicfvC9S73OSg=="
49+
50+
if quiet {
51+
err = selfupdate.Run(updInfo, pubKey, nil)
52+
} else {
53+
err = selfupdate.Run(updInfo, pubKey, interactive.Dispatcher())
54+
}
55+
56+
if err != nil {
57+
return 1
58+
}
59+
60+
return 0
61+
}
62+
63+
// ////////////////////////////////////////////////////////////////////////////////// //

cli/without_selfupdate.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build !selfupdate
2+
// +build !selfupdate
3+
4+
package cli
5+
6+
// ////////////////////////////////////////////////////////////////////////////////// //
7+
// //
8+
// Copyright (c) 2025 ESSENTIAL KAOS //
9+
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
10+
// //
11+
// ////////////////////////////////////////////////////////////////////////////////// //
12+
13+
var withSelfUpdate = false
14+
15+
// ////////////////////////////////////////////////////////////////////////////////// //
16+
17+
// updateBinary updates current binary to the latest version
18+
func updateBinary() int {
19+
return 1
20+
}
21+
22+
// ////////////////////////////////////////////////////////////////////////////////// //

0 commit comments

Comments
 (0)