Danek Duvall wrote:
> http://cr.opensolaris.org/~dduvall/pkg-backrefs/
In order to do some sneaky convolutions in the pkg(5) packaging, I had to
add the following patch to pkgmogrify:
--- a/src/util/publish/pkgmogrify.py
+++ b/src/util/publish/pkgmogrify.py
@@ -102,7 +102,11 @@ def add_transform(transform, filename, l
pkg_attrs, filename, lineno)
newval = substitute_values(value, action, matches,
pkg_attrs, filename, lineno)
- action.attrs[newattr] = newval
+ if newattr == "action.hash":
+ if hasattr(action, "hash"):
+ action.hash = newval
+ else:
+ action.attrs[newattr] = newval
return action
operation = set_func
which basically just lets you set the hash of the action with the "set"
operation to whatever you want. It's used in the pycurl package this way:
<transform file path=$(PYDIRVP)/share.* -> set action.hash %(path)>
<transform dir file path=$(PYDIRVP)/share.* -> edit path $(PYDIRVP) usr>
I've also added the following, which re-does the way that badly-numbered
backreferences are handled. In particular, %<0> now returns an error
instead of stack tracing.
--- a/src/util/publish/pkgmogrify.py
+++ b/src/util/publish/pkgmogrify.py
@@ -427,11 +427,12 @@ def substitute_values(msg, action, match
), (None,))
for i in re.finditer(r"%<\d>", msg):
ref = int(i.string[slice(*i.span())][2:-1])
- try:
- newmsg += msg[prevend:i.start()] + backrefs[ref]
- except IndexError:
+
+ if ref == 0 or ref > len(backrefs) - 1:
raise RuntimeError, _("no match group %d (max
%d)") % \
(ref, len(backrefs) - 1)
+
+ newmsg += msg[prevend:i.start()] + backrefs[ref]
prevend = i.end()
newmsg += msg[prevend:]
Thanks,
Danek
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss