简体   繁体   English

如何在Alpine Docker映像上安装gdbserver软件包?

[英]How to install gdbserver package on Alpine Docker image?

I've been trying to install gdbserver package on Alpine Docker image ( https://hub.docker.com/_/alpine/ ) 我一直在尝试在Alpine Docker映像( https://hub.docker.com/_/alpine/ )上安装gdbserver软件包

apk add gdbserver apk添加gdbserver

was giving me this: 给我这个:

ERROR: unsatisfiable constraints: gdbserver (missing): required by: world[gdbserver] 错误:约束无法满足:gdbserver(丢失):世界需要:[gdbserver]

At the same time, 同时,

apk add gdb apk添加gdb

works just fine. 效果很好。 So, what's the correct way to install the gdbserver package on Alpine? 那么,在Alpine上安装gdbserver软件包的正确方法是什么?

PS 聚苯乙烯

apk update has been executed before everything else. apk更新已被执行。

Currently it seems that gdbserver is not a package available at the alpine repositories and the gdb package does not contain gdbserver. 当前,gdbserver似乎不是高山存储库中可用的软件包,并且gdb软件包不包含gdbserver。

But you can install gdb from source which contains gdbserver. 但是您可以从包含gdbserver的源代码安装gdb。

First you will need to install the required packages for the compilation: 首先,您需要安装编译所需的软件包:

apk add --no-cache make
apk add --no-cache linux-headers
apk add --no-cache texinfo
apk add --no-cache gcc
apk add --no-cache g++

then you can install it , downloading the source and compiling it: 然后您可以安装它,下载源代码并进行编译:

wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz
tar -xvf gdb-7.11.tar.xz
cd gdb-7.11
./configure --prefix=/usr
make
make -C gdb install

After that you should be able to run gdbserver from the shell. 之后,您应该可以从外壳程序运行gdbserver。

I have been using this procedure in Docker, with the following dockerfile which also includes a ssh server installation: 我在Docker中一直使用此过程,下面的dockerfile也包括ssh服务器安装:

FROM alpine
RUN apk update
# we need make and linux-headers to compile gdb
RUN apk add --no-cache make
RUN apk add --no-cache linux-headers
RUN apk add --no-cache texinfo
RUN apk add --no-cache gcc
RUN apk add --no-cache g++
RUN apk add --no-cache gfortran
# install gdb
# RUN apk add --no-cache gdb
RUN mkdir gdb-build ;\
    cd gdb-build;\
    wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz;\
    tar -xvf gdb-7.11.tar.xz;\
    cd gdb-7.11;\
    ./configure --prefix=/usr;\
    make;\
    make -C gdb install;\
    cd ..;\
    rm -rf gdb-build/;
# install ssh server support and keys
RUN apk add --no-cache openssh
RUN ssh-keygen -A

With Alpine 3.8 and newer ( gdb >= 8.0.1-r6 ), gdbserver is readily available as part of the gdb package: 使用Alpine 3.8和更高版本( gdb > = 8.0.1-r6 ), gdbserver可以作为gdb软件包的一部分轻松使用:

https://pkgs.alpinelinux.org/contents?file=gdbserver&path=&name=gdb&branch=v3.8&repo=main&arch=x86_64 https://pkgs.alpinelinux.org/contents?file=gdbserver&path=&name=gdb&branch=v3.8&repo=main&arch=x86_64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM