Ubuntu – How to downgrade Gedit to a previous (3.10.4) Version in Ubuntu 16.04 LTS

16.04downgradegedit

As the title already says: I have some plug-ins which don't run with gedit 3.18.3 which is shipped with Ubuntu 16.04 LTS.

How can I downgrade to the version 3.10.4 which was used in Ubuntu 14.04 LTS and Ubuntu 15.10 and get all the plug-ins possible installed?

And how do I revert it back to 3.18.3 if 3.10.4 is not needed any more.

Best Answer

The solution is quite complicated so make sure you read and proceed carefully. As preparation to this make sure you enabled all packet sources so your /etc/apt/sources.list looks like this and do an upgrade:

sudo apt-get update
sudo apt-get dist-upgrade
reboot

To install the old version:

Then as a first step, you need to remove the existing version of gedit. To do so run the following commands in your terminal (ctrl+alt+t):

# this installs the build dependencies
sudo apt-get build-dep gedit gedit-plugins
sudo apt-get install moreutils

# this uninstalls the 3.18.3 version of gedit, gedit-dev, 
# gedit-plugins and gedit-common and should get rid of everything else
# installed for gedit
sudo apt-get remove gedit gedit-dev gedit-plugins gedit-common

Now prepare a directory to work in. For convenience we do that in our home directory.

# creating directory and switching to it
mkdir ~/gedit-downgrade
cd ~/gedit-downgrade

Next step is to create a wget-list file to make the download easier (you can copy and paste the whole field into your terminal). If you're not using a 64-bit system you might want to find the proper links for i386 here.

cat > wget-list << "EOF"
http://mirrors.kernel.org/ubuntu/pool/main/g/gedit/gedit-common_3.10.4-0ubuntu13_all.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gedit/gedit_3.10.4-0ubuntu13_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/main/g/gedit/gedit-dev_3.10.4-0ubuntu13_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-developer-plugins/gedit-developer-plugins_0.5.15-0ubuntu1_all.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-latex-plugin/gedit-latex-plugin_3.8.0-3build1_all.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-plugins/gedit-plugins_3.10.1-1ubuntu3_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-r-plugin/gedit-r-plugin_0.8.0.2-Gtk3-Python3-1ubuntu1_all.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-source-code-browser-plugin/gedit-source-code-browser-plugin_3.0.3-3_all.deb
http://mirrors.kernel.org/ubuntu/pool/universe/g/gedit-valencia-plugin/gedit-valencia-plugin_0.8.0-0ubuntu2_amd64.deb
http://mirrors.kernel.org/ubuntu/pool/universe/r/rabbitvcs/rabbitvcs-gedit_0.16-1_all.deb
http://mirrors.kernel.org/ubuntu/pool/universe/s/supercollider/supercollider-gedit_3.6.6~repack-2-1build1_all.deb
EOF

Now you have that wget-list file, you can download everything in one go by typing wget -i wget-list, let the files download and then begin your installation.

Please follow below steps one by one and if you run into dependency errors simply do sudo apt-get remove <package-name> which reflects the package giving trouble, then install the dependencies by hand with sudo apt-get install <package-name> then do the dpkg line again. Do not, and I mean do not run sudo apt-get -f install while you're trying this installation: it will mess everything up.

Now, let's begin with the essential packages (tested and working on a clean 16.04 LTS installation):

# install gedit-common (essential needed)
sudo dpkg -i gedit-common_3.10.4-0ubuntu13_all.deb

# install gedit (essential needed)
sudo dpkg -i gedit_3.10.4-0ubuntu13_amd64.deb

# install gedit-dev (essential needed)
sudo dpkg -i gedit-dev_3.10.4-0ubuntu13_amd64.deb 

# install gedit-plugins (essential needed)
# here are some steps needed follow them carefully

    # unpacking the .deb file
    sudo dpkg-deb -R gedit-plugins_3.10.1-1ubuntu3_amd64.deb tmp

    # editing tmp/DEBIAN/control:
    # change 'python3 (<< 3.5), python3 (>= 3.4~), python3.4' to 'python3 (>= 3.5~), python3.5'
    sed 's/python3 (<< 3\.5), python3 (>= 3\.4~), python3\.4/python3 (>= 3.5~), python3.5/' tmp/DEBIAN/control | sudo sponge tmp/DEBIAN/control

    # editing tmp/DEBIAN/postinst
    # change 'py3compile -p gedit-plugins /usr/lib/x86_64-linux-gnu/gedit/plugins -V 3.4' to
    # 'py3compile -p gedit-plugins /usr/lib/x86_64-linux-gnu/gedit/plugins -V 3.5'
    sed 's/3\.4/3.5/' tmp/DEBIAN/postinst | sudo sponge tmp/DEBIAN/postinst

    # packing a new .deb file 
    sudo dpkg-deb -b tmp gedit-plugins_3.10.1-1ubuntu4_amd64.deb

    # changing ownership of the new .deb file replace username with your username
    sudo chown username:username gedit-plugins_3.10.1-1ubuntu4_amd64.deb

    # removing tmp
    sudo rm -rfv tmp

    # installing it
    sudo dpkg -i gedit-plugins_3.10.1-1ubuntu4_amd64.deb

