Updating Linux GNU Tar from Source on CentOS

By Adam McQuistan in Linux  09/26/2019 Comment

Introduction

I was recently tasked with migrating a GitLab instance from one ContOS Linux server to another which required creating a backup of the existing system via the gitlab-backup CLI utility. When I read the GitLab docs on creating backups I learned that gitlab-backup requires at least a version of 1.3 for GNU Tar. As of this writing it turns out this is not possible using the yum package manager so, in this article I walk you through how to upgrade the tar compression utiltity from source.

Verifying the Current Version

My natrual assumption is that if you are reading this you are probably facing a similar problem where you don't have the specific version of a software package, tar in this case, available to your system via the package manager yum. However, it will only be a matter of time before the package repository maintainers update their versions to something more current so, before we get too far I'd like to demonstrate how we can check what is currently available before we go side stepping the package manager which should be done as a last ditch effort.

I hop on my server and check the version of tar with yum like so.

$ tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Ok, it is now clear that I have tar 1.26 installed so first things first let me try to use yum to make sure I cannot update it via the package manager.

$ sudo yum update tar
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.web-ster.com
 * epel: mirrors.kernel.org
 * extras: repo1.sea.innoscale.net
 * updates: mirror.web-ster.com
No packages marked for update

Dang. No updates available so, its time to move on to installing from source.

Downloading Tar and Installing from Source

First things first I need to fetch a version of tar that is at least version 1.3 so, I go to the GNU Tar website where it points me in the direction of a FTP server where I can get it from. In this example I am going to grab the http://ftp.gnu.org/gnu/tar/tar-1.32.tar.gz tar software using wget but, I first need to install wget like so.

$ sudo yum install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.web-ster.com
 * epel: mirrors.kernel.org
 * extras: repo1.sea.innoscale.net
 * updates: mirror.web-ster.com
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                              Arch                                   Version                                         Repository                            Size
========================================================================================================================================================================
Installing:
 wget                                 x86_64                                 1.14-18.el7_6.1                                 base                                 547 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package

Total download size: 547 k
Installed size: 2.0 M
Is this ok [y/d/N]: Y
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm                                                                                                                  | 547 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                                                                                                          1/1 
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                                                                                                          1/1 

Installed:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                                                                         

Complete!

Now I can download the tar source using the following.

$ wget http://ftp.gnu.org/gnu/tar/tar-1.32.tar.gz
--2019-09-26 13:44:28--  http://ftp.gnu.org/gnu/tar/tar-1.32.tar.gz
Resolving ftp.gnu.org (ftp.gnu.org)... 209.51.188.20, 2001:470:142:3::b
Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4242595 (4.0M) [application/x-gzip]
Saving to: ‘tar-1.32.tar.gz’

100%[==============================================================================================================================>] 4,242,595   6.04MB/s   in 0.7s   

2019-09-26 13:44:29 (6.04 MB/s) - ‘tar-1.32.tar.gz’ saved [4242595/4242595]

Next up I extract the archive.

$ gunzip tar-1.32.tar.gz
$ tar xf tar-1.32.tar 
$ ls -l
total 17424
drwxr-xr-x. 12 adam adam     4096 Feb 23  2019 tar-1.32
-rw-r--r--.  1 adam adam   17838080 Feb 23  2019 tar-1.32.tar

Now I can peek inside the extracted tar-1.32 directory and look for installation instructions.

