尝试按照Github上的说明安装一个工具,但在尝试运行时出现错误。

huangapple go评论90阅读模式
英文:

Attempted to install a tool using the instructions on Github but get a error when try to run

问题

我显然不熟悉从Github仓库构建,但我真的很需要一些帮助。

操作系统:Kali Linux(5.15.0-kali2-amd64)

我正在尝试按照这里的说明构建:https://github.com/Tripwire/padcheck

构建似乎安装成功:

sudo docker build . -t padcheck

使用podman模拟Docker CLI。创建/etc/containers/nodocker以静音消息。
步骤1/15:FROM alpine:3.9
步骤2/15:RUN apk add --no-cache               ca-certificates
--> 使用缓存d7c12b042fcc42a2ef3ec1733900a720263cf64b8d69cbd05b1189133a8f2f8e
--> d7c12b042fc
步骤3/15:RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
--> 使用缓存7feea938c3cf5def2e55edbe0f515c83ec3a608a045f6f15ac3ead6448fae86b
--> 7feea938c3c
步骤4/15:COPY ./paddingmodes-go1.11.diff /tmp/paddingmodes-go1.11.diff
--> 使用缓存dc9c476290cadbfce6c23b5c86fe7cac8a92f52924ab537680be72341a389641
--> dc9c476290c
步骤5/15:ENV GOLANG_VERSION 1.11.5
--> 使用缓存14ad60e2e84e634cfa252abad776eeb513752eefee542de803950bbfb64be5b7
--> 14ad60e2e84
步骤6/15:RUN set -eux;        apk add --no-cache --virtual .build-deps                bash            gcc        musl-dev                 openssl                 go      ;       export          GOROOT_BOOTSTRAP="$(go env GOROOT)"GOOS="$(go env GOOS)"            GOARCH="$(go env GOARCH)"               GOHOSTOS="$(go env GOHOSTOS)"           GOHOSTARCH="$(go env GOHOSTARCH)"   ;       apkArch="$(apk --print-arch)";  case "$apkArch" in              armhf) export GOARM='6' ;;          x86) export GO386='387' ;;      esac;           wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz";        echo 'bc1ef02bb1668835db1390a2e478dcbccb5dd16911691af9d75184bbe5aa943e *go.tgz' | sha256sum -c -;   tar -C /usr/local -xzf go.tgz;  rm go.tgz;              cd /usr/local/go/src;   patch -p2 < /tmp/paddingmodes-go1.11.diff;  rm /tmp/paddingmodes-go1.11.diff;       ./make.bash;            rm -rf          /usr/local/go/pkg/bootstrap                 /usr/local/go/pkg/obj   ;       apk del .build-deps;            export PATH="/usr/local/go/bin:$PATH";      go version
--> 使用缓存9299711dd2046598f08f1dedceb322af2d2723797664a698a4f322290d37e097
--> 9299711dd20
步骤7/15:ENV GOPATH /go
--> 使用缓存7b9bebc3e577b5e6976b16a7c9e21115959836b06f49f87d693f924245769478
--> 7b9bebc3e57
步骤8/15:ENV GOBIN $GOPATH/bin
--> 使用缓存7ffb2e13401e316132b5d0572e5313eab602ecb91bb9a7d60a8e4b0f5d5391b2
--> 7ffb2e13401
步骤9/15:ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
--> 使用缓存18ae898383c2553a814df7913e3be77123e8a6a3673ae2d17ea4feaf50f06410
--> 18ae898383c
步骤10/15:RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
--> 使用缓存03ae353817062bf2f135999e0ba4b01dc3dcb23e7da6e48f6990ed9502b5379b
--> 03ae3538170
步骤11/15:WORKDIR $GOPATH
--> 使用缓存d01b2a8bb52880b155919645013b3dc4b548a8da4feae75892b75f115eb83b11
--> d01b2a8bb52
步骤12/15:COPY padcheck.go /go/src
--> 使用缓存1435510254fccb68633b033e0e88da685215f34420094cfb695bd230fe64493b
--> 1435510254f
步骤13/15:RUN cd /go/src && go install padcheck.go
--> 使用缓存82a8ba8ed6255289ea31e26ecc341d58ddef964e201a644902a8294ad8cb5ba9
--> 82a8ba8ed62
步骤14/15:ENTRYPOINT ["/go/bin/padcheck"]
--> 使用缓存6fcadceec4f2de2365d84ae96a7e9906727709ecfe46cd4f692299ca1a41f650
--> 6fcadceec4f
步骤15/15:CMD ["-h"]
--> 使用缓存80892f2bf809ca96bfd6abb7ff049353edde423964804a194d0ff6e39af44c39
提交padcheck
--> 80892f2bf80
成功标记localhost/padcheck:latest
80892f2bf809ca96bfd6abb7ff049353edde423964804a194d0ff6e39af44c39

