Compile custom lftp for CentOS 7.x

I use lftp to do a lot of backups.  rsync would be my preferred solution, but when I have to back up a large repository of files from a Windows machine rsync isn’t an option.

I’ve found Red Hat or CentOS keeps lftp woefully out of date.   I found some annoying bugs in the in older versions (specifically it chokes on some Windows files with unusual names and spacing).  This is how how installed lftp for CentOS 7.

Step 1: get your build environment and dependencies

yum install rpm-build ncurses-devel gnutls-devel readline-devel

You may have other dependencies, but those are the ones that seem to typically be missing.

Step 2: create a spec file

I am putting the build treen in /root/rpmbuild. The spec file contains build information.  Run

mkdir -p /root/rpmbuild/SPECS/ && nano /root/rpmbuild/SPECS/lftp.spec

And then create the following file:

Summary:    A sophisticated file transfer program
Name:        lftp                                                                                                                                                                                                
Version:    4.7.5
Release:    3%{?dist}
License:    GPLv3+
Group:        Applications/Internet
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:    ncurses-devel, gnutls-devel, pkgconfig, readline-devel, gettext
LFTP is a sophisticated ftp/http file transfer program. Like bash, it has job
control and uses the readline library for input. It has bookmarks, built-in
mirroring, and can transfer several files in parallel. It is designed with
reliability in mind.
%package scripts
Summary:    Scripts for lftp
Group:        Applications/Internet
Requires:    lftp >= %{version}-%{release}
BuildArch:    noarch
%description scripts
Utility scripts for use with lftp.
%setup -q
#sed -i.rpath -e '/lftp_cv_openssl/s|-R.*lib||' configure
sed -i.norpath -e \
   '/sys_lib_dlsearch_path_spec/s|/usr/lib |/usr/lib /usr/lib64 /lib64 |' \
%configure --with-modules --disable-static --with-gnutls --without-openssl --with-debug
make %{?_smp_mflags}
export tagname=CC
make DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' install
chmod 0755 $RPM_BUILD_ROOT%{_libdir}/lftp/*
chmod 0755 $RPM_BUILD_ROOT%{_libdir}/lftp/%{version}/*.so
iconv -f ISO88591 -t UTF8 NEWS -o NEWS.tmp
touch -c -r NEWS NEWS.tmp
mv NEWS.tmp NEWS
# Remove files from $RPM_BUILD_ROOT that we aren't shipping.
#rm $RPM_BUILD_ROOT%{_libdir}/lftp/%{version}/*.la
rm $RPM_BUILD_ROOT%{_libdir}/
rm $RPM_BUILD_ROOT%{_libdir}/
rm $RPM_BUILD_ROOT%{_libdir}/
rm $RPM_BUILD_ROOT%{_libdir}/
%find_lang %{name}
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files -f %{name}.lang
%config(noreplace) %{_sysconfdir}/lftp.conf
%dir %{_libdir}/lftp
%dir %{_libdir}/lftp/%{version}
%files scripts

You can download a spec file for lftp here, but you will need to make some modifications.  The version needs to be changed to the version you downloaded, and I removed references to distro-specific patches. (I actually have no idea what these patches do, but they are several versions old.)

Step 3: download the source

In my example, I downloaded lftp version 4.7.5.

mkdir -p /root/rpmbuild/SOURCES/ && cd /root/rpmbuild/SOURCES/ && wget

Step 4: build

rpmbuild -ba lftp.spec

Step 5: install

rpm -ivvh /root/rpmbuild/RPMS/x86_64/lftp-4.7.5-3.el7.centos.x86_64.rpm

You can use the command rpm -qa lftp to confirmation successful installation.

Leave a Reply

Your email address will not be published. Required fields are marked *