summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/modpkg34
1 files changed, 33 insertions, 1 deletions
diff --git a/bin/modpkg b/bin/modpkg
index 17c273a..3b9f572 100755
--- a/bin/modpkg
+++ b/bin/modpkg
@@ -86,6 +86,7 @@ $modi eval {
}
proc initdotfunc {func} {
+ global pkgname source
if {! [file exists PKGTREE/$pkgname.install]} {
lappend source "$pkgname.install"
}
@@ -93,7 +94,7 @@ $modi eval {
}
proc fput {name code section} {
- global dotfuncs pbfuncs
+ global dotfuncs pbfuncs pkgname
if {$name in $dotfuncs} {
initdotfunc $name
@@ -127,6 +128,37 @@ $modi eval {
set src [lreplace $src $idx $idx]
}
}
+
+ proc splitdep {dep} {
+ set re {(?x) ^ ([^<>=]+) ([<>]=?.+)? $}
+ if {[regexp $re $dep -> name cmp]} {
+ return [list $name $cmp]
+ } else {
+ error "Invalid dependency string: $dep"
+ }
+ }
+
+ proc setdep {type newdep} {
+ if {! [string match *depends $type]} {
+ error "setdep can only be used with depends fields"
+ }
+ upvar #0 $type deps
+ if {! [info exists deps]} {
+ error "Unknown dependency field: $type"
+ }
+
+ lassign [splitdep $newdep] depname newcmp
+ for {set i 0} {$i < [llength $deps]} {incr i} {
+ set dep [lindex $deps $i]
+ lassign [splitdep $dep] name cmp
+ if {$name eq $depname} {
+ set deps [lreplace $deps $i $i $name$newcmp]
+ return
+ }
+ }
+
+ error "$name was not found in $type"
+ }
}
$modi eval [read $modch]