diff options
author | Justin Davis <jrcd83@gmail.com> | 2012-05-12 17:17:54 +0200 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2012-05-12 17:17:54 +0200 |
commit | 0e751f1969c99932ff8760a7e59ee8687b0925db (patch) | |
tree | 16d1e48d8034606be1f8ef8a87f83a29af8ac799 | |
parent | e49d6c98ba070fdc56a231479b1b75074ac8bd68 (diff) | |
download | genpkg-0e751f1969c99932ff8760a7e59ee8687b0925db.tar.gz genpkg-0e751f1969c99932ff8760a7e59ee8687b0925db.tar.xz |
Adds setdep command.
Fix bugs when appending to dotinstall files.
-rwxr-xr-x | bin/modpkg | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -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] |