]> git.pld-linux.org Git - packages/opera.git/commitdiff
update opera wrapper to support profile migration
authorElan Ruusamäe <glen@delfi.ee>
Sun, 6 Sep 2015 07:59:21 +0000 (10:59 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 6 Sep 2015 08:19:57 +0000 (11:19 +0300)
opera.sh

index 3995959882c7e1a1acc86a3e3941b915687f5a59..f87ad7ebf6a1256fcf93cfd657a228cc586eadbd 100755 (executable)
--- a/opera.sh
+++ b/opera.sh
@@ -1,17 +1,48 @@
 #!/bin/sh
-# set JAVA_HOME from jpackage-utils if available
-if [ -f /usr/share/java-utils/java-functions ]; then
-       . /usr/share/java-utils/java-functions
-       set_jvm
-fi
-export OPERA_DIR=/usr/share/opera
-
-# Legacy dir
-export OPERA_PERSONALDIR="$HOME/.opera"
-
-# XDG path
-if [ ! -d "$OPERA_PERSONALDIR/operaprefs.ini" ]; then
-       OPERA_PERSONALDIR="${XDG_CONFIG_HOME:-$HOME/.config}/opera"
-fi
+
+migrate_profiledir() {
+       # restore location of opera dir for new opera to do automatic profile migration
+       # we used to setup OPERA_PERSONALDIR to use XDG config path
+       # but seems there's no way to tell new opera where to take old profile for
+       # migration than it's hardcoded $HOME/.opera
+       # so we move stuff back there before launching opera
+
+       DOT_DIR="$HOME/.opera"
+       XDG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opera"
+
+       # skip if already migrated
+       if [ -e $XDG_DIR/Preferences ]; then
+               return
+       fi
+
+       OPERA_PERSONALDIR=$DOT_DIR
+       if [ ! -d "$OPERA_PERSONALDIR/operaprefs.ini" ]; then
+               OPERA_PERSONALDIR=$XDG_DIR
+       fi
+
+       if [ "$OPERA_PERSONALDIR" = "$DOT_DIR" ]; then
+               # already there
+               return
+       fi
+
+       # if ~/.opera contains just OperaAutoupdateChecker.sqlite, remove it
+       rm -f $DOT_DIR/OperaAutoupdateChecker.sqlite
+       test -d "$DOT_DIR" && rmdir --ignore-fail-on-non-empty $DOT_DIR
+
+       # neither dir exists, nothing to do
+       if [ ! -d "$DOT_DIR" ] && [ ! -d $XDG_DIR ]; then
+               return
+       fi
+
+       # if no dir, just move
+       if [ ! -d "$DOT_DIR" ]; then
+               mv $XDG_DIR $DOT_DIR
+               return
+       fi
+
+       # may attempt to figure which dir is newer and then rename
+}
+
+migrate_profiledir
 
 exec /usr/lib/opera/opera "$@"
This page took 0.277198 seconds and 4 git commands to generate.