Migrate from gNewSense to Trisquel without reinstalling

Warning: Using this script might break your system. The time you will spend trying to fix it, will be a lot more than making a clean install. Backup your data before starting! You have been warned.

The information on this page and the script itself are based on the article explaining how to migrate from Ubuntu to Trisqel without reinstalling. Since gNewSense is fully free software distribution some of the steps required in migration from Ubuntu are omitted.

The script automates the steps required to migrate from gNewSense to Trisquel without reinstalling the system. It will install the default Trisquel package set.

You might have to run sudo aptitude safe-upgrade and sudo aptitude full-upgrade after the script finishes, to make the system up to date. Prepare yourself for conflicts. Reports about differences between local versions of configuration files and ones provided by packages. The installer will ask for your preferences on every occurrence. It is recommended to examine he differences and then decide what to do.

You might have to even restart the system to make it behave as it should after the update.

Copy the script into a file, call it trisquelize-gnewsense.sh and run sudo sh trisquelize-gnewsense.sh.

There are two command line options available.

--no-desktop 
If ran with this option, the script will install the trisquel-base and trisquel-base-recommended packages, instead of trisquel and trisquel-recommended needed for desktop systems. This will make the resulting system console based, which is convenient for server installation.
--server-kernel
This option installs the linux-image-server instead of linux-image-generic, when the option is omitted.

Notes:

  • Edit the MIRROR, RELEASE and EDITION variables as needed.
  • The sample contents of those variables are intended to migrate to Trisquel 4.0. The script was tested with gNewSense 3.0 MetaD.
  • If your disk is encrypted make sure you have the paintext 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-gnewsense.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.

#!/bin/bash
#
#    Copyright (C) 2010  Rubén Rodríguez <ruben@trisquel.info>
#    Copyright (C) 2011  Ivaylo Valkov <ivaylo@e-valkov.org>
#
#    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 2110-1301 USA
#
 
# Edit this lines if you want to use a different mirror, release or edition.
# Available editions are trisquel and trisquel-mini
MIRROR="http://es.archive.trisquel.info/trisquel/"
RELEASE="taranis"
EDITION="trisquel"

no_desktop=0
server_kernel=0

while test -n "$1"
do 
    # Install console packages, no GUI
    if test "$1" = "--no-desktop"
    then
    echo You are about to convert you distribution to Trisquel.
    echo The resulting system will have only *console* interface - *no* graphical user interface.
    echo Are you sure you want to continue?

    answer=0
    while test $answer != 'y' && test $answer != 'n'
    do
        echo -n Yes/No \(y/n\)\>
        read answer

        answer=$(echo $answer | tr 'A-Z' 'a-z');

        if test $answer = 'n'
        then
        exit 3;
        elif test $answer != 'y'
        then
        echo 
        echo Please type 'y' or 'n'.
        fi

        no_desktop=1;
    done
    fi

    # Install server optimised kernel flavour
    if test "$1" = "--server-kernel"
    then
    server_kernel=1;
    fi

    # Get next argument in $1
    shift 
done

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

if ! grep -i gnewsense /etc/issue 2>&1 > /dev/null
then
    echo It seems the distribution you are trying to convert to Trisquel is not any version of gNewSense.
    echo Exiting.
    exit 2;
fi


cp /etc/apt/sources.list /etc/apt/sources.list.gnewsense-orig
cat << EOF > /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

if test -d /etc/apt/sources.list.d
then
    sed -i 's/\(.*\)/#\1/' /etc/apt/sources.list.d/* 2> /dev/null
fi

if test ! -d /etc/apt/preferences.d/
then
    mkdir /etc/apt/preferences.d 2> /dev/null
fi

cat << EOF > /etc/apt/preferences.d/pinning
Package: *
Pin: release o=Trisquel
Pin-Priority: 1001
EOF

if test $no_desktop
then
    META_PACKAGE=${EDITION}-base 
    RECOMMENDED_PACKAGE=${EDITION}-base-recommended
else
    META_PACKAGE=${EDITION}
    RECOMMENDED_PACKAGE=${EDITION}-recommended
fi

if test $server_kernel
then
    KERNEL_IMAGE_PACKAGE=linux-image-server
else
    KENREL_IMAGE_PACKAGE=linux-image-generic
fi

export DEBIAN_FRONTEND=noninteractive
apt-get update 2>&1 | COLUMNS=500 tee /var/log/trisquelize-gnewsense.log
apt-get -y --force-yes install trisquel-keyring 2>&1 | COLUMNS=500 tee -a /var/log/trisquelize-gnewsense.log
apt-key add /var/lib/apt/keyrings/trisquel-archive-keyring.gpg 2>&1 | COLUMNS=500 tee -a /var/log/trisquelize-gnewsense.log
apt-get -y --force-yes dist-upgrade 2>&1 | COLUMNS=500 tee -a /var/log/trisquelize-gnewsense.log
apt-get install -y --force-yes --no-install-recommends $META_PACKAGE $RECOMMENDED_PACKAGE 2>&1 | COLUMNS=500 tee -a /var/log/trisquelize-gnewsense.log
apt-get install -y --force-yes --no-install-recommends $KERNEL_IMAGE_PACKAGE 2>&1 | COLUMNS=500 tee -a /var/log/trisquelize-gnewsense.log
rm /etc/apt/preferences.d/pinning

echo -------------------------------------------
echo All Trisquel packages succesfully installed.

echo -------------------------------------------
echo System succesfully 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

Revisions

11/11/2011 - 21:14
ivaylo
12/06/2013 - 03:29
greenman
03/21/2014 - 08:31
lembas