但是当我运行(使用docker run --rm -it padcheck)时:

使用podman模拟Docker CLI。创建/etc/containers/nodocker以静音消息。
错误:短名称“padcheck”未解析为别名,并且在“/etc/containers/registries.conf”中未定义未限定搜索的注册表。

并且使用golang-go:

sudo ./build.sh

--2022-02-22 10:49:41--  https://github.com/golang/go/archive/go1.11.tar.gz
正在解析 github.com (github.com)... 140.82.121.3
正在连接 github.com (github.com)|140.82.121.3|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://codeload.github.com/golang/go/tar.gz/refs/tags/go1.11 [跟随至]
--2022-02-22 10:49:42--  https://codeload.github.com/golang/go/tar.gz/refs/tags/go1.11
正在解析 codeload.github.com (codeload.github.com)... 140.82.121.9
正在连接 codeload.github.com (codeload.github.com)|140.82.121.9|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:21058849 (20M) [application/x-gzip]
正在保存至: “go1.11.tar.gz.2”

go1.11.tar.gz.2              100%[==============================================>]  20.08M  14.0MB/s    in 1.4s

2022-02-22 10:49:43 (14.0 MB/s) - 已保存 “go1.11.tar.gz.2” [21058849/21058849]

正在打补丁文件 src/crypto/tls/common.go
正在打补丁文件 src/crypto/tls/conn.go
正在打补丁文件 src/crypto/tls/handshake_client.go
正在打补丁文件 src/crypto/tls/handshake_server.go
使用 /usr/lib/go-1.17 构建 Go cmd/dist。
go: 无法找到主模块,但在 /home/padcheck 中找到 .git/config
        要在那里创建一个模块,请运行:
        cd ../.. && go mod init

┌──
└─$ cd /home/padcheck && go mod init

go: 无法确定源目录 /home/padcheck 的模块路径(在GOPATH之外,必须指定模块路径)

示例用法:
        'go mod init example.com/m' 初始化 v0 或 v1 模块
        'go mod init example.com/m/v2' 初始化 v2 模块

运行 'go help mod init' 以获取更多信息。
英文:

I am ovbviously not au fait with building from Github repos but would really appreciate some help.

OS: Kali Linux (5.15.0-kali2-amd64)

I am trying to build per the instructions here: https://github.com/Tripwire/padcheck

The build seems to install OK:

sudo docker build . -t padcheck

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
STEP 1/15: FROM alpine:3.9
STEP 2/15: RUN apk add --no-cache               ca-certificates
--> Using cache d7c12b042fcc42a2ef3ec1733900a720263cf64b8d69cbd05b1189133a8f2f8e
--> d7c12b042fc
STEP 3/15: RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
--> Using cache 7feea938c3cf5def2e55edbe0f515c83ec3a608a045f6f15ac3ead6448fae86b
--> 7feea938c3c
STEP 4/15: COPY ./paddingmodes-go1.11.diff /tmp/paddingmodes-go1.11.diff
--> Using cache dc9c476290cadbfce6c23b5c86fe7cac8a92f52924ab537680be72341a389641
--> dc9c476290c
STEP 5/15: ENV GOLANG_VERSION 1.11.5
--> Using cache 14ad60e2e84e634cfa252abad776eeb513752eefee542de803950bbfb64be5b7
--> 14ad60e2e84
STEP 6/15: RUN set -eux;        apk add --no-cache --virtual .build-deps                bash            gcc        musl-dev                 openssl                 go      ;       export          GOROOT_BOOTSTRAP="$(go env GOROOT)"GOOS="$(go env GOOS)"            GOARCH="$(go env GOARCH)"               GOHOSTOS="$(go env GOHOSTOS)"           GOHOSTARCH="$(go env GOHOSTARCH)"   ;       apkArch="$(apk --print-arch)";  case "$apkArch" in              armhf) export GOARM='6' ;;          x86) export GO386='387' ;;      esac;           wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz";        echo 'bc1ef02bb1668835db1390a2e478dcbccb5dd16911691af9d75184bbe5aa943e *go.tgz' | sha256sum -c -;   tar -C /usr/local -xzf go.tgz;  rm go.tgz;              cd /usr/local/go/src;   patch -p2 < /tmp/paddingmodes-go1.11.diff;  rm /tmp/paddingmodes-go1.11.diff;       ./make.bash;            rm -rf          /usr/local/go/pkg/bootstrap                 /usr/local/go/pkg/obj   ;       apk del .build-deps;            export PATH="/usr/local/go/bin:$PATH";      go version
--> Using cache 9299711dd2046598f08f1dedceb322af2d2723797664a698a4f322290d37e097
--> 9299711dd20
STEP 7/15: ENV GOPATH /go
--> Using cache 7b9bebc3e577b5e6976b16a7c9e21115959836b06f49f87d693f924245769478
--> 7b9bebc3e57
STEP 8/15: ENV GOBIN $GOPATH/bin
--> Using cache 7ffb2e13401e316132b5d0572e5313eab602ecb91bb9a7d60a8e4b0f5d5391b2
--> 7ffb2e13401
STEP 9/15: ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
--> Using cache 18ae898383c2553a814df7913e3be77123e8a6a3673ae2d17ea4feaf50f06410
--> 18ae898383c
STEP 10/15: RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
--> Using cache 03ae353817062bf2f135999e0ba4b01dc3dcb23e7da6e48f6990ed9502b5379b
--> 03ae3538170
STEP 11/15: WORKDIR $GOPATH
--> Using cache d01b2a8bb52880b155919645013b3dc4b548a8da4feae75892b75f115eb83b11
--> d01b2a8bb52
STEP 12/15: COPY padcheck.go /go/src
--> Using cache 1435510254fccb68633b033e0e88da685215f34420094cfb695bd230fe64493b
--> 1435510254f
STEP 13/15: RUN cd /go/src && go install padcheck.go
--> Using cache 82a8ba8ed6255289ea31e26ecc341d58ddef964e201a644902a8294ad8cb5ba9
--> 82a8ba8ed62
STEP 14/15: ENTRYPOINT ["/go/bin/padcheck"]
--> Using cache 6fcadceec4f2de2365d84ae96a7e9906727709ecfe46cd4f692299ca1a41f650
--> 6fcadceec4f
STEP 15/15: CMD ["-h"]
--> Using cache 80892f2bf809ca96bfd6abb7ff049353edde423964804a194d0ff6e39af44c39
COMMIT padcheck
--> 80892f2bf80
Successfully tagged localhost/padcheck:latest
80892f2bf809ca96bfd6abb7ff049353edde423964804a194d0ff6e39af44c39

