/usr/bin/tcltk-depends is in tcl-dev 8.6.0+8.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | #!/usr/bin/tclsh
if {[info commands lassign] == ""} {
# lassign --
# Assigns list contents to given variables. This command
# exists in Tcl 8.5, so the definition is conditional.
#
# Arguments:
# list A list of assigning values.
# args Variables to assign.
#
# Results:
# The rest of a list.
#
# Side effects:
# The given variables are assigned.
proc lassign {list args} {
foreach name $args {
upvar $name var
set var [lindex $list 0]
set list [lrange $list 1 end]
}
return $list
}
}
# delsubstvar --
# Removes substitution variable from a substvar file for a given
# package in ./debian/ directory.
#
# Arguments:
# package Name of a package (file $package.substvars is used).
# substvar Name of a substitution variable to delete.
#
# Results:
# An empty string.
#
# Side effects:
# File debian/$package.substvars is overwritten. The specified variable
# is deleted.
proc delsubstvar {package substvar} {
set substvarfile [file join debian $package.substvars]
if {[file exists $substvarfile]} {
set fd [open $substvarfile]
set lines [split [string trim [read $fd]] "\n"]
close $fd
set fd [open $substvarfile w]
foreach line $lines {
if {[string first $substvar= $line] != 0} {
puts $fd $line
}
}
close $fd
}
return
}
# addsubstvar --
# Adds a dependency to a substitution variable in a substvar file
# for a given package in ./debian/ directory.
#
# Arguments:
# package Name of a package (file $package.substvars is used).
# substvar Name of a substitution variable to add/change.
# deppackage An added substitution dependency string.
#
# Results:
# An empty string.
#
# Side effects:
# File debian/$package.substvars is overwritten. The specified depandency
# string is added to the variable.
proc addsubstvar {package substvar deppackage} {
set substvarfile [file join debian $package.substvars]
if {[file exists $substvarfile]} {
set fd [open $substvarfile]
set lines [split [string trim [read $fd]] "\n"]
close $fd
set fd [open $substvarfile w]
set found 0
foreach line $lines {
if {[string first $substvar= $line] != 0} {
puts $fd $line
} else {
set items [split [string range $line [string length $substvar=] end] ","]
set items1 {}
foreach i $items {
lappend items1 [string trim $i]
}
lappend items1 $deppackage
puts $fd $substvar=[join $items1 ", "]
set found 1
}
}
if {!$found} {
puts $fd $substvar=$deppackage
}
close $fd
} else {
set fd [open $substvarfile w]
puts $fd $substvar=$deppackage
close $fd
}
return
}
# getpackages --
# Parses debhelper command line options and debian/control file and
# returns packages to act on.
#
# Arguments:
# arglist Dephelper options (only -a, -i, -p, -N options are
# recognised).
#
# Results:
# Package names to work on or error message and exit if debian/control
# is unreadable or unknown option is specified.
#
# Side effects:
# None.
proc getpackages {arglist} {
if {[catch {open [file join debian control]} fd]} {
puts [format "cannot read debian/control: %s" $fd]
exit 1
} else {
set arches all
set excluded {}
set explicit {}
while {[llength $arglist] > 0} {
set arglist [lassign $arglist opt]
switch -glob -- $opt {
-a -
--arch {
# Only the last -a or -i options takes effect
set arches arch
}
-i -
--indep {
# Only the last -a or -i options takes effect
set arches indep
}
-s -
--same-arch {
puts "options -s and --same-arch aren't supported yet"
exit 1
}
-p* {
lappend explicit [string range $opt 2 end]
}
--package=* {
lappend explicit [string range $opt 10 end]
}
-N* {
lappend excluded [string range $opt 2 end]
}
--no-package=* {
lappend excluded [string range $opt 13 end]
}
default {
puts [format "unknown option %s" $opt]
exit 1
}
}
}
set data [read $fd]
regsub -all {\n( |\t)} $data {\1} data ; # Join up all continuatioin lines
set lines [split $data "\n"]
lappend lines "" ; # If debian/config doesn't have a trailing LF
close $fd
set packages {}
set allpackages {}
set package ""
set arch ""
set vars {}
foreach line $lines {
switch -glob -- $line {
"Package: *" {
set package [string trim [string range $line 9 end]]
}
"Architecture: *" {
set arch [string trim [string range $line 14 end]]
}
"Pre-Depends: *" -
"Depends: *" -
"Recommends: *" -
"Suggests: *" -
"Enhances: *" -
"Breaks: *" -
"Conflicts: *" -
"Provides: *" -
"Replaces: *" {
set vars [concat $vars [regexp -all -inline {\$\{\S*\}} $line]]
}
"" {
if {$package == ""} {
# Two LF in a row or the end of a source package
} elseif {[lsearch -exact $excluded $package] >= 0} {
# The package is excluded by -Npackage
} elseif {[lsearch -exact $explicit $package] >= 0} {
# The package is explicitly required
lappend packages $package $vars
} elseif {$arches == "arch" && $arch != "all"} {
# Arch dependent packages are requested
lappend packages $package $vars
} elseif {$arches == "indep" && $arch == "all"} {
# Arch independent packages are requested
lappend packages $package $vars
} elseif {$arches == "all"} {
lappend allpackages $package $vars
}
set package ""
set arch ""
set vars {}
}
}
}
if {$arches == "all" && [llength $packages] == 0} {
# There aren't explicitly requested packages
set packages $allpackages
}
return $packages
}
}
set ver "8.6"
set tclver "8.6.0-2"
if {$tclver == ""} {
set tcldep ""
} else {
set tcldep " (>= $tclver)"
}
set tkver "8.6.0-2"
if {$tkver == ""} {
set tkdep ""
} else {
set tkdep " (>= $tkver)"
}
set version "8.6.0-2"
if {$version == ""} {
set dep ""
} else {
set dep " (>= $version)"
}
foreach {package vars} [getpackages $argv] {
delsubstvar $package "tclXY:Depends"
if {[lsearch -exact $vars "\${tclXY:Depends}"] >= 0} {
addsubstvar $package "tclXY:Depends" "tcl$ver$tcldep"
}
delsubstvar $package "tcl:Depends"
if {[lsearch -exact $vars "\${tcl:Depends}"] >= 0} {
addsubstvar $package "tcl:Depends" "tcl$dep"
}
# tclsh:Depends is retained for backward compatibility
delsubstvar $package "tclsh:Depends"
if {[lsearch -exact $vars "\${tclsh:Depends}"] >= 0} {
addsubstvar $package "tclsh:Depends" "tcl$dep"
}
delsubstvar $package "tkXY:Depends"
if {[lsearch -exact $vars "\${tkXY:Depends}"] >= 0} {
addsubstvar $package "tkXY:Depends" "tk$ver$tkdep"
}
delsubstvar $package "tk:Depends"
if {[lsearch -exact $vars "\${tk:Depends}"] >= 0} {
addsubstvar $package "tk:Depends" "tk$dep"
}
# wish:Depends is retained for backward compatibility
delsubstvar $package "wish:Depends"
if {[lsearch -exact $vars "\${wish:Depends}"] >= 0} {
addsubstvar $package "wish:Depends" "tk$dep"
}
}
|