Apply a patch and compile vim the debian way
From raju
Situation and Task
When using gvim, it is not currently possible to move the tabs by using a mouse [1]. However, there is a patch [2] available to do this. But it is not integrated into the official vim. The idea here is to apply this patch and recompile vim the debian way.
The following vim packages are currently installed on this machine.
rajulocal@hogwarts ~/work/debian/compile_vim % dpkg -l "*vim*" | grep -v iceweasel | grep ^ii ii vim 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor ii vim-common 2:7.4.488-4 amd64 Vi IMproved - Common files ii vim-gtk 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor - with GTK2 GUI ii vim-gui-common 2:7.4.488-4 all Vi IMproved - Common GUI files ii vim-runtime 2:7.4.488-4 all Vi IMproved - Runtime files ii vim-tiny 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor - compact version
Solution
https://wiki.debian.org/BuildingAPackage has some useful instructions on compiling packages the debian way.
<Note to self: It looks like https://wiki.debian.org/BuildingTutorial is a subset of BuildingAPackage>
The following packages are necessary to build any package in debian
% sudo apt-get install build-essential fakeroot devscripts
The debian vim package uses quilt to manage the patches
% sudo apt-get install quilt
Add the necessary deb-src entries in /etc/apt/sources.list . This machine runs a combination of Debian Wheezy (stable) and Jessie (testing). My sources.list looks as below.
% stuff.pl /etc/apt/sources.list deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free deb http://security.debian.org/ wheezy/updates main contrib non-free deb-src http://security.debian.org/ wheezy/updates main contrib non-free deb http://ftp.us.debian.org/debian/ jessie main contrib non-free deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free
where stuff.pl is my own script similar to cat but weeds out comments and empty lines.
Commands below show that gvim is provided by the vim-gtk package
% which gvim /usr/bin/gvim % readlink -f /usr/bin/gvim /usr/bin/vim.gtk % dpkg -S /usr/bin/vim.gtk vim-gtk: /usr/bin/vim.gtk
Install all the dependencies necessary to build vim-gtk
sudo apt-get update sudo apt-get build-dep vim-gtk
Install the vim-gtk source.
rajulocal@hogwarts ~/work/debian/compile_vim % apt-get source vim-gtk Reading package lists... Done Building dependency tree Reading state information... Done Picking 'vim' as source package instead of 'vim-gtk' NOTICE: 'vim' packaging is maintained in the 'Hg' version control system at: http://anonscm.debian.org/hg/pkg-vim/vim Need to get 12.2 MB of source archives. Get:1 http://ftp.us.debian.org/debian/ jessie/main vim 2:7.4.488-4 (dsc) [2,931 B] Get:2 http://ftp.us.debian.org/debian/ jessie/main vim 2:7.4.488-4 (tar) [12.0 MB] Get:3 http://ftp.us.debian.org/debian/ jessie/main vim 2:7.4.488-4 (diff) [153 kB] Fetched 12.2 MB in 5s (2,054 kB/s) dpkg-source: info: extracting vim in vim-7.4.488 dpkg-source: info: unpacking vim_7.4.488.orig.tar.gz dpkg-source: info: unpacking vim_7.4.488-4.debian.tar.xz dpkg-source: info: applying upstream/extra-rst-detection.patch dpkg-source: info: applying upstream/es.po-recover.patch dpkg-source: info: applying upstream/pythoncomplete-autoload-init.patch dpkg-source: info: applying upstream/debcontrol-syntax-vcs-git.patch dpkg-source: info: applying upstream/debian-runtime-versions.patch dpkg-source: info: applying debian/vim-tiny.patch dpkg-source: info: applying debian/disabled-modelines.patch dpkg-source: info: applying debian/extra-tex-detection.patch
Notice how dpkg-source already applied some patches to the upstream source after unpacking the source. Now cd into the source directory.
rajulocal@hogwarts ~/work/debian/compile_vim % ls vim-7.4.488/ vim_7.4.488-4.debian.tar.xz vim_7.4.488-4.dsc vim_7.4.488.orig.tar.gz rajulocal@hogwarts ~/work/debian/compile_vim % cd vim-7.4.488 rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488
Read debian/README.source to understand how to apply patches.
By default, quilt looks in patches directory. But since all our patches are stored in debian/patches, set the QUILT_PATCHES environment variable appropriately.
% grep "export QUILT_PATCHES" ~/.zshrc export QUILT_PATCHES=debian/patches
Download the tabline-dnd.patch from [2] into a temp directory, say ~/x
% ls ~/x/tabline-dnd.patch /home/rajulocal/x/tabline-dnd.patch
Apply all the existing patches
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % quilt push -a File series fully applied, ends at patch debian/patches/debian/extra-tex-detection.patch
Import the patch of interest
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % quilt import -P debian/patches/upstream/tabline-dnd.patch ~/x/tabline-dnd.patch Importing patch /home/rajulocal/x/tabline-dnd.patch (stored as debian/patches/upstream/tabline-dnd.patch)
Apply the new patch
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % quilt push -a Applying patch debian/patches/upstream/tabline-dnd.patch patching file src/gui_gtk_x11.c Hunk #1 succeeded at 2946 (offset 4 lines). Hunk #2 succeeded at 3036 (offset 4 lines). Hunk #3 succeeded at 3406 (offset 8 lines). patching file src/gui_w32.c Hunk #1 succeeded at 4417 (offset -14 lines). Hunk #2 succeeded at 4453 (offset -14 lines). Now at patch debian/patches/upstream/tabline-dnd.patch
update the changelog
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % dch -n
My entry looks as below after the update
vim (2:7.4.488-4.1) UNRELEASED; urgency=medium
* Non-maintainer upload. * Applied the tabline-dnd.patch from https://groups.google.com/forum/#!msg/vim_dev/LnZVZYls1yk/fj_Gz0vhnrsJ in order to move the tabs using mouse
-- Kamaraju Kusumanchi <rajulocal@localhost> Sun, 25 Jan 2015 01:30:45 -0500
recompile the package
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % fakeroot debian/rules clean rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % fakeroot debian/rules binary
Go to the upper level directory once the compilation is finished. Here you will find the newly created .deb packages.
rajulocal@hogwarts ~/work/debian/compile_vim/vim-7.4.488 % cd .. rajulocal@hogwarts ~/work/debian/compile_vim % ls vim-7.4.488/ vim-doc_7.4.488-4.1_all.deb vim_7.4.488-4.1_amd64.deb vim-gnome_7.4.488-4.1_amd64.deb vim_7.4.488-4.debian.tar.xz vim-gtk_7.4.488-4.1_amd64.deb vim_7.4.488-4.dsc vim-gui-common_7.4.488-4.1_all.deb vim_7.4.488.orig.tar.gz vim-lesstif_7.4.488-4.1_all.deb vim-athena_7.4.488-4.1_amd64.deb vim-nox_7.4.488-4.1_amd64.deb vim-common_7.4.488-4.1_amd64.deb vim-runtime_7.4.488-4.1_all.deb vim-dbg_7.4.488-4.1_amd64.deb vim-tiny_7.4.488-4.1_amd64.deb
Install the new packages
rajulocal@hogwarts ~/work/debian/compile_vim % sudo dpkg -i vim-tiny_7.4.488-4.1_amd64.deb vim-runtime_7.4.488-4.1_all.deb vim-common_7.4.488-4.1_amd64.deb vim_7.4.488-4.1_amd64.deb vim-gui-common_7.4.488-4.1_all.deb vim-gtk_7.4.488-4.1_amd64.deb (Reading database ... 237861 files and directories currently installed.) Preparing to unpack vim-tiny_7.4.488-4.1_amd64.deb ... Unpacking vim-tiny (2:7.4.488-4.1) over (2:7.4.488-4) ... Preparing to unpack vim-runtime_7.4.488-4.1_all.deb ... Unpacking vim-runtime (2:7.4.488-4.1) over (2:7.4.488-4) ... Preparing to unpack vim-common_7.4.488-4.1_amd64.deb ... Unpacking vim-common (2:7.4.488-4.1) over (2:7.4.488-4) ... Preparing to unpack vim_7.4.488-4.1_amd64.deb ... Unpacking vim (2:7.4.488-4.1) over (2:7.4.488-4) ... Preparing to unpack vim-gui-common_7.4.488-4.1_all.deb ... Unpacking vim-gui-common (2:7.4.488-4.1) over (2:7.4.488-4) ... Preparing to unpack vim-gtk_7.4.488-4.1_amd64.deb ... Unpacking vim-gtk (2:7.4.488-4.1) over (2:7.4.488-4) ... Setting up vim-runtime (2:7.4.488-4.1) ... Processing /usr/share/vim/addons/doc Setting up vim-common (2:7.4.488-4.1) ... Setting up vim-gui-common (2:7.4.488-4.1) ... Processing triggers for hicolor-icon-theme (0.13-1) ... Processing triggers for desktop-file-utils (0.22-1) ... Setting up vim (2:7.4.488-4.1) ... Setting up vim-gtk (2:7.4.488-4.1) ... Setting up vim-tiny (2:7.4.488-4.1) ... Processing triggers for man-db (2.7.0.2-3) ... Processing triggers for mime-support (3.58) ...
At which point you will see
rajulocal@hogwarts ~/work/debian/compile_vim % dpkg -l "*vim*" | grep -v iceweasel | grep ^ii ii vim 2:7.4.488-4.1 amd64 Vi IMproved - enhanced vi editor ii vim-common 2:7.4.488-4.1 amd64 Vi IMproved - Common files ii vim-gtk 2:7.4.488-4.1 amd64 Vi IMproved - enhanced vi editor - with GTK2 GUI ii vim-gui-common 2:7.4.488-4.1 all Vi IMproved - Common GUI files ii vim-runtime 2:7.4.488-4.1 all Vi IMproved - Runtime files ii vim-tiny 2:7.4.488-4.1 amd64 Vi IMproved - enhanced vi editor - compact version
Test the new gvim
Launch gvim by opening two files in separate tabs and confirm that you can move tabs by dragging the mouse across.
rajulocal@hogwarts ~/work/debian/compile_vim % gvim -p ~/x/junk1.txt ~/x/junk2.txt 2 files to edit
Reverting back
If for some reasaon, you want to revert back to the original gvim
rajulocal@hogwarts ~/work/debian/compile_vim % sudo apt-get install --reinstall vim-tiny=2:7.4.488-4 vim-runtime=2:7.4.488-4 vim-common=2:7.4.488-4 vim=2:7.4.488-4 vim-gui-common=2:7.4.488-4 vim-gtk=2:7.4.488-4
This would return the system back to
rajulocal@hogwarts ~/work/debian/compile_vim % dpkg -l "*vim*" | grep -v iceweasel | grep ^ii ii vim 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor ii vim-common 2:7.4.488-4 amd64 Vi IMproved - Common files ii vim-gtk 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor - with GTK2 GUI ii vim-gui-common 2:7.4.488-4 all Vi IMproved - Common GUI files ii vim-runtime 2:7.4.488-4 all Vi IMproved - Runtime files ii vim-tiny 2:7.4.488-4 amd64 Vi IMproved - enhanced vi editor - compact version
References
[1] - http://vim.1045645.n5.nabble.com/move-tabs-using-mouse-in-gvim-td5723485.html [2] - https://groups.google.com/forum/#!msg/vim_dev/LnZVZYls1yk/fj_Gz0vhnrsJ [3] - https://wiki.debian.org/BuildingAPackage