summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-05-12 17:17:54 +0200
committerJustin Davis <jrcd83@gmail.com>2012-05-12 17:17:54 +0200
commit0e751f1969c99932ff8760a7e59ee8687b0925db (patch)
tree16d1e48d8034606be1f8ef8a87f83a29af8ac799
parente49d6c98ba070fdc56a231479b1b75074ac8bd68 (diff)
downloadgenpkg-0e751f1969c99932ff8760a7e59ee8687b0925db.tar.gz
genpkg-0e751f1969c99932ff8760a7e59ee8687b0925db.tar.xz
Adds setdep command.
Fix bugs when appending to dotinstall files.
-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]