#!/bin/env tclsh

# <20220413.1715.50>
#
# This code reads a file of required packages and outputs a list of the missing
# packages (i.e. in the list but not avaiable).
#

set file "RequiredPackages"

lassign $argv this ops
if {$this != {}} {set file $this}
  
set req [lsort -unique [split [read [set fid [open $file r]]] \n]]

puts "Checking for presents of [llength $req] packages."
set count 0
foreach pack $req {
  set what [lassign $pack -> pk ver]
  set what [string trim $what]
  set ver  [string trim $what]
  set pk [string trim $pk]
  if {$pk == {}} {continue}
  if {![catch {package require $pk} er]} {continue}
  incr count
  puts "$er"
  # puts ">$pk< >$ver< >$what<"
}
puts "$count not found"
    
