一个伪linux粉丝的blog
  1. 首页
  2. unix/linux
  3. 正文

Install a newer version of Git on CentOS 7

2021年01月06日 29点热度 0人点赞 0条评论

Install a newer version of Git on CentOS 7

直接docker build 时遇到git版本问题,没想到安装偷懒装一个新版的git还挺折腾,记录一下

起因

系统 CentOS Linux release 7.6.1810 (Core) 自带的一直是  git version 1.8.3.1

然后某天直接 docker build 在线地址时报错

 docker build -t p3terx/openwrt-build-env github.com/P3TERX/openwrt-build-env
提示
unable to prepare context: unable to 'git clone' to temporary context directory: error initializing submodules: usage: git submodule [--quiet] add [-b ] [-f|--force] [--name ] [--reference ] [--] []
   or: git submodule [--quiet] status [--cached] [--recursive] [--] [...]
   or: git submodule [--quiet] init [--] [...]
   or: git submodule [--quiet] deinit [-f|--force] [--] ...
   or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference ] [--merge] [--recursive] [--] [...]
   or: git submodule [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...]
   or: git submodule [--quiet] foreach [--recursive]
   or: git submodule [--quiet] sync [--recursive] [--] [...]
: exit status 1
 原来是 git版本太老,需要升级,折腾许久, 当前3行命令可以完成升级

yum remove git

yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm

yum install git

过程日志如下

[[email protected] ~]# sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager,

          : versionlock

This system is not registered with an entitlement server. You can use subscription-manager to register.

endpoint-repo-1.7-1.x86_64.rpm                           |  10 kB     00:00     

正在检查 /var/tmp/yum-root-xtmc7A/endpoint-repo-1.7-1.x86_64.rpm: endpoint-repo-1.7-1.x86_64

/var/tmp/yum-root-xtmc7A/endpoint-repo-1.7-1.x86_64.rpm 将被安装

正在解决依赖关系

--> 正在检查事务

---> 软件包 endpoint-repo.x86_64.0.1.7-1 将被 安装

--> 解决依赖关系完成

依赖关系解决

================================================================================

Package           架构       版本        源                               大小

================================================================================

正在安装:

endpoint-repo     x86_64     1.7-1       /endpoint-repo-1.7-1.x86_64     3.3 k

事务概要

================================================================================

安装  1 软件包

总计:3.3 k

安装大小:3.3 k

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在安装    : endpoint-repo-1.7-1.x86_64                                  1/1

  验证中      : endpoint-repo-1.7-1.x86_64                                  1/1

已安装:

  endpoint-repo.x86_64 0:1.7-1                                                  

完毕!

[[email protected] ~]#

[[email protected] ~]# sudo yum install git

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager,

          : versionlock

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* epel: mirrors.bfsu.edu.cn

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

endpoint                                                 | 2.9 kB     00:00     

endpoint/7/x86_64/primary_db                               | 603 kB   00:02     

正在解决依赖关系

--> 正在检查事务

---> 软件包 git.x86_64.0.2.24.1-1.ep7 将被 安装

--> 正在处理依赖关系 git-core-doc = 2.24.1-1.ep7,它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 git-core = 2.24.1-1.ep7,它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 perl-Git = 2.24.1-1.ep7,它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 emacs-filesystem >= 24.3,它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 perl(Git::I18N),它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 perl(Git),它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在处理依赖关系 libsecret-1.so.0()(64bit),它被软件包 git-2.24.1-1.ep7.x86_64 需要

--> 正在检查事务

---> 软件包 emacs-filesystem.noarch.1.24.3-23.el7 将被 安装

---> 软件包 git-core.x86_64.0.2.24.1-1.ep7 将被 安装

--> 正在处理依赖关系 libpcre2-8.so.0()(64bit),它被软件包 git-core-2.24.1-1.ep7.x86_64 需要

---> 软件包 git-core-doc.noarch.0.2.24.1-1.ep7 将被 安装

---> 软件包 libsecret.x86_64.0.0.18.6-1.el7 将被 安装

---> 软件包 perl-Git.noarch.0.2.24.1-1.ep7 将被 安装

--> 正在检查事务

---> 软件包 pcre2.x86_64.0.10.23-2.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

================================================================================

Package                架构         版本                  源              大小

================================================================================

正在安装:

git                    x86_64       2.24.1-1.ep7          endpoint       139 k

为依赖而安装:

emacs-filesystem       noarch       1:24.3-23.el7         base            58 k

git-core               x86_64       2.24.1-1.ep7          endpoint       5.1 M

git-core-doc           noarch       2.24.1-1.ep7          endpoint       2.4 M

libsecret              x86_64       0.18.6-1.el7          base           153 k

pcre2                  x86_64       10.23-2.el7           base           201 k

