Moving to a new machine/setup with Ubuntu Linux (or Debian)

Today, as I got my new harddrive (which is a Samsung 830 SSD), I decided to re-install my copy of Ubuntu (for whatever reason). Copying my home folder, some configfiles and so on is an easy task, but what about all these little programs, that were installed with some manual Installer (like QPilot, VMware, …) because they don’t provide a APT-Installer? I do not do any bookkeeping about those, so I wrote a little script, that checks populates a list of files on my root filesystem and checks them, if they belong to some debian package.

It took a while on my old spinning harddrive, probably there is a more efficient way, instead of calling dlocate for every single file.

My little script:

#!/bin/bash
FILELIST=/tmp/findonapt_filelist.lst
FRESHLIST=0

populatelist() {
    echo "Creating fileslist"
    eval "/usr/bin/find / -xdev -type f > $FILELIST 2>/dev/null"
}

if [ ! -f $FILELIST ]
    then
        populatelist &
        FRESHLIST=1
        sleep 5;
fi

exec 0<$FILELIST
value=0
while read LINE

do
    if [[ $LINE != *var\/cache* ]]
        then 
            if [ $(dlocate -S $LINE | wc -l) == 0 ]
                then
                    value=`expr $value + 1`;
                    echo $LINE;
            fi

    fi
done

if [ $FRESHLIST == 1]
    then
        wait
fi

echo "****$value Non-APT Files found";

Leave a Reply

Your email address will not be published.