Vim 7.3 has one really useful built-in feature – Blowfish encryption. With Blowfish encryption, strong encryption of files is now possible using vim. Here is a short tutorial on how to build RPM packages for Vim 7.3 on 64-bit CentOS 5 and CentOS 6. I have built the packages as user ‘root’. However, it is generally not recommended to build packages as ‘root’. Instead, this should be done as a normal user. I have not tried this but if you are interested, you can look at the links in the References section.
- Install rpmbuild and some other tools.
# yum install rpm-build redhat-rpm-config # yum install make gcc
- Download and install vim 7.3 SRPM.
# wget "http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Everything/source/SRPMS/vim-7.3.138-1.fc15.src.rpm" # mkdir -p /usr/src/redhat/ #(for CentOS 5 only) # rpm --nomd5 -ivh vim-7.3.138-1.fc15.src.rpm
- Install vim build dependencies
# grep -i 'BuildRequires:' /usr/src/redhat/SPECS/vim.spec # yum install hunspell-devel python-devel ncurses-devel gettext perl-devel \ perl-ExtUtils-Embed libacl-devel gpm-devel autoconf libselinux-devel ruby-devel ruby \ desktop-file-utils gtk2-devel libSM-devel libXt-devel libXpm-devel
For CentOS 5 only, upgrade autoconf and m4 packages, and remove build dependency on ‘perl-devel’.
# wget "ftp://rpmfind.net/linux/sourceforge/h/project/hp/hphp/CentOS%205%2064bit/RPM/autoconf-2.63-3.noarch.rpm" # wget "ftp://rpmfind.net/linux/sourceforge/h/project/hp/hphp/CentOS%205%2064bit/RPM/m4-1.4.13-4.x86_64.rpm" # rpm -Uvh autoconf-2.63-3.noarch.rpm m4-1.4.13-4.x86_64.rpm # sed -i 's/ perl-devel//' /usr/src/redhat/SPECS/vim.spec
Alternatively, for CentOS 6, you can install the build dependencies using “yum-builddep” command.
# yum install yum-utils # yum-builddep --nogpgcheck vim-7.3.138-1.fc15.src.rpm
- Finally build vim rpms using rpmbuild.
# rpmbuild -ba /usr/src/redhat/SPECS/vim.spec #(for CentOS 5) # rpmbuild -ba ~/rpmbuild/SPECS/vim.spec #(for CentOS 6)
You should find the rpms in /usr/src/redhat/RPMS/x86_64/ (CentOS 5) or ~/rpmbuild/RPMS/x86_64/ (CentOS 6). Unfortunately while the build was successful in CentOS 5, it failed in CentOS 6.
Vim plugin for transparent editing of gpg encrypted files
Although Vim now offers Blowfish encryption, I highly recommend using Vim’s gnupg plugin. The reason being apart from providing strong encryption, this plugin also takes care of not creating swap files and not writing any information to .viminfo file. The easiest way to convert any text file to GPG symmetric encrypted file is by running the command:
# gpg -ac passwords.txt
This will create the file “passwords.txt.asc”. Once the gnupg plugin is installed, vim can be used to open and modify this file.
References
- http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
- http://wiki.centos.org/HowTos/RebuildSRPM
- http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Everything/source/SRPMS/
- http://rpmfind.net/linux/rpm2html/search.php?query=m4
- http://rpmfind.net/linux/rpm2html/search.php?query=autoconf
- http://awesometrousers.net/post/vim-with-gpg-file-encryption/
Leave a Reply to Charles Cancel reply