5 if [ "$1" != "configure" ]
10 ### Change old default values to new default values
12 CONFIG_FILE="/home/user/.config/kde.org/Marble Desktop Globe.conf"
13 if test -e "${CONFIG_FILE}"
16 -e 's/^sideBar=true$/sideBar=false/' \
17 -e 's/^volatileTileCacheLimit=30$/volatileTileCacheLimit=6/' \
18 -e 's/^projection=0$/projection=2/' \
19 -e '/^distanceUnit=/d' \
20 -e 's/^persistentTileCacheLimit=300$/persistentTileCacheLimit=0/' \
22 chown user:users "${CONFIG_FILE}"
25 ### Migrate cached openstreetmap tiles to shared directory
27 # The OSM tile download location in Marble 1.0.x and earlier
28 OSM_DIR_10="/home/user/MyDocs/.local/share/marble/maps/earth/openstreetmap"
30 # The OSM tile download location in Marble 1.1 and later
31 OSM_DIR_11="/home/user/MyDocs/.maps/OpenStreetMap I"
34 OSM_DIR_BASE="/opt/marble/share/marble/data/maps/earth/openstreetmap"
36 # The OSM theme .dgml file
37 OSM_DGML="${OSM_DIR_BASE}/openstreetmap.dgml"
39 # A file used as a flag to indicate a previous migration
40 MIGRATED="${OSM_DIR_10}/.migrated"
42 # Verify we have the .dgml file and can write to it (required)
43 test -w "${OSM_DGML}" || { echo "DGML file ${OSM_DGML} not existant/writable."; exit 1; }
45 # Check whether the tiles were previously migrated. In that case there's nothing to do
46 test -e "${MIGRATED}" && exit 0
48 # If the migration has to move files, ask the user to skip it since it can
49 # take some minutes to finish
51 test -e "${OSM_DIR_10}" && test -e "${OSM_DIR_11}" && { maemo-confirm-text "Enable OpenStreetMap Data Sharing" /opt/marble/share/marble/data/migration-warning.txt || exit 0; }
54 mkdir -p "${OSM_DIR_11}"
55 if test -d "${OSM_DIR_10}"
57 # Cached tiles from an old Marble installation exist and must be migrated
58 for x in ${OSM_DIR_10}/[0-9]*
60 test -e "${x}" || continue
62 if test -e "${OSM_DIR_11}/${dx}"
64 # Tiles /x/ were downloaded both in Marble and another application
67 test -e "${y}" || continue
69 target="${OSM_DIR_11}/${dx}/${dy}/"
70 if test -e "${target}"
72 # Tiles /x/y/ were downloaded both in Marble and another application. Move each /x/y/z
73 mv "${y}"/[0-9]*.png "${target}"
76 # Target dir does not exist yet, so we can move it over (much quicker)
77 mv "${y}" "${OSM_DIR_11}/${dx}"
82 # Target does not exist yet, so we can move it over (much quicker)
83 mv "${x}" "${OSM_DIR_11}/"
88 # Delete now empty directory
89 test -d "${OSM_DIR_10}/" && rmdir "${OSM_DIR_10}/" || true
91 # If files are left in the old directory, leave a flag to avoid running
92 # the migration again. This only happens if the user created custom files in
93 # the OSM cache directory
94 test -d "${OSM_DIR_10}/" && touch "${MIGRATED}"
96 # Finally, change the download location in the .dgml file. Also needed for new installations
97 sed -i "s@<sourcedir format=\"PNG\"> earth/openstreetmap </sourcedir>@<sourcedir format=\"PNG\"> ${OSM_DIR_11} </sourcedir>@" "${OSM_DGML}"
99 # Copy the base tile to the right place.
100 mkdir -p "${OSM_DIR_11}/0/0"
101 cp "${OSM_DIR_BASE}/0/0/0.png" "${OSM_DIR_11}/0/0/"