$ ls -l tar-1.32
total 2252
-rw-r--r--. 1 adam adam   79584 Dec  5  2015 ABOUT-NLS
-rw-r--r--. 1 adam adam    2282 Jan  2  2019 acinclude.m4
-rw-r--r--. 1 adam adam   49459 Feb 23  2019 aclocal.m4
-rw-r--r--. 1 adam adam     601 Jan  2  2019 AUTHORS
drwxr-xr-x. 2 adam adam    4096 Feb 23  2019 build-aux
-rw-r--r--. 1 adam adam  534084 Feb 23  2019 ChangeLog
-rw-r--r--. 1 adam adam  206632 Jan  2  2019 ChangeLog.1
-rw-rw-r--. 1 adam adam   75896 Sep 26 14:03 config.h
-rw-r--r--. 1 adam adam   72873 Feb 23  2019 config.h.in
-rwxr-xr-x. 1 adam adam 1023346 Feb 23  2019 configure
-rw-r--r--. 1 adam adam   12685 Feb 23  2019 configure.ac
-rw-r--r--. 1 adam adam   35147 Jan  2  2019 COPYING
drwxr-xr-x. 2 adam adam    4096 Sep 26 14:03 doc
drwxr-xr-x. 6 adam adam   16384 Sep 26 14:04 gnu
-rw-r--r--. 1 adam adam   15756 Jan  2  2019 INSTALL
drwxr-xr-x. 3 adam adam    4096 Sep 26 14:04 lib
drwxr-xr-x. 2 adam adam    8192 Feb 23  2019 m4
-rw-rw-r--. 1 adam adam   56091 Sep 26 14:03 Makefile
-rw-r--r--. 1 adam adam    1207 Jan  2  2019 Makefile.am
-rw-r--r--. 1 adam adam   68334 Feb 23  2019 Makefile.in
-rw-r--r--. 1 adam adam    2822 Dec  5  2015 Make.rules
-rw-r--r--. 1 adam adam   64136 Feb 23  2019 NEWS
drwxr-xr-x. 2 adam adam    4096 Sep 26 14:03 po
-rw-r--r--. 1 adam adam    9756 Jan  2  2019 README
drwxr-xr-x. 3 adam adam     103 Sep 26 14:04 rmt
drwxr-xr-x. 2 adam adam    4096 Sep 26 14:03 scripts
drwxr-xr-x. 3 adam adam    4096 Sep 26 14:04 src
-rw-rw-r--. 1 adam adam      23 Sep 26 14:03 stamp-h1
drwxr-xr-x. 5 adam adam    8192 Sep 26 14:03 tests
-rw-r--r--. 1 adam adam   20500 Jan 14  2019 THANKS
-rw-r--r--. 1 adam adam    2151 Jan  2  2019 TODO

Check that out, there is a file named INSTALL and inside that file are detailed instructions of how to build this package from source. Amazing!

To start I change directory into the tar-1.32 directory and configure the build.

$ ./configure
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/tar-1.32':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

Oops! Looks like I need a C compiler. I can get one of those by installing the Development Tools packages group. I'm omitting the output because it's quite verbose.

$ sudo yum group install "Development Tools" -y

This time when I configure the tar build everything checks out. Again, for the next few commands I will omit the output as its very verbose.

$ ./configure

Now I can run the make commands to compile and install the program.

$ sudo make

then

$ sudo make install

I check the version of tar to verify the program was updated.

$ tar --version
tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

If you run the command above and still see the old version then its likely because you need to refresh your user environment which you can do by sourcing your user shell scripts (ie, .bashrc, .bash_profile). A quick way to do this is exit out of your current user and su back to that user or, a simple su - username as shown below.

$ tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
$ which tar
/usr/local/bin/tar
$ /usr/local/bin/tar --version
tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
$ su - adam
Password: 
Last login: Fri Oct 18 04:09:12 UTC 2019 on pts/0
$ tar --version
tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Awesome, mission complete!

Resources for Learning More About Linux and System Administration

thecodinginterface.com earns commision from sales of linked products such as the books above. This enables providing continued free tutorials and content so, thank you for supporting the authors of these resources as well as thecodinginterface.com

Conclusion

In this article I have demonstrated how to install the tar command line compression utility from source on a CentOS. Although I generally don't recommend side stepping the system package manager, yum in this case, there are times such as the one I describe for this article where it is necessary as an exception to that rule.

Share with friends and colleagues

[[ likes ]] likes

Navigation

Community favorites for Linux

theCodingInterface