Migrate from Ubuntu to Trisquel without reinstalling

This script automates all the steps required to migrate from any Ubuntu version to its Trisquel counterpart without reinstalling the system. It will replace the kernel with Linux-libre, remove as many non-free packages as possible and install the default Trisquel package set.

Just copy the script into a file, call it trisquelize.sh and run sudo sh trisquelize.sh.

Notes

  • Edit the following variables as needed: $MIRROR $RELEASE and $EDITION
  • The sample contents of those variables are intended to migrate from Ubuntu 12.04 Precise to Trisquel 6.0.
  • Never attempt to run this script from a Ubuntu edition with no Trisquel counterpart! Ask in the forums if you are in doubt.
  • The script attempts to remove a set of known non-free packages available in Ubuntu main and universe repositories; everything else will be preserved.
  • If your disk is encrypted make sure you have the plaintext key written down in case something goes wrong.
  • Making backups is recommended.
  • The script has some long lines; mind them if you modify it.
  • If something goes wrong and you need help, paste the contents of /var/log/trisquelize.log in http://trisquel.pastebin.com and ask in the forum posting the link to your log at pastebin.
  • We recommend you to join the #trisquel IRC channel at irc.freenode.org during the process, in case you ever need help.

Script

#!/bin/bash
#
#Copyright (C) 2010  Rubén Rodríguez <ruben@trisquel.info>
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

if ! touch /etc/apt/sources.list 2&gt;/dev/null
then
echo You need to run this script with sudo!
echo Try: sudo sh $0
fi

# Edit these lines if you want to use a different mirror, release or edition.
# Available editions are trisquel and trisquel-mini
MIRROR=&quot;http://es.archive.trisquel.info/trisquel/&quot;
RELEASE=&quot;toutatis&quot;
EDITION=&quot;trisquel&quot;

cp /etc/apt/sources.list /etc/apt/sources.list.ubuntu-orig
cat &lt;&lt; EOF &gt; /etc/apt/sources.list
deb $MIRROR $RELEASE main
deb $MIRROR $RELEASE-security main
deb $MIRROR $RELEASE-updates main
#deb $MIRROR $RELEASE-backports main
deb-src $MIRROR $RELEASE main
deb-src $MIRROR $RELEASE-security main
deb-src $MIRROR $RELEASE-updates main
#deb $MIRROR $RELEASE-backports main
EOF

sed -i 's/. * /#\1/' /etc/apt/sources.list.d/*

cat &lt;&lt; EOF &gt; /etc/apt/preferences.d/pinning
Package: *
Pin: release o=Trisquel
Pin-Priority: 1001
EOF

export DEBIAN_FRONTEND=noninteractive
apt-get update 2&gt;&amp;1 | COLUMNS=500 tee /var/log/trisquelize.log
apt-get -y --force-yes install trisquel-keyring 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-key add /var/lib/apt/keyrings/trisquel-archive-keyring.gpg 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-get remove --purge plymouth-theme-ubuntu 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-get remove --purge plymouth-theme-ubuntu-text 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-get -y --force-yes dist-upgrade 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-get install -y --force-yes --no-install-recommends $EDITION $EDITION-recommended 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
apt-get install -y --force-yes --no-install-recommends linux-image-generic 2&gt;&amp;1 | COLUMNS=500 tee -a /var/log/trisquelize.log
rm /etc/apt/preferences.d/pinning

echo -------------------------------------------
echo All Trisquel packages succesfully installed.
echo Your system may still have some non-free packages installed,
echo I\'ll now ask you for removal, one by one.
for i in aee afio app-install-data-commercial app-install-data-partner app-install-data-ubuntu b43-fwcutter capiutils chromium-browser chromium-browser-dbg chromium-browser-inspector chromium-browser-l10n chromium-codecs-ffmpeg chromium-codecs-ffmpeg-dbg chromium-codecs-ffmpeg-extra chromium-codecs-ffmpeg-extra-dbg chromium-codecs-ffmpeg-nonfree chromium-codecs-ffmpeg-nonfree-dbg d4x-common envyng-core envyng-gtk envyng-qt fglrx-modaliases firefox-3.5-branding firefox-branding flashplugin-installer freesci freesci-doc gstreamer0.10-pitfdll helix-player ipppd isdnactivecards isdneurofile isdnlog isdnlog-data isdnutils isdnutils-base isdnutils-doc isdnutils-xtools isdnvbox isdnvboxclient isdnvboxserver ivman jockey jockey-common jockey-gtk jockey-kde libmoon libmoonlight-desktop2.0-cil-dev libmoonlight-gtk3.0-cil libmoonlight-system-windows-controls2.0-cil libmoonlight-system-windows3.0-cil libmoonlight-windows-desktop3.0-cil libubuntuone libubuntuone-1.0-1 libubuntuone-dev libubuntuone1.0-cil libubuntuone1.0-cil-dev monodoc-moonlight-manual moon moonlight-plugin-core moonlight-plugin-mozilla moonlight-tools moonlight-web-devel mozilla-helix-player ndisgtk ndiswrapper ndiswrapper-common ndiswrapper-utils-1.9 nvidia-173-modaliases nvidia-180-modaliases nvidia-185-modaliases nvidia-96-modaliases nvidia-common nvidia-current-modaliases nvidia-settings ophcrack ophcrack-cli pdftk pppdcapiplugin rman scribus-ng-doc scsi-firmware linux-firmware software-center tatan ubufox ubuntu-drivers-common ubuntuone-client ubuntuone-client-gnome ubuntuone-client-tools ubuntuone-storage-protocol user-mode-linux vrms
do
echo WARNING: non-free package found: $i
echo Do you want to remove it?
apt-get remove --purge $i
done

echo -------------------------------------------
echo System successfully Trisquelized!
echo If you want to use the Trisquel default desktop layout and
echo other gconf settings, run this as user:
echo gconftool --recursive-unset /apps

If you like to update this code you can commit your changes here: https://devel.trisquel.info/trisquelize/trisquelize

Revisions

11/09/2010 - 20:11
Trisquel
01/16/2011 - 20:43
AndrewT
02/07/2011 - 16:44
Trisquel
10/20/2012 - 14:19
acoronajr.
05/07/2013 - 08:37
megurineturilli
05/20/2013 - 18:55
lembas
08/13/2013 - 19:10
lloydsmart
01/20/2014 - 18:58
antiesnob
04/14/2014 - 04:37
alguien
09/03/2014 - 04:39
muhammed
12/08/2014 - 22:00
t3g
03/25/2015 - 15:05
leny2010
04/28/2016 - 10:11
SalmanMohammadi
01/14/2017 - 12:02
umdhlebe