But when I run (using docker run --rm -it padcheck):

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Error: short-name "padcheck" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"

And using golang-go:

sudo ./build.sh

--2022-02-22 10:49:41--  https://github.com/golang/go/archive/go1.11.tar.gz
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/golang/go/tar.gz/refs/tags/go1.11 [following]
--2022-02-22 10:49:42--  https://codeload.github.com/golang/go/tar.gz/refs/tags/go1.11
Resolving codeload.github.com (codeload.github.com)... 140.82.121.9
Connecting to codeload.github.com (codeload.github.com)|140.82.121.9|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21058849 (20M) [application/x-gzip]
Saving to: ‘go1.11.tar.gz.2’

go1.11.tar.gz.2              100%[==============================================>]  20.08M  14.0MB/s    in 1.4s

2022-02-22 10:49:43 (14.0 MB/s) - ‘go1.11.tar.gz.2’ saved [21058849/21058849]

patching file src/crypto/tls/common.go
patching file src/crypto/tls/conn.go
patching file src/crypto/tls/handshake_client.go
patching file src/crypto/tls/handshake_server.go
Building Go cmd/dist using /usr/lib/go-1.17.
go: cannot find main module, but found .git/config in /home/padcheck
        to create a module there, run:
        cd ../.. && go mod init

┌──
└─$ cd /home/padcheck && go mod init

go: cannot determine module path for source directory /home/padcheck (outside GOPATH, module path must be specified)

Example usage:
        'go mod init example.com/m' to initialize a v0 or v1 module
        'go mod init example.com/m/v2' to initialize a v2 module

Run 'go help mod init' for more information.

答案1

得分: 1

你正在尝试运行padcheck,但是你的容器被称为localhost/padcheck,你可以在构建输出的倒数第二行看到:

Successfully tagged localhost/padcheck:latest

请使用docker run --rm -ti localhost/padcheck来运行它。

至于golang的问题:
该脚本正在下载golang 1.11,其中更频繁地可能会有没有gomod的项目,因此在该存储库中不存在gomod文件。
然而,你可以像下面这样“修复”它:

$ go mod init github.com/Tripwire/padcheck/m/v2
go: creating new go.mod: module github.com/Tripwire/padcheck/m/v2
go: to add module requirements and sums:
        go mod tidy
$ go mod tidy

英文:

You're trying to run padcheck but your container is called localhost/padcheck as you can see in the second to last line of your build output:

Successfully tagged localhost/padcheck:latest

Run it like docker run --rm -ti localhost/padcheck instead

As for the golang problem:
The script is downloading golang 1.11 in which you could have projects without a gomod more frequently, hence no gomod files exist in that repo.
However, you can "fix" this like follows:

$ go mod init github.com/Tripwire/padcheck/m/v2
go: creating new go.mod: module github.com/Tripwire/padcheck/m/v2
go: to add module requirements and sums:
        go mod tidy
$ go mod tidy

huangapple
  • 本文由 发表于 2022年2月22日 19:41:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/71220681.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定