diff --git a/.DS_Store b/.DS_Store index c2241d6..462c1cc 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/DbusSettingsResources b/DbusSettingsResources index 29339bd..a989086 100755 --- a/DbusSettingsResources +++ b/DbusSettingsResources @@ -62,19 +62,23 @@ updateDbusIntSetting () } -# removeDbusSetting removes the setting from dbus Settings +# removeDbusSettings removes the setting from dbus Settings # -# $1 is the path to the setting to be removed starting with /Settings +# all parameters are each a quoted path to the setting to be removed +# e.g., removeDbusSettings "/Settings/foo" "/Settings/bar" +# (including all settings in one dbus call is much faster) -removeDbusSetting () +removeDbusSettings () { - logMessage "removing dbus Setting $1" - dbus -y com.victronenergy.settings / RemoveSettings "%[\"$1\" ]" &> /dev/null + logMessage "removing dbus Settings $@" + local settings=$(echo "$@" | sed -e s_^_\"_ -e s_\$_\"_ -e s_\ _'", "'_g) + dbus -y com.victronenergy.settings / RemoveSettings "%[ $settings ]" &> /dev/null } # setSetting updates the dbus setting parameter # the setting must already exist or the update will fail +# (the setting can not be created without knowing the data type(s)) # # $1 is the new value # $2 is the setting path @@ -86,22 +90,39 @@ setSetting () # move a setting from setup options or from previous dbus Setting # $1 is the setup options path -# $2 is the old dbus path +# $2 is the old dbus path (has priority over setup option) # $3 is the new dbus path # dbus paths start with /Settings # if specified, the setup option file must include a value # that value has priority over the old dbus parameter +# +# setup options can either contain a value or be a flag file +# for flag files, the file will be empty and the state of the option +# depends on the presence of the file (true) or absense of the file (false) +# +# Note: this function does NOT create or remove any old option or Setting +# use other functions or commands to do so moveSetting () { local setupOption="$1" local oldDbusPath=$2 local newDbusPath=$3 - if [ -f "$setupOption" ]; then - oldSetting=$(cat "$setupOption") - elif [ ! -z "$oldDbusPath" ]; then + + if [ ! -z "$oldDbusPath" ]; then oldSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings\ $oldDbusPath com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') + elif [ ! -z $setupOption ]; then + if [ -f "$setupOption" ]; then + oldSetting=$(cat "$setupOption") + # flag file - old setting is true (1) + if [ -z $oldSetting ]; then + oldSetting=1 + fi + # file did not exist - assume a false value for a flag file + else + oldSetting=0 + fi else oldSetting="" fi diff --git a/FileSets/PageSettingsPackageControl.qml b/FileSets/PageSettingsPackageControl.qml index e1c29c4..9b46b0f 100644 --- a/FileSets/PageSettingsPackageControl.qml +++ b/FileSets/PageSettingsPackageControl.qml @@ -7,7 +7,7 @@ import com.victron.velib 1.0 MbPage { id: root title: qsTr("Package Versions") - property string bindPrefix: "com.victronenergy.settings/Settings/GuiMods" + property string bindPrefix: "com.victronenergy.settings/Settings/PackageVersion" VBusItem { id: checkingPackageItem; bind: Utils.path(bindPrefix, "/CheckingPackage") } property string checkingPackage: checkingPackageItem.valid ? checkingPackageItem.value : "" diff --git a/FileSets/v2.80~26/PageSettings.qml b/FileSets/v2.80~29/PageSettings.qml similarity index 100% rename from FileSets/v2.80~26/PageSettings.qml rename to FileSets/v2.80~29/PageSettings.qml diff --git a/FileSets/v2.80~26/PageSettings.qml.orig b/FileSets/v2.80~29/PageSettings.qml.orig similarity index 100% rename from FileSets/v2.80~26/PageSettings.qml.orig rename to FileSets/v2.80~29/PageSettings.qml.orig diff --git a/UpdateResources b/UpdateResources index 277c42e..8e3809f 100755 --- a/UpdateResources +++ b/UpdateResources @@ -109,7 +109,7 @@ getFromUsb () archiveVersion=$(cat "/data/$package-$fileSuffix/version") if [ ! -e "$packageDir" ]; then if $logToConsole ; then - echo "$package not yet installed" + echo "$package not yet installed - proceeding" fi return 1 elif [ -z $archiveVersion ]; then @@ -135,6 +135,10 @@ getFromUsb () # get the package from a GitHub # The package is left in $package-$gitHubBranch for processing later # $1 is the name of the package +# +# $2 is a boolean: when true archive download is skipped +# used by packageInstaller when a package is aready installed and auto updates are enabled +# if auto updates are enabled and update will be skipped anyway # returns 0 if update should NOT occur or 1 if update is acceptable getFromGitHub () @@ -142,7 +146,13 @@ getFromGitHub () local package=$1 local packageDir="/data/$package" local lastUpdate="" - + local skipDownload + if [ $# -gt 1 ] && $2 ; then + checkOnly=true + else + checkOnly=false + fi + # get the version from local copy of package if [ -f "$packageDir/version" ]; then installedVersion=$(cat "$packageDir/version") @@ -150,14 +160,16 @@ getFromGitHub () installedVersion="" fi - # fetch archive version - archiveVersion=$(wget -qO - https://raw.githubusercontent.com/$gitHubUser/$package/$gitHubBranch/version) if [ ! -e "$packageDir" ]; then if $logToConsole ; then - echo "$package not yet installed" + echo "$package not yet installed - proceeding" fi - elif [ -z $archiveVersion ]; then - logMessage "ERROR: Can't access GitHub archive or no version for $package - can't update" + fi + + # fetch archive version + archiveVersion=$(wget -qO - https://raw.githubusercontent.com/$gitHubUser/$package/$gitHubBranch/version) + if [ -z $archiveVersion ]; then + logMessage "ERROR: no version for $package $gitHubUser $gitHubBranch on GitHub - can't continue" return 0 elif [ -z $installedVersion ]; then logMessage "WARNING: no version for $package current installation - proceeding" @@ -168,6 +180,8 @@ getFromGitHub () echo "$package is up to date" fi return 0 + elif $checkOnly ; then + return 1 fi fi # update the package and reinstall it @@ -175,7 +189,7 @@ getFromGitHub () if [ $? -eq 0 ]; then return 1 else - logMessage "ERROR: $package $gitHubUser $gitHubBranch not available" + logMessage "ERROR: can't access $package $gitHubUser $gitHubBranch on GitHub" return 0 fi } diff --git a/packageAutoUpdater b/packageAutoUpdater index 0e9ec38..aa53004 100755 --- a/packageAutoUpdater +++ b/packageAutoUpdater @@ -57,7 +57,7 @@ updateStatus () fi # update GUI status message if $updateDbus ; then - updateDbusStringSetting "/Settings/GuiMods/CheckingPackage" "$message" + updateDbusStringSetting "/Settings/PackageVersion/CheckingPackage" "$message" fi lastMessage=$1 lastPackage=$package @@ -127,7 +127,7 @@ while true ; do doUpdate=false # pull Git Hub autoupdate mode from dbus - autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ + autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/PackageVersion/GitHubAutoUpdate\ com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') if [ -z $autoUpdateSetting ]; then autoUpdateSetting=0 @@ -243,10 +243,10 @@ while true ; do if ! $restartFromFirstPackage && ! $updateSetupHelper; then # single pass if (( $autoUpdateSetting == 3 )) ; then - setSetting 0 /Settings/GuiMods/GitHubAutoUpdate + setSetting 0 /Settings/PackageVersion/GitHubAutoUpdate # end of first pass, switch to slow updates elif (( $autoUpdateSetting == 2 )) ; then - setSetting 1 /Settings/GuiMods/GitHubAutoUpdate + setSetting 1 /Settings/PackageVersion/GitHubAutoUpdate fi fi usbCheck=false diff --git a/packageInstaller b/packageInstaller index ddf16a3..dcdc816 100755 --- a/packageInstaller +++ b/packageInstaller @@ -48,7 +48,7 @@ if $updateFromUsb ; then fi # allow reinstallations if auto updates are not enabled -autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ +autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/PackageVersion/GitHubAutoUpdate\ com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') if [ -z $autoUpdateSetting ] || [ $autoUpdateSetting == 0 ]; then autoUpdatesEnabled=false @@ -78,16 +78,14 @@ while read -u 9 package gitHubUser gitHubBranch; do doUpdate=false packageDir="/data/$package" - - -########################################################## - # if automatic updates are enabled, skip packages that have alreay been installed - if [ -e $packageDir ] && [ -f "$setupOptionsRoot/$package/installOk" ]; then - if $autoUpdatesEnabled ; then - echo "$package has already been installed and will be automatically updated - skipping" - continue - fi + # if automatic updates are enabled, skip packages that are installed + checkOnly=false + if [ -e $packageDir ] && [ -f "$installedFlagPrefix"$package ]; then installText="reinstall" + # update will be skipped so set a flag so getFromGitHub only checks versions + if ! $updateFromUsb ; then + checkOnly=true + fi else installText="install" fi @@ -109,8 +107,12 @@ while read -u 9 package gitHubUser gitHubBranch; do # check GitHub else - getFromGitHub $package + getFromGitHub $package $checkOnly if [ $? -eq 1 ]; then + if $autoUpdatesEnabled ; then + echo "$package needs update but will be updated automatically - skipping" + continue + fi echo yesNoPrompt "$installText $package from GitHub? (y/n): " if $yesResponse ; then diff --git a/setup b/setup index 9119e73..30f5cbc 100755 --- a/setup +++ b/setup @@ -15,19 +15,15 @@ source "/data/SetupHelper/CommonResources" cleanupDbusSettings () { - dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/PackageVersions/GeneratorConnector\ + dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ com.victronenergy.BusItem.GetValue &> /dev/null if (( $? == 0 )); then - removeDbusSetting "/Settings/GuiMods/PackageVersions/GeneratorConnector" - removeDbusSetting "/Settings/GuiMods/PackageVersions/GuiMods" - removeDbusSetting "/Settings/GuiMods/PackageVersions/GuiMods2" - removeDbusSetting "/Settings/GuiMods/PackageVersions/RpiDisplaySetup" - removeDbusSetting "/Settings/GuiMods/PackageVersions/RpiGpioSetup" - removeDbusSetting "/Settings/GuiMods/PackageVersions/RpiTemp" - removeDbusSetting "/Settings/GuiMods/PackageVersions/SetupHelper" - removeDbusSetting "/Settings/GuiMods/PackageVersions/TankRepeater" - removeDbusSetting "/Settings/GuiMods/PackageVersions/VeCanSetup" - removeDbusSetting "/Settings/GuiMods/PackageVersions/ShutdownMonitor" + removeDbusSettings "/Settings/GuiMods/PackageVersions/GeneratorConnector" "/Settings/GuiMods/PackageVersions/GuiMods"\ + "/Settings/GuiMods/PackageVersions/GuiMods" "/Settings/GuiMods/PackageVersions/RpiDisplaySetup"\ + "/Settings/GuiMods/PackageVersions/RpiGpioSetup" "/Settings/GuiMods/PackageVersions/RpiTemp"\ + "/Settings/GuiMods/PackageVersions/SetupHelper" "/Settings/GuiMods/PackageVersions/TankRepeater",\ + "/Settings/GuiMods/PackageVersions/VeCanSetup" "/Settings/GuiMods/PackageVersions/ShutdownMonitor"\ + "/Settings/GuiMods/CheckingPackage" "/Settings/GuiMods/CheckingPackage" fi } @@ -38,20 +34,17 @@ if [ $scriptAction == 'NONE' ] ; then # NOTE: if new settings are added in the future, change test for that one # to avoid creating that new parameter !!!! - dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/CheckingPackage\ + dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/PackageVersion/CheckingPackage\ com.victronenergy.BusItem.GetValue &> /dev/null if (( $? != 0 )); then logMessage "creating SetupHelper Settings" dbus -y com.victronenergy.settings /Settings AddSettings\ - '%[ {"path": "/GuiMods/GitHubAutoUpdate", "default":0},\ - {"path": "/GuiMods/CheckingPackage", "default":""},]' > /dev/null - # move setup option flag to dbus setting - if [ -f "$setupOptionsDir/autoGitHubUpdate" ]; then - setSetting 1 /Settings/GuiMods/GitHubAutoUpdate - rm -f "$setupOptionsDir/autoGitHubUpdate" - else - setSetting 0 /Settings/GuiMods/GitHubAutoUpdate - fi + '%[ {"path": "/PackageVersion/GitHubAutoUpdate", "default":0},\ + {"path": "/PackageVersion/CheckingPackage", "default":""},]' > /dev/null + # relocate options and current values + moveSetting "$setupOptionsDir/autoGitHubUpdate" "/Settings/GuiMods/GitHubAutoUpdate" "/PackageVersion/GitHubAutoUpdate" + rm -f "$setupOptionsDir/autoGitHubUpdate" + moveSetting "" "/Settings/GuiMods/CheckingPackage" "/PackageVersion/CheckingPackage" fi # display initial message @@ -115,7 +108,7 @@ if [ $scriptAction == 'NONE' ] ; then ;; [gG]*) autoUpdate=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings\ - /Settings/GuiMods/GitHubAutoUpdate\ + /Settings/PackageVersion/GitHubAutoUpdate\ com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') case $autoUpdate in 1) @@ -141,16 +134,16 @@ if [ $scriptAction == 'NONE' ] ; then if [ ! -z $response ]; then case $response in [nN]* | [eE]*) - setSetting 1 /Settings/GuiMods/GitHubAutoUpdate + setSetting 1 /Settings/PackageVersion/GitHubAutoUpdate ;; [fF]*) - setSetting 2 /Settings/GuiMods/GitHubAutoUpdate + setSetting 2 /Settings/PackageVersion/GitHubAutoUpdate ;; [oO]*) - setSetting 3 /Settings/GuiMods/GitHubAutoUpdate + setSetting 3 /Settings/PackageVersion/GitHubAutoUpdate ;; [dD]*) - setSetting 0 /Settings/GuiMods/GitHubAutoUpdate + setSetting 0 /Settings/PackageVersion/GitHubAutoUpdate ;; *) esac diff --git a/updatePackageVersions b/updatePackageVersions index fae8684..0e6d2a3 100755 --- a/updatePackageVersions +++ b/updatePackageVersions @@ -110,8 +110,8 @@ done index=$newCount while (( $index < $oldCount )); do - removeDbusSetting "/Settings/PackageVersion/$index/PackageName" - removeDbusSetting "/Settings/PackageVersion/$index/PackageVersion" + removeDbusSettings "/Settings/PackageVersion/$index/PackageName"\ + "/Settings/PackageVersion/$index/PackageVersion" ((index++)) done diff --git a/venus-data.tgz b/venus-data.tgz index ca3e76c..3870f48 100644 Binary files a/venus-data.tgz and b/venus-data.tgz differ diff --git a/version b/version index 7945083..3c81e0c 100644 --- a/version +++ b/version @@ -1 +1 @@ -v3.4 +v3.5