Skip to content

Commit

Permalink
Extend PiAware package name/version and reporting.
Browse files Browse the repository at this point in the history
We now find a package with "piaware" anywhere in the name and if the machine
isn't running a piaware system image, report the image as "package" and the
name of the package.
  • Loading branch information
lehenbauer committed Oct 5, 2014
1 parent adfef08 commit 7b484a7
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions package/piaware.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ proc load_piaware_config {} {
}

#
# query_piaware_pkg - return the version of the piaware package if it was
# installed as a package, else return an empty string
# query_piaware_pkg - Figure out piaware package name and version
#
proc query_piaware_pkg {} {
set fp [open "|dpkg-query --show piaware* 2>/dev/null"]
# Find a package that has piaware in the name. There will about for sure
# be only one.
#
# Parse out the name and version into passed-in variables and return
# 1 if successful or 0 if unsuccessful
#
proc query_piaware_pkg {_packageName _packageVersion} {
upvar $_packageName packageName $_packageVersion packageVersion

set fp [open "|dpkg-query --show *piaware* 2>/dev/null"]
gets $fp line

if {[catch {close $fp}] == 1} {
return ""
return 0
}
if {![regexp {\t(.*)} $line dummy version]} {
return ""

if {![regexp {([^\t]*)\t(.*)} $line dummy packageName packageVersion]} {
return 0
}
return $version

return 1
}

#
Expand All @@ -43,10 +53,10 @@ proc query_piaware_pkg {} {
#
proc load_piaware_config_and_stuff {} {
load_piaware_config

if {![info exists ::imageType]} {
set packageVersion [query_piaware_pkg]
if {$packageVersion != ""} {
set ::imageType "package"
if {[query_piaware_pkg packageName packageVersion]} {
set ::imageType "${packageName}_package"
}
}
}
Expand Down

0 comments on commit 7b484a7

Please sign in to comment.