Skip to content

Commit

Permalink
Merge pull request #202 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 8.0.4
  • Loading branch information
andyone authored May 21, 2024
2 parents be603db + 8325ebd commit 16c47b1
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[files]
extend-exclude = ["go.sum"]

[default.extend-words]
wrk = "wrk"
2 changes: 1 addition & 1 deletion COOKBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ command "-" "Check linking"

##### `lib-rpath`

Checks if binary file has [rpath](https://en.wikipedia.org/wiki/Rpath) field with given path.
Checks if binary file has [`rpath`](https://en.wikipedia.org/wiki/Rpath)/`runpath`/`runpath` field with given path.

**Syntax:** `lib-rpath <binary> <path>`

Expand Down
74 changes: 45 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
################################################################################

# This Makefile generated by GoMakeGen 2.3.0 using next command:
# This Makefile generated by GoMakeGen 3.0.1 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen

################################################################################

export GO111MODULE=on

ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif

COMPAT ?= 1.18
COMPAT ?= 1.19
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)

################################################################################

.DEFAULT_GOAL := help
.PHONY = fmt vet all clean deps update test init vendor gen-fuzz mod-init mod-update mod-download mod-vendor help
.PHONY = fmt vet all install uninstall clean deps update test init vendor gen-fuzz mod-init mod-update mod-download mod-vendor help

################################################################################

all: bibop ## Build all binaries

bibop:
go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" bibop.go
@echo "Building bibop…"
@go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" bibop.go

install: ## Install all binaries
cp bibop /usr/bin/bibop
@echo "Installing binaries…"
@cp bibop /usr/bin/bibop

uninstall: ## Uninstall all binaries
rm -f /usr/bin/bibop
@echo "Removing installed binaries…"
@rm -f /usr/bin/bibop

init: mod-init ## Initialize new module

Expand All @@ -44,68 +45,83 @@ update: mod-update ## Update dependencies to the latest versions
vendor: mod-vendor ## Make vendored copy of dependencies

test: ## Run tests
@echo "Starting tests…"
ifdef COVERAGE_FILE ## Save coverage data into file (String)
go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./parser ./recipe
@go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./parser ./recipe
else
go test $(VERBOSE_FLAG) -covermode=count ./parser ./recipe
@go test $(VERBOSE_FLAG) -covermode=count ./parser ./recipe
endif

gen-fuzz: ## Generate archives for fuzz testing
which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build
go-fuzz-build -o parser-fuzz.zip github.com/essentialkaos/bibop/parser
@which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build
@echo "Generating fuzzing data…"
@go-fuzz-build -o parser-fuzz.zip github.com/essentialkaos/bibop/parser

mod-init:
@echo "[1/2] Modules initialization…"
ifdef MODULE_PATH ## Module path for initialization (String)
go mod init $(MODULE_PATH)
@go mod init $(MODULE_PATH)
else
go mod init
@go mod init
endif

@echo "[2/2] Dependencies cleanup…"
ifdef COMPAT ## Compatible Go version (String)
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
@go mod tidy $(VERBOSE_FLAG)
endif

mod-update:
@echo "[1/4] Updating dependencies…"
ifdef UPDATE_ALL ## Update all dependencies (Flag)
go get -u $(VERBOSE_FLAG) all
@go get -u $(VERBOSE_FLAG) all
else
go get -u $(VERBOSE_FLAG) ./...
@go get -u $(VERBOSE_FLAG) ./...
endif

@echo "[2/4] Stripping toolchain info…"
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :

@echo "[3/4] Dependencies cleanup…"
ifdef COMPAT
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
@go mod tidy $(VERBOSE_FLAG)
endif

test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
@echo "[4/4] Updating vendored dependencies…"
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
go mod download
@echo "Downloading dependencies…"
@go mod download

mod-vendor:
rm -rf vendor && go mod vendor $(VERBOSE_FLAG)
@echo "Vendoring dependencies…"
@rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

fmt: ## Format source code with gofmt
find . -name "*.go" -exec gofmt -s -w {} \;
@echo "Formatting sources…"
@find . -name "*.go" -exec gofmt -s -w {} \;

vet: ## Runs 'go vet' over sources
go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
@echo "Running 'go vet' over sources…"
@go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...

clean: ## Remove generated files
rm -f bibop
@echo "Removing built binaries…"
@rm -f bibop

help: ## Show this info
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}'
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-13s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 3.0.1\033[0m\n'

################################################################################
8 changes: 8 additions & 0 deletions action/libs.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func LibRPath(action *recipe.Action) error {
return fmt.Errorf("Can't get info from binary: %v", err)
}

if !hasRPath {
hasRPath, err = isELFHasTag(binary, "Library runpath", rpath)

if err != nil {
return fmt.Errorf("Can't get info from binary: %v", err)
}
}

switch {
case !action.Negative && !hasRPath:
return fmt.Errorf("Binary %s does not use %s as rpath (run-time search path)", binary, rpath)
Expand Down
23 changes: 8 additions & 15 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/essentialkaos/ek/v12/support"
"github.com/essentialkaos/ek/v12/support/deps"
"github.com/essentialkaos/ek/v12/support/pkgs"
"github.com/essentialkaos/ek/v12/terminal"
"github.com/essentialkaos/ek/v12/terminal/tty"
"github.com/essentialkaos/ek/v12/usage"
"github.com/essentialkaos/ek/v12/usage/completion/bash"
Expand All @@ -43,7 +44,7 @@ import (
// Application info
const (
APP = "bibop"
VER = "8.0.3"
VER = "8.0.4"
DESC = "Utility for testing command-line tools"
)

Expand Down Expand Up @@ -114,8 +115,9 @@ func Run(gitRev string, gomod []byte) {

args, errs := options.Parse(optMap)

if len(errs) != 0 {
printError(errs[0].Error())
if !errs.IsEmpty() {
terminal.Error("Options parsing errors:")
terminal.Error(errs.String())
os.Exit(1)
}

Expand Down Expand Up @@ -299,10 +301,10 @@ func validate(e *executor.Executor, r *recipe.Recipe, tags []string) {
return
}

printError("Recipe validation errors:")
terminal.Error("Recipe validation errors:")

for _, err := range errs {
printError(" • %v", err)
terminal.Error(" • %v", err)
}

os.Exit(1)
Expand Down Expand Up @@ -388,18 +390,9 @@ func getRenderer() render.Renderer {
return nil
}

// printError prints error message to console
func printError(f string, a ...interface{}) {
if len(a) == 0 {
fmtc.Fprintln(os.Stderr, "{r}"+f+"{!}")
} else {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
}
}

// printErrorAndExit print error message and exit with exit code 1
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
terminal.Error(f, a...)
os.Exit(1)
}

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module github.com/essentialkaos/bibop

go 1.18
go 1.19

require (
github.com/buger/jsonparser v1.1.1
github.com/creack/pty v1.1.21
github.com/essentialkaos/check v1.4.0
github.com/essentialkaos/ek/v12 v12.113.1
github.com/essentialkaos/ek/v12 v12.125.0
)

require (
github.com/essentialkaos/depsy v1.1.0 // indirect
github.com/essentialkaos/depsy v1.3.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/sys v0.20.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
github.com/essentialkaos/check v1.4.0/go.mod h1:LMKPZ2H+9PXe7Y2gEoKyVAwUqXVgx7KtgibfsHJPus0=
github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
github.com/essentialkaos/ek/v12 v12.113.1 h1:3opV9dwRpIQq1fqg5mkaSEt6ogECL4VLzrH/829qeYg=
github.com/essentialkaos/ek/v12 v12.113.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U=
github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU=
github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
github.com/essentialkaos/ek/v12 v12.125.0 h1:LVtDVESX0Rr0/34ZBOwgmpATaQfoQ/FDExqZyAzQp8I=
github.com/essentialkaos/ek/v12 v12.125.0/go.mod h1:cnS6YLrSZc9Ct7NvS5Qx0/7+sMRcEwPp4vGNHMq95/Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -17,5 +17,5 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 1 addition & 1 deletion scripts/bibop-multi-check
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ checkPackagesAvailability() {
fi

# shellcheck disable=SC2086
aval_list=$(LC_ALL=C yum -q $opts list availabile $pkg_list 2> /dev/null | grep -v 'Available Packages' | tr -s " " | sed 's/\.\(i386\|i686\|x86_64\|el6\|el7\|el7\)//g' | cut -f1,2 -d' ' | tr " " "-")
aval_list=$(LC_ALL=C yum -q $opts list available $pkg_list 2> /dev/null | grep -v 'Available Packages' | tr -s " " | sed 's/\.\(i386\|i686\|x86_64\|el6\|el7\|el7\)//g' | cut -f1,2 -d' ' | tr " " "-")

if [[ -z "$aval_list" ]] ; then
return 1
Expand Down

0 comments on commit 16c47b1

Please sign in to comment.