perl-Git               noarch       2.24.1-1.ep7          endpoint        47 k

事务概要

================================================================================

安装  1 软件包 (+6 依赖软件包)

总下载量:8.1 M

安装大小:42 M

Is this ok [y/d/N]: y

Downloading packages:

(1/7): emacs-filesystem-24.3-23.el7.noarch.rpm             |  58 kB   00:00     

(2/7): git-2.24.1-1.ep7.x86_64.rpm                         | 139 kB   00:02     

(3/7): libsecret-0.18.6-1.el7.x86_64.rpm                   | 153 kB   00:00     

(4/7): pcre2-10.23-2.el7.x86_64.rpm                        | 201 kB   00:00     

(5/7): git-core-2.24.1-1.ep7.x86_64.rpm                    | 5.1 MB   00:05     

(6/7): perl-Git-2.24.1-1.ep7.noarch.rpm                    |  47 kB   00:00     

(7/7): git-core-doc-2.24.1-1.ep7.noarch.rpm                | 2.4 MB   00:13     

--------------------------------------------------------------------------------

总计                                               528 kB/s | 8.1 MB  00:15     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  正在安装    : libsecret-0.18.6-1.el7.x86_64                               1/7

  正在安装    : 1:emacs-filesystem-24.3-23.el7.noarch                       2/7

  正在安装    : pcre2-10.23-2.el7.x86_64                                    3/7

  正在安装    : git-core-2.24.1-1.ep7.x86_64                                4/7

  正在安装    : git-core-doc-2.24.1-1.ep7.noarch                            5/7

  正在安装    : perl-Git-2.24.1-1.ep7.noarch                                6/7

  正在安装    : git-2.24.1-1.ep7.x86_64                                     7/7

  验证中      : pcre2-10.23-2.el7.x86_64                                    1/7

  验证中      : git-2.24.1-1.ep7.x86_64                                     2/7

  验证中      : 1:emacs-filesystem-24.3-23.el7.noarch                       3/7

  验证中      : perl-Git-2.24.1-1.ep7.noarch                                4/7

  验证中      : libsecret-0.18.6-1.el7.x86_64                               5/7

  验证中      : git-core-2.24.1-1.ep7.x86_64                                6/7

  验证中      : git-core-doc-2.24.1-1.ep7.noarch                            7/7

已安装:

  git.x86_64 0:2.24.1-1.ep7                                                     

作为依赖被安装:

  emacs-filesystem.noarch 1:24.3-23.el7     git-core.x86_64 0:2.24.1-1.ep7     

  git-core-doc.noarch 0:2.24.1-1.ep7        libsecret.x86_64 0:0.18.6-1.el7    

  pcre2.x86_64 0:10.23-2.el7                perl-Git.noarch 0:2.24.1-1.ep7     

完毕!

检查版本

[[email protected] ~]# git version

git version 2.24.1

升级后,再次执行,一切正常。

打包

docker build -t cnrock/openwrt-build-env github.com/P3TERX/openwrt-build-env

Sending build context to Docker daemon    193kB

Step 1/8 : ARG BASE_IMAGE_TAG=20.04

Step 2/8 : FROM linuxplus/ubuntu:${BASE_IMAGE_TAG}

---> 006b3b9169fa

Step 3/8 : USER root

---> Using cache

---> 6a5b90a63af3

Step 4/8 : ARG DEBIAN_FRONTEND=noninteractive

---> Using cache

---> 0db95e85f7d7

Step 5/8 : ARG DEPENDS_LIST=depends-ubuntu-2004

---> Using cache

---> 0e9e36974720

Step 6/8 : RUN apt-get update -qq &&     apt-get upgrade -qqy &&     apt-get install -qqy $(curl -fsSL git.io/${DEPENDS_LIST}) &&     apt-get clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

---> Using cache

---> 876ed2f573ec

Step 7/8 : USER user

---> Using cache

---> 9bde68cf4487

Step 8/8 : WORKDIR /home/user

---> Using cache

---> 82d5b542cfb2

Successfully built 82d5b542cfb2

Successfully tagged cnrock/openwrt-build-env:latest

Related posts:

  1. how-to-upgrade-kernel-centos
  2. brew-update
  3. CentOS Kernel Upgrade
  4. This system is not registered with an entitlement server
标签: docker git
最后更新:2021年01月05日

WanJie

正经人谁写博客啊?你写博客吗?写出来的那能叫博客?

点赞
< 上一篇
下一篇 >

文章评论

取消回复

分类目录
  • network
  • Uncategorized
  • unix/linux
  • 业界资讯
  • 公司杂事
  • 数码影像
  • 美剧
  • 美图共赏
  • 英语学习

COPYRIGHT © 2008-2021 一个伪linux粉丝的blog. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS