gvm 安装

本文详细介绍了如何使用GVM(GoVersionManager)安装、管理Go语言版本,包括编译Go1.5+时的bootstrap问题,以及在不同操作系统上的安装要求。还涉及了GVM的包管理功能,如vendoring原生代码和依赖的处理方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Installing

To install:

  1. Install Bison:

    sudo apt-get install bison
    
  2. Install gvm:

    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    

Or if you are using zsh just change bash with zsh

Installing Go

gvm install go1.4
gvm use go1.4 [--default]

Once this is done Go will be in the path and ready to use. $GOROOT and $GOPATH are set automatically.

Additional options can be specified when installing Go:

Usage: gvm install [version] [options]
    -s,  --source=SOURCE      Install Go from specified source.
    -n,  --name=NAME          Override the default name for this version.
    -pb, --with-protobuf      Install Go protocol buffers.
    -b,  --with-build-tools   Install package build tools.
    -B,  --binary             Only install from binary.
         --prefer-binary      Attempt a binary install, falling back to source.
    -h,  --help               Display this message.

A Note on Compiling Go 1.5+

Go 1.5+ removed the C compilers from the toolchain and replaced them with one written in Go. Obviously, this creates a bootstrapping problem if you don't already have a working Go install. In order to compile Go 1.5+, make sure Go 1.4 is installed first. If Go 1.4 won't install try a later version (e.g. go1.5), just make sure you have the -B option after the version number.

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.7

A Note on ARMv6 and ARMv7 architectures (32 bit)

Binary versions for ARMv6 architecture are available starting from Go 1.6. So, it is necessary to bootstrap with an existing binary version, then it will be possible compiling other versions. For instance, to bootstrap a setup, version 1.21.0 may be used:

gvm install go1.21.0 -B
gvm use go1.21.0

And then, compile any other version:

gvm install go1.20.7
To install Go 1.20+

Go 1.20+ requires go1.17.3+. Use the below:

gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20
gvm use go1.20

List Go Versions

To list all installed Go versions (The current version is prefixed with "=>"):

gvm list

To list all Go versions available for download:

gvm listall

Uninstalling

To completely remove gvm and all installed Go versions and packages:

gvm implode

If that doesn't work see the troubleshooting steps at the bottom of this page.

Mac OS X Requirements

  • Install Mercurial from Mercurial SCM
  • Install Xcode Command Line Tools from the App Store.
xcode-select --install
brew update
brew install mercurial

Linux Requirements

Debian/Ubuntu

sudo apt-get install curl git mercurial make binutils bison gcc build-essential

Redhat/Centos

sudo yum install curl
sudo yum install git
sudo yum install make
sudo yum install bison
sudo yum install gcc
sudo yum install glibc-devel

FreeBSD Requirements

sudo pkg_add -r bash
sudo pkg_add -r git
sudo pkg_add -r mercurial

Vendoring Native Code and Dependencies

GVM supports vendoring package set-specific native code and related dependencies, which is useful if you need to qualify a new configuration or version of one of these dependencies against a last-known-good version in an isolated manner. Such behavior is critical to maintaining good release engineering and production environment hygiene.

As a convenience matter, GVM will furnish the following environment variables to aid in this manner if you want to decouple your work from what the operating system provides:

  1. ${GVM_OVERLAY_PREFIX} functions in a manner akin to a root directory hierarchy suitable for auto{conf,make,tools} where it could be passed in to ./configure --prefix=${GVM_OVERLAY_PREFIX} and not conflict with any existing operating system artifacts and hermetically be used by your workspace. This is suitable to use with C{PP,XX}FLAGS and LDFLAGS, but you will have to manage these yourself, since each tool that uses them is different.

  2. ${PATH} includes ${GVM_OVERLAY_PREFIX}/bin so that any tools you manually install will reside there, available for you.

  3. ${LD_LIBRARY_PATH} includes ${GVM_OVERLAY_PREFIX}/lib so that any runtime library searching can be fulfilled there on FreeBSD and Linux.

  4. ${DYLD_LIBRARY_PATH} includes ${GVM_OVERLAY_PREFIX}/lib so that any runtime library searching can be fulfilled there on Mac OS X.

  5. ${PKG_CONFIG_PATH} includes ${GVM_OVERLAY_PREFIX}/lib/pkgconfig so that pkg-config can automatically resolve any vendored dependencies.

