| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
export TEXTDOMAIN='calcurse' |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
[ -d "$HOME/.calcurse" ] && CONFFILE="$HOME/.calcurse/conf" || CONFFILE="${XDG_CONFIG_HOME:-$HOME/.config}/calcurse/conf" |
| 8 |
|
| 9 |
if [ "$#" -gt 0 ]; then |
| 10 |
if [ "$1" = "--config" ]; then |
| 11 |
CONFFILE=$2 |
| 12 |
elif [ "$1" = "-h" -o "$1" = "--help" ]; then |
| 13 |
echo "calcurse-upgrade 4.8.1" |
| 14 |
echo "$(gettext "Usage: calcurse-upgrade [-h|-v|--config <file>]")" |
| 15 |
elif [ "$1" = "-v" -o "$1" = "--version" ]; then |
| 16 |
echo "calcurse-upgrade 4.8.1" |
| 17 |
echo "$(gettext " |
| 18 |
Copyright (c) 2004-2023 calcurse Development Team. |
| 19 |
This is free software; see the source for copying conditions. |
| 20 |
")" |
| 21 |
else |
| 22 |
echo "$(gettext "unrecognized option:") \"$1\"" >&2 |
| 23 |
exit 1 |
| 24 |
fi |
| 25 |
fi |
| 26 |
|
| 27 |
if [ ! -e "$CONFFILE" ]; then |
| 28 |
echo "$(gettext "Configuration file not found:") $CONFFILE" >&2 |
| 29 |
exit 1 |
| 30 |
fi |
| 31 |
|
| 32 |
if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ |
| 33 |
-e '^confirm_quit=' -e '^confirm_delete=' -e '^skip_system_dialogs=' \ |
| 34 |
-e '^skip_progress_bar=' -e '^calendar_default_view=' \ |
| 35 |
-e '^week_begins_on_monday=' -e '^color-theme=' -e '^layout=' \ |
| 36 |
-e '^side-bar_width=' -e '^notify-bar_show=' -e '^notify-bar_date=' \ |
| 37 |
-e '^notify-bar_clock=' -e '^notify-bar_warning=' -e '^notify-bar_command=' \ |
| 38 |
-e '^notify-all=' -e '^output_datefmt=' -e '^input_datefmt=' \ |
| 39 |
-e '^notify-daemon_enable=' -e '^notify-daemon_log=' "$CONFFILE"; then |
| 40 |
|
| 41 |
echo "$(gettext "Pre-3.0.0 configuration file format detected...")" |
| 42 |
|
| 43 |
echo -n "$(gettext "Create temporary backup of the configuration file...")" |
| 44 |
|
| 45 |
backupfile="$CONFFILE.calcurse-upgrade.old" |
| 46 |
if [ -e "$backupfile" ]; then |
| 47 |
echo |
| 48 |
echo "$(gettext "Old backup file found:") \"$backupfile\"" >&2 |
| 49 |
echo "$(gettext " |
| 50 |
If a previous conversion did not complete, please try to restore your |
| 51 |
configuration from this backup and then remove the backup file.")" >&2 |
| 52 |
exit 1 |
| 53 |
fi |
| 54 |
|
| 55 |
cp "$CONFFILE" "$backupfile" |
| 56 |
|
| 57 |
echo -n ' ' |
| 58 |
echo "$(gettext 'done')" |
| 59 |
|
| 60 |
tmpfile="$CONFFILE.calcurse-upgrade.tmp" |
| 61 |
if [ -e "$tmpfile" ]; then |
| 62 |
echo "$(gettext "Old temporary file found:") \"$tmpfile\"" >&2 |
| 63 |
echo "$(gettext " |
| 64 |
If a previous conversion did not complete, please try to remove this file and |
| 65 |
start over with a backup of your old configuration file.")" >&2 |
| 66 |
exit 1 |
| 67 |
fi |
| 68 |
|
| 69 |
echo -n "$(gettext "Upgrade configuration directives...")" |
| 70 |
|
| 71 |
sed -e 's/^auto_save=/general.autosave=/' \ |
| 72 |
-e 's/^auto_gc=/general.autogc=/' \ |
| 73 |
-e 's/^periodic_save=/general.periodicsave=/' \ |
| 74 |
-e 's/^confirm_quit=/general.confirmquit=/' \ |
| 75 |
-e 's/^confirm_delete=/general.confirmdelete=/' \ |
| 76 |
-e 's/^skip_system_dialogs=/general.systemdialogs=/' \ |
| 77 |
-e 's/^skip_progress_bar=/general.progressbar=/' \ |
| 78 |
-e 's/^calendar_default_view=/appearance.calendarview=/' \ |
| 79 |
-e 's/^week_begins_on_monday=/general.firstdayofweek=/' \ |
| 80 |
-e 's/^color-theme=/appearance.theme=/' \ |
| 81 |
-e 's/^layout=/appearance.layout=/' \ |
| 82 |
-e 's/^side-bar_width=/appearance.sidebarwidth=/' \ |
| 83 |
-e 's/^notify-bar_show=/appearance.notifybar=/' \ |
| 84 |
-e 's/^notify-bar_date=/format.notifydate=/' \ |
| 85 |
-e 's/^notify-bar_clock=/format.notifytime=/' \ |
| 86 |
-e 's/^notify-bar_warning=/notification.warning=/' \ |
| 87 |
-e 's/^notify-bar_command=/notification.command=/' \ |
| 88 |
-e 's/^notify-all=/notification.notifyall=/' \ |
| 89 |
-e 's/^output_datefmt=/format.outputdate=/' \ |
| 90 |
-e 's/^input_datefmt=/format.inputdate=/' \ |
| 91 |
-e 's/^notify-daemon_enable=/daemon.enable=/' \ |
| 92 |
-e 's/^notify-daemon_log=/daemon.log=/' "$CONFFILE" > "$tmpfile" |
| 93 |
mv "$tmpfile" "$CONFFILE" |
| 94 |
|
| 95 |
if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then |
| 96 |
sed ' |
| 97 |
/^general.autosave=/{ |
| 98 |
N |
| 99 |
s/\n// |
| 100 |
} |
| 101 |
/^general.autogc=/{ |
| 102 |
N |
| 103 |
s/\n// |
| 104 |
} |
| 105 |
/^general.periodicsave=/{ |
| 106 |
N |
| 107 |
s/\n// |
| 108 |
} |
| 109 |
/^general.confirmquit=/{ |
| 110 |
N |
| 111 |
s/\n// |
| 112 |
} |
| 113 |
/^general.confirmdelete=/{ |
| 114 |
N |
| 115 |
s/\n// |
| 116 |
} |
| 117 |
/^general.systemdialogs=/{ |
| 118 |
N |
| 119 |
s/\n// |
| 120 |
} |
| 121 |
/^general.progressbar=/{ |
| 122 |
N |
| 123 |
s/\n// |
| 124 |
} |
| 125 |
/^appearance.calendarview=/{ |
| 126 |
N |
| 127 |
s/\n// |
| 128 |
} |
| 129 |
/^general.firstdayofweek=/{ |
| 130 |
N |
| 131 |
s/\n// |
| 132 |
} |
| 133 |
/^appearance.theme=/{ |
| 134 |
N |
| 135 |
s/\n// |
| 136 |
} |
| 137 |
/^appearance.layout=/{ |
| 138 |
N |
| 139 |
s/\n// |
| 140 |
} |
| 141 |
/^appearance.sidebarwidth=/{ |
| 142 |
N |
| 143 |
s/\n// |
| 144 |
} |
| 145 |
/^appearance.notifybar=/{ |
| 146 |
N |
| 147 |
s/\n// |
| 148 |
} |
| 149 |
/^format.notifydate=/{ |
| 150 |
N |
| 151 |
s/\n// |
| 152 |
} |
| 153 |
/^format.notifytime=/{ |
| 154 |
N |
| 155 |
s/\n// |
| 156 |
} |
| 157 |
/^notification.warning=/{ |
| 158 |
N |
| 159 |
s/\n// |
| 160 |
} |
| 161 |
/^notification.command=/{ |
| 162 |
N |
| 163 |
s/\n// |
| 164 |
} |
| 165 |
/^notification.notifyall=/{ |
| 166 |
N |
| 167 |
s/\n// |
| 168 |
} |
| 169 |
/^format.outputdate=/{ |
| 170 |
N |
| 171 |
s/\n// |
| 172 |
} |
| 173 |
/^format.inputdate=/{ |
| 174 |
N |
| 175 |
s/\n// |
| 176 |
} |
| 177 |
/^daemon.enable=/{ |
| 178 |
N |
| 179 |
s/\n// |
| 180 |
} |
| 181 |
/^daemon.log=/{ |
| 182 |
N |
| 183 |
s/\n// |
| 184 |
}' "$CONFFILE" > "$tmpfile" |
| 185 |
mv "$tmpfile" "$CONFFILE" |
| 186 |
fi |
| 187 |
|
| 188 |
awk ' |
| 189 |
BEGIN { FS=OFS="=" } |
| 190 |
$1 == "general.systemdialogs" || $1 == "general.progressbar" \ |
| 191 |
{ $2 = ($2 == "yes") ? "no" : "yes" } |
| 192 |
$1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" } |
| 193 |
$1 == "appearance.calendarview" { $2 = ($2 == 0) ? "monthly" : \ |
| 194 |
($2 == 1) ? "weekly" : $2 } |
| 195 |
{ print } |
| 196 |
' < "$CONFFILE" > "$tmpfile" |
| 197 |
mv "$tmpfile" "$CONFFILE" |
| 198 |
|
| 199 |
echo -n ' ' |
| 200 |
echo "$(gettext 'done')" |
| 201 |
|
| 202 |
echo -n "$(gettext "Remove temporary backup...")" |
| 203 |
rm "$backupfile" |
| 204 |
echo -n ' ' |
| 205 |
echo "$(gettext 'done')" |
| 206 |
fi |
| 207 |
|