The following packages are only optional and you should be able to install them easily, the dependencies to download are given and tested on a clean 16.04 LTS install like the above.

# install gedit-developer-plugins (optional)
sudo apt-get install python-pocket-lint
sudo dpkg -i gedit-developer-plugins_0.5.15-0ubuntu1_all.deb

# install gedit-latex-plugin (optional)
sudo apt-get install rubber
sudo dpkg -i gedit-latex-plugin_3.8.0-3build1_all.deb

# install gedit-r-plugin (optional but needs gedit-plugins)
sudo dpkg -i gedit-r-plugin_0.8.0.2-Gtk3-Python3-1ubuntu1_all.deb 

# install gedit-source-code-browser-plugin (optional)
sudo apt-get install ctags
sudo dpkg -i gedit-source-code-browser-plugin_3.0.3-3_all.deb

# install gedit-valencia-plugin (optional)

    # unpacking .deb file
    sudo dpkg-deb -R gedit-valencia-plugin_0.8.0-0ubuntu2_amd64.deb tmp

    # edit tmp/DEBIAN/control
    # change 'libvala-0.28-0 (>= 0.15.1)' to 'libvala-0.30-0 (>= 0.15.1)'
    # change 'libvte-2.90-9 (>= 1:0.27.2)' to 'libvte-2.91-0 (>= 0.27.2)'
    sed -e 's/libvala-0\.28-0 (>= 0\.15\.1)/libvala-0.30-0 (>= 0.15.1)/' -e 's/libvte-2\.90-9 (>= 1:0\.27\.2)/libvte-2.91-0 (>= 0.27.2)/' tmp/DEBIAN/control | sudo sponge tmp/DEBIAN/control

    # packing a new .deb file 
    sudo dpkg-deb -b tmp gedit-valencia-plugin_0.8.0-0ubuntu3_amd64.deb

    # changing ownership of the new .deb file replace username with your username
    sudo chown username:username gedit-valencia-plugin_0.8.0-0ubuntu3_amd64.deb

    # removing tmp
    sudo rm -rfv tmp

    # installing it
    sudo dpkg -i gedit-valencia-plugin_0.8.0-0ubuntu3_amd64.deb

# install rabbitvcs-gedit (optional)
sudo apt-get install rabbitvcs-core
sudo dpkg -i rabbitvcs-gedit_0.16-1_all.deb

# install supercollider-gedit (optional)
sudo apt-get install supercollider-language
sudo dpkg -i supercollider-gedit_3.6.6~repack-2-1build1_all.deb

Now you have to make sure the packages won't be changed when you run an update, so ensure only to state the packages you have installed:

# now protecting this all from upgrading
sudo apt-mark hold gedit-common gedit gedit-dev gedit-developer-plugin gedit-latex-plugin gedit-plugins gedit-r-plugin gedit-source-code-browser-plugin gedit-valencia-plugin rabbitvcs-gedit supercollider-gedit

To reverse the whole process do:

# removing protection from upgrades
sudo apt-mark unhold gedit-common gedit gedit-dev gedit-developer-plugin gedit-latex-plugin gedit-plugins gedit-r-plugin gedit-source-code-browser-plugin gedit-valencia-plugin rabbitvcs-gedit supercollider-gedit

# simply do an upgrade
sudo apt-get update
sudo apt-get dist-upgrade

Is there a script to do it?:

Yes I made even a script to automate the whole process, you can get it here or by:

wget https://github.com/Videonauth/gdowngrade/blob/master/gdowngrade.sh

Then to run it:

chmod 755 ./gdowngrade.sh
sudo ./gdowngrade.sh

This will create a custom file for you called gupgrade.shwhich allows you to reverse the whole process by simply:

sudo ./gupgrade.sh
Related Question