Skip to content

Commit

Permalink
PackageManager release
Browse files Browse the repository at this point in the history
PackageManager provides a GUI to manage packages.
  • Loading branch information
kwindrem committed Jan 15, 2022
1 parent 1c8dfc4 commit 1094a41
Show file tree
Hide file tree
Showing 59 changed files with 6,783 additions and 1,782 deletions.
367 changes: 237 additions & 130 deletions CommonResources

Large diffs are not rendered by default.

90 changes: 88 additions & 2 deletions EssentialResources
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ fullScriptName="$scriptDir/$(basename "$0")"

venusVersion="$(cat /opt/victronenergy/version | head -n 1)"

installedVersionPrefix="/etc/venus/installedVersion-"
installedVersionFile="$installedVersionPrefix"$packageName

# obsolete - use installedVersion
installedFlagPrefix="/etc/venus/inInstalled-"
installedFlag="$installedFlagPrefix"$packageName

Expand All @@ -25,8 +29,19 @@ fileSet="$pkgFileSets/$venusVersion"
rcLocal="/data/rcS.local"

# defined exit codes - must be consistent between all setup scripts and reinstallMods
exitReboot=123
exitSuccess=0
# and PackageManager.py
EXIT_SUCCESS=0
EXIT_REBOOT=123
EXIT_RESTART_GUI=124
EXIT_ERROR=255 # unknown error
EXIT_INCOMPATIBLE_VERSION=254
EXIT_INCOMPATIBLE_PLATFOM=253
EXIT_FILE_SET_ERROR=252
EXIT_OPTIONS_NOT_SET=251
EXIT_RUN_AGAIN=250
# old variables - keep for compatibility
exitReboot=$EXIT_REBOOT
exitSuccess=$EXIT_SUCCESS

reinstallParam="reinstall"

Expand All @@ -40,3 +55,74 @@ packageListFile="/data/packageList"

qmlDir=/opt/victronenergy/gui/qml



# convert a version string in the form of vX.Y~Z-large-W to an integer to make comparisions easier
# the ~Z portion indicates a pre-release version so a version without it is later than a version with it
# the -W portion is like the ~Z for large builds
# the large portion is IGNORED !!!!
# note part[0] is always null because there is nothing before v which is used as a separator
#
# the incoming verison string is split on every non-digit character
# the first three of those pieces are combined into a single integer
# additional pieces are ignored
#
# for example v1.2~3 would be 1002003
# for example v11.22.33 would be 11022033
# for example v11.22-large-33 would be 11022999
# an empty file or one that contains "unknown" or does not beging with 'v'
# has a version number = 0
#
# the separators ~, b, a and d are given special significance
# indicating beta (~ and b), alpha or develompent releases
# which are prioritized: release is the highest, then beta, then alpha then development
# by spliting the third number range into individual ranges
# a released version is given the highest numerical value: 999
# none for release -- 999
# ~ or b for beta 0-398 600-998
# a for alpha 0-299 300-599
# d for development 0-299 0-299

function versionStringToNumber ()
{
local version
local type
local major
local minor
local preRelease
local number
version=$( echo ${1:1} | sed -e 's/-.*//')
read major minor preRelease <<< $(echo $version | sed 's/[.abd~]/ /g')
type=$(echo $version | sed 's/[^abd~]//g')

# assemble core version number from major, minor and preRelease parts
(( number = 0 ))
if [ ! -z $major ]; then
(( number += major * 1000000 ))
fi
if [ ! -z $minor ]; then
(( number += minor * 1000 ))
fi
if [ ! -z $preRelease ]; then
(( number += preRelease ))
fi

# adjust number for release
if [ -z $type ] || [ $type = '' ]; then
# if no preRelease part specified, the preRelease version needs to be it's maximum
# if a preRelease part is specified, use as is
# (should never specify a preRelease for a released version !!!)
if [ -z $preRelease ] || [ $preRelease = '' ]; then
(( number += 999 ))
fi
# adjust number for alpha
elif [ $type == 'a' ]; then
(( number += 300 ))
# adjust number for beta
elif [ $type == 'b' ] || [ $type == '~' ]; then
(( number += 600 ))
fi
versionNumber=$number
}


95 changes: 95 additions & 0 deletions FileSets/MbDisplayDefaultPackage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//////// new for PackageManager

import QtQuick 1.1
import com.victron.velib 1.0
import "utils.js" as Utils

MbItem {
id: root

property int defaultIndex
property string servicePrefix

VBusItem { id: packageName; bind: getServiceBind ("PackageName") }


onClicked: rootWindow.pageStack.push ("/opt/victronenergy/gui/qml/PageSettingsPackageAdd.qml", {defaultIndex: defaultIndex})


function getServiceBind(param)
{
return Utils.path(servicePrefix, "/Default/", defaultIndex, "/", param)
}


MbRowSmall
{
description: ""

anchors.verticalCenter: parent.verticalCenter
Column
{
width: root.width - gitHubUser.width - gitHubBranch.width - 20
Text // puts a bit of space above package name
{
text: " "
font.pixelSize: 6
}
Text
{
text:packageName.valid ? packageName.value : ""
font.pixelSize: 14
horizontalAlignment: Text.AlignLeft
}
Text
{
text: ""
font.pixelSize: 10
horizontalAlignment: Text.AlignLeft
}
}
Column
{
Text // puts a bit of space above version boxes
{
text: " "
font.pixelSize: 3
}
Text
{
text: "GitHub User"
font.pixelSize: 10
}
MbTextBlock
{
id: gitHubUser
item { bind: getServiceBind("GitHubUser") }
height: 20; width: 120
}
Text // puts a bit of space below version boxes - only needed in one column
{
text: " "
font.pixelSize: 6
}
}
Column
{
Text // puts a bit of space above version boxes
{
text: " "
font.pixelSize: 3
}
Text
{
text: qsTr ("GitHub Tag")
font.pixelSize: 10
}
MbTextBlock
{
id: gitHubBranch
item { bind: getServiceBind("GitHubBranch") }
height: 20; width: 120
}
}
}
}
174 changes: 147 additions & 27 deletions FileSets/MbDisplayPackageVersion.qml
Original file line number Diff line number Diff line change
@@ -1,45 +1,165 @@
//////// new for PackageManager

import QtQuick 1.1
import com.victron.velib 1.0
import "utils.js" as Utils

MbItem {
id: root

property int versionIndex
property string bindPrefix
property int packageIndex
property string servicePrefix
property string settingsPrefix

VBusItem { id: packageName; bind: getSettingsBind ("PackageName") }
property VBusItem rebootNeededItem: VBusItem { bind: getServiceBind ( "RebootNeeded") }
property VBusItem guiRestartNeededItem: VBusItem { bind: getServiceBind ( "GuiRestartNeeded") }
property bool rebootNeeded: rebootNeededItem.valid && rebootNeededItem.value == 1
property bool guiRestartNeeded: guiRestartNeededItem.valid && guiRestartNeededItem.value == 1

VBusItem { id: platformItem; bind: Utils.path("com.victronenergy.packageManager", "/Platform" ) }
VBusItem { id: incompatibleItem; bind: getServiceBind ( "Incompatible" ) }
property string incompatibleReason: incompatibleItem.valid ? incompatibleItem.value : ""
property bool compatible: incompatibleReason == ""
property string platform: platformItem.valid ? platformItem.value : "??"

onClicked: rootWindow.pageStack.push ("/opt/victronenergy/gui/qml/PageSettingsPackageEdit.qml", {packageIndex: packageIndex})

function getBind(param)

function statusText ()
{
return Utils.path(bindPrefix, "/", versionIndex, "/", param)
if (rebootNeeded)
return qsTr (" REBOOT needed")
if (guiRestartNeeded)
return qsTr (" GUI restart needed")
else if (incompatibleReason == 'PLATFORM')
return qsTr ( " not compatible with " + platform )
else if (incompatibleReason == 'VERSION')
return qsTr ( " not compatible with " + vePlatform.version )
else if (incompatibleReason == 'CMDLINE' && installedVersion.item.value == "")
return qsTr ( " must install from command line" )
else
return ""
}

VBusItem { id: packageName; bind: getBind ("PackageName") }
function getSettingsBind(param)
{
return Utils.path(settingsPrefix, "/", packageIndex, "/", param)
}
function getServiceBind(param)
{
return Utils.path(servicePrefix, "/Package/", packageIndex, "/", param)
}

function versionToNumber (item)
{
var parts=["x", "x", "x", "x", "x"]
var versionNumber = 0

if (item.valid && item.value.substring (0,1) == "v")
{
parts = item.value.split (/[v.~]+/ , 4)
{
if (parts.length >= 2)
versionNumber += parseInt(parts[1]) * 1000000
if (parts.length >= 3)
versionNumber += parseInt(parts[2]) * 1000
if (parts.length >= 4)
versionNumber += parseInt(parts[3])
else
versionNumber += 999
}
}
return versionNumber
}

MbRowSmall
{
description: ""

anchors.verticalCenter: parent.verticalCenter
height: 20

isCurrentItem: root.isCurrentItem
description: packageName.valid ? packageName.value : ""
MbTextBlock
{
id: gitUser
item { bind: getBind("GitHubUser") }
width: 100
show: packageName.valid && item.valid
}
MbTextBlock
{
item { bind: getBind("GitHubBranch") }
show: packageName.valid && gitUser.item.valid
width: 80
}
MbTextBlock
{
item { bind: getBind("PackageVersion") }
width: 80
show: packageName.valid
Column
{
width: root.width - gitHubVersion.width - packageVersion.width - installedVersion.width - 20
Text // puts a bit of space above package name
{
text: " "
font.pixelSize: 6
}
Text
{
text:packageName.valid ? packageName.value : ""
font.pixelSize: 14
horizontalAlignment: Text.AlignLeft
}
Text
{
text: statusText ()
font.pixelSize: 10
horizontalAlignment: Text.AlignLeft
}
}
Column
{
Text // puts a bit of space above version boxes
{
text: " "
font.pixelSize: 3
}
Text
{
text: "GitHub"
font.pixelSize: 10
}
MbTextBlock
{
id: gitHubVersion
item { bind: getServiceBind("GitHubVersion") }
height: 20; width: 80
}
Text // puts a bit of space below version boxes - only needed in one column
{
text: " "
font.pixelSize: 6
}
}
Column
{
Text // puts a bit of space above version boxes
{
text: " "
font.pixelSize: 3
}
Text
{
text: qsTr ("Stored")
font.pixelSize: 10
}
MbTextBlock
{
id: packageVersion
item { bind: getServiceBind("PackageVersion") }
height: 20; width: 80
}
}
Column
{
Text // puts a bit of space above version boxes
{
text: " "
font.pixelSize: 3
}
Text
{
text: qsTr ("Installed")
font.pixelSize: 10
}
MbTextBlock
{
id: installedVersion
item { bind: getServiceBind("InstalledVersion") }
height: 20; width: 80
}
}
}
}
Loading

0 comments on commit 1094a41

Please sign in to comment.