[Frugalware-devel] Akonadi database switch

Marius Cirsta mforce2 at gmail.com
Fri Jun 10 21:44:50 CEST 2011

On Sun, May 8, 2011 at 12:49 PM, Michel Hermier <hermier at frugalware.org> wrote:
> The post install script looks interesting, but I think there are 3 issues
> with it.
> * (simple one) It doesn't display which user is converted.
> * (average) It doesn't convert all the users, you should use the
> /etc/password infos for that instead of a simple ls.
> * (complcated) It doesn't migrate the data between the resources.
>> On Sun, Apr 24, 2011 at 10:47 PM, bouleetbil <bouleetbil at frogdev.info>
>> wrote:
>>> Le Sun, 24 Apr 2011 21:30:52 +0200,
>>> Miklos Vajna <vmiklos at frugalware.org> a écrit :
>>>> On Sun, Apr 24, 2011 at 09:53:40PM +0300, Marius Cirsta
>>>> <mforce2 at gmail.com> wrote:
>>>> > Every time KDE 4 started I got a kres-migrator start which runs
>>>> before
>>>> > Akonadi does. It turns out kres-migrator wasn't able to run because
>>>> > Akonadi no longer supports sqlite as a database. The default is now
>>>> > mysql and postgresql is an alternative ( doesn't seem that well
>>>> > maintained however ).
>>>> >
>>>> > Attached are two patches for adding dependencies needed because of
>>>> > this switch to mysql for both current and stable. Also for current
>>>> > there's a version bump to 1.5.2.
>>>> Hi,
>>>> Hmm, but this will break our "main vs extra" policy, since akonadi is
>>>> installed by default, while mysql is not.
>> Sorry about that, didn't know about this, makes sense though.
>>>> Michel, isn't it possible to fix sqlite-default.patch?
>>> Hi,
>> Upon further investigation it turns out that sqlite is indeed
>> supported ( though this http://techbase.kde.org/Projects/PIM/Akonadi
>> said otherwise ). I added cmake option to set sqlite to default for
>> new installs and a post upgrade script to change all user configs to
>> sqlite if it's currently set to mysql. Mine was set to mysql with the
>> Akonadi packages in both stable and current. Here is the script :
>> post_upgrade()
>> {
>>   for user in `ls /home` ; do
>>       AKONADI_CONF=/home/$user/.config/akonadi/akonadiserverrc
>>       if [ -f "$AKONADI_CONF" ] ; then
>>         CHK_MYSQL=`grep "Driver=QMYSQL" $AKONADI_CONF`
>>         if [ -n "$CHK_MYSQL" ] ; then
>>             echo "Switching Akonadi to use sqlite"
>>             sed 's/Driver=QMYSQL/Driver=QSQLITE3/g' $AKONADI_CONF >
>>             mv $AKONADI_CONF.temp $AKONADI_CONF
>>             echo "changed $AKONADI_CONF to Driver=QSQLITE3"
>>         fi
>>       fi
>>   done
>> }
>> Let me know if there are any issues with this.
>> Attached are the new patches for current and stable.
>> _______________________________________________
>> Frugalware-devel mailing list
>> Frugalware-devel at frugalware.org
>> http://frugalware.org/mailman/listinfo/frugalware-devel

I've thought about this for quite some time now and tried different
things. I couldn't really find anything to properly export the Akonadi
mysql database and then properly convert it to sqlite one. Even if
this is achieved it still needs testing and we need to make sure we
don't loose any data , that it still works properly after the switch
and so on.

Instead I've got another solution to the problem, we can check the
folder where Akondi saves the mysql data ( it's hardcoded into Akonadi
to use that certain XDG path ) and see if that folder is empty. If it
is than it means no data was stored there using the mysql backend so
we can safely switch to the sqlite backend. This will be the case for
most new installs where mysql will not be installed by Akonadi will be
configured to use it. If data is present in that folder it means the
user has Akonadi working properly with the mysql backend and he can
continue using that. It's a supported Akonadi backend and now changes
will be made to switch to the sqlite backend.

The other two issues raised be Michel were hopefully addressed by this
new version of the post install script which is below. Let me know if
you have any comments

  allusers=`awk -F: '$3 >= 1000 {print $1 ";" $6}' /etc/passwd`
  for user in $allusers ; do
    username=`echo $user | cut -d";" -f1`
    homedir=`echo $user | cut -d";" -f2`
    if [ ! -f "$AKONADI_CONF" ] ; then
      echo "Akonadi not installed for user: "$username ; " Skipping"
      echo "Akonadi is installed for user: "$username
    if [ "$(ls -A $AKONADI_DB_DIR)" ]; then
      echo "Akonadi database will not be switched to SQLite because
data is present in: "$AKONADI_DB_DIR
    if [ -n "$CHK_MYSQL" ] ; then
	sed -i 's/Driver=QMYSQL/Driver=QSQLITE3/g' $AKONADI_CONF
	echo "changed $AKONADI_CONF to Driver=QSQLITE3"
	echo "Driver is not QMYSQL in "$AKONADI_CONF

$op $*

I've already tested this and it seems to work well.

Thanks, Marius

More information about the Frugalware-devel mailing list