[packages/opera] update opera wrapper to support profile migration
glen
glen at pld-linux.org
Sun Sep 6 10:27:46 CEST 2015
commit d73e0eadbe0ce33bfbb2d6cbd8a8fc046b1ac282
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Sep 6 10:59:21 2015 +0300
update opera wrapper to support profile migration
opera.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 14 deletions(-)
---
diff --git a/opera.sh b/opera.sh
index 3995959..f87ad7e 100755
--- 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 "$@"
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/opera.git/commitdiff/1224e0a911a271947b5af183646aa0dfbc18dc92
More information about the pld-cvs-commit
mailing list