Recipe for success:

gvm use go1.1
gvm pkgset use current-known-good
# Let's assume that this includes some C headers and native libraries, which
# Go's CGO facility wraps for us.  Let's assume that these native
# dependencies are at version V.
gvm pkgset create trial-next-version
# Let's assume that V+1 has come along and you want to safely trial it in
# your workspace.
gvm pkgset use trial-next-version
# Do your work here replicating current-known-good from above, but install
# V+1 into ${GVM_OVERLAY_PREFIX}.

See examples/native for a working example.

### GVM 安装方法与配置指南 #### 1. 使用 `gvm-installer` 脚本安装 对于 Mac 和 Linux 用户而言,`gvm-installer` 是一种简便的安装方式。该脚本提供了直观的操作流程,能够快速完成 GVM 的部署[^1]。 ```bash curl -s https://raw.githubusercontent.com/greenbone/gvm-libs/master/scripts/gvm-installer | bash ``` 上述命令会下载并运行 `gvm-installer` 脚本,随后按照提示选择所需的 GVM 版本(如版本 20 或 21),并通过参数 `-v` 指定具体版本号。例如: ```bash sudo ./install_gvm.sh -v 21 -u ``` 此过程完成后即可成功安装 GVM[^2]。 --- #### 2. 在 Fedora 系统上安装 GVM (OpenVAS) 针对 Fedora 发行版用户,可通过以下步骤实现 GVM安装: 1. **获取 Atomic Release RPM** 访问官方资源站点 (`http://www6.atomicorp.com`) 并下载适用于 Fedora 34 的最新原子发行包。 2. **安装 Atomic Release RPM** 执行如下命令以安装已下载的 `.rpm` 文件: ```bash sudo rpm -Uvh atomic-release*rpm ``` 3. **安装 GVM RPM 包** 利用 DNF 工具完成 GVM 的实际安装工作,同时忽略背景校验选项: ```bash sudo dnf install gvm --nogpgcheck ``` 以上三步操作可确保在 Fedora 上顺利完成 GVM 的基础环境搭建[^4]。 --- #### 3. 配置 GVM 及其工具集 为了更好地适配个人需求或企业场景,GVM 提供了灵活多样的配置机制。主要涉及以下几个方面: - **默认配置路径**: 如果希望自定义行为,则可以在用户的家目录下创建名为 `.gvmtools.conf` 的文件来进行全局调整。此类配置涵盖了诸如网络连接细节、预设目标主机以及身份验证凭证等内容[^3]。 - **动态修改配置**: 当前支持借助环境变量的形式即时更改某些属性值。举个例子来说,如果想重新指定 GMP API 地址的话,只需简单声明对应变量即可生效: ```bash export GVM_API_URL="https://your-gmp-server-address" ``` 此外,在项目资料库中还附带了一份示例性质的配置模板——`.gvmtools.conf.example`,它能有效指导初学者理解各项字段含义及其合理取值范围。 --- #### 4. 启动与管理 GVM 功能模块 一旦基本框架构建完毕之后,便可以利用一系列内置子命令来操控整个平台运作状况。比如通过 Python 解析器驱动下的接口程序发起请求动作: ```python from gvm.protocols.latest import Gmp connection = Gmp(username='admin', password='password') response = connection.get_tasks() print(response.xml_str()) ``` 或者直接调用 CLI 实现更便捷的任务调度模式: ```bash gvm-cli socket --xml "<get_tasks/>" ``` 这类交互手段极大地简化了日常运维活动中的复杂度,并提升了工作效率。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值