2008-11-22 17:22:01 +08:00
|
|
|
# rpmmacro.at: test rpm macros
|
|
|
|
#
|
2008-11-22 19:26:43 +08:00
|
|
|
AT_BANNER([RPM macros])
|
2008-11-22 17:22:01 +08:00
|
|
|
|
|
|
|
# ------------------------------
|
|
|
|
AT_SETUP([simple rpm --eval])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 17:22:01 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm --define "this that" --eval '%{this}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[that
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([simple true conditional rpm --eval])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 17:22:01 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm --define "this that" --eval '%{?this}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[that
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([simple false conditional rpm --eval])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 17:22:01 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm --define "this that" --eval '%{?that}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_SETUP([uncompress macro])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_CHECK([
|
|
|
|
(cd ${RPMDATA}/SOURCES/ &&
|
|
|
|
run rpm \
|
|
|
|
--define "__gzip /my/bin/gzip" \
|
|
|
|
--eval "%{uncompress:hello-2.0.tar.gz}"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[/my/bin/gzip -dc hello-2.0.tar.gz
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([basename macro])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_CHECK([
|
|
|
|
(cd ${RPMDATA}/SOURCES/ &&
|
|
|
|
run rpm \
|
|
|
|
--eval "%{basename:${RPMDATA}/SOURCES/hello-2.0.tar.gz}"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[hello-2.0.tar.gz
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([suffix macro])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_CHECK([
|
|
|
|
(cd ${RPMDATA}/SOURCES/ &&
|
|
|
|
run rpm \
|
|
|
|
--eval "%{suffix:${RPMDATA}/SOURCES/hello-2.0.tar.gz}"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[gz
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([url2path macro])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_CHECK([
|
|
|
|
(cd ${RPMDATA}/SOURCES/ &&
|
|
|
|
run rpm \
|
|
|
|
--eval "%{url2path:http://hello.org/releases/hello-2.0.tar.gz}"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[/releases/hello-2.0.tar.gz
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([shell expansion])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros])
|
2008-11-22 19:20:33 +08:00
|
|
|
AT_CHECK([
|
|
|
|
(cd ${RPMDATA}/SOURCES/ &&
|
|
|
|
run rpm \
|
|
|
|
--eval "%(echo foo)"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[foo
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
2008-11-22 17:22:01 +08:00
|
|
|
AT_SETUP([simple lua --eval])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros lua])
|
2008-11-22 17:22:01 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm --eval '%{lua:print(5*5)}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[25
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
2008-11-22 19:45:17 +08:00
|
|
|
|
|
|
|
AT_SETUP([lua rpm extensions])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros lua])
|
2008-11-22 19:45:17 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm --eval '%{lua: rpm.define("foo bar") print(rpm.expand("%{foo}"))}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[bar
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([lua posix extensions])
|
2008-11-22 20:07:34 +08:00
|
|
|
AT_KEYWORDS([macros lua])
|
2008-11-22 19:45:17 +08:00
|
|
|
AT_CHECK([
|
|
|
|
run rpm \
|
|
|
|
--eval '%{lua: posix.putenv("LUATEST=ok") print(posix.getenv("LUATEST"))}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[ok
|
|
|
|
])
|
|
|
|
AT_CLEANUP
|
2010-11-15 15:36:17 +08:00
|
|
|
|
|
|
|
AT_SETUP([lua script exit behavior])
|
|
|
|
AT_KEYWORDS([macros lua])
|
|
|
|
AT_CHECK([
|
|
|
|
run rpm \
|
|
|
|
--eval '%{lua: os.exit()}))}'
|
|
|
|
],
|
|
|
|
[0],
|
|
|
|
[
|
|
|
|
],
|
|
|
|
[error: lua script failed: [[string "<lua>"]]:1: exit not permitted in this context]
|
|
|
|
)
|
|
|
|
AT_CLEANUP
|