Mail Archives: cygwin/2006/12/09/02:06:05
--------------060002060609030009050909
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
And here's number 5 (or 6, depending on how you count). This one adds
the ability to call cygport functions (in addition to the usual
prep/compile/install/ and friends).
It works this way:
cygport cvs-1.11.22-1 custom0-cvs_check_local_known_fail
will invoke cvs_check_local_known_fail() with no additional arguments.
However,
cygport cvs-1.11.22-1 custom3-cvs_do_one_test rcslib remote fail
will invoke cvs_do_one_test() with $1=rcslib $2=remote $3=fail.
Note that the number following 'custom' indicates how many arguments to
consume and forward to the target command. Variants from 0 to 9 are
accepted.
The custom-command framework will ONLY invoke shell functions; it can't
be used to run arbitrary commands (although, you could simply edit the
.cygport file to define a shell function, that then runs those arbitrary
commands).
The subcommand 'custom-show' will list all shell functions defined
within the cygport runtime envionment, including those defined in the
cygport file.
cygport cvs-1.11.22-1 custom-show
As you can tell from my examples, I needed this functionality to deal
with cvs's totally braindead testsuite "system". (During development,
that is. Normal cygport usage for running the cvs testsuite would be
'cygport cvs-1.11.22-1 check' as usual).
You can test the custom-command functionality (using any old cygport
file) by doing:
cygport some-cygport-file custom0-dummy
cygport some-cygport-file custom1-dummy a
cygport some-cygport-file custom2-dummy a b
etc -- or even
cygport some-cygport-file \
prep \
custom2-dummy a b \
compile \
custom1-dummy c \
install \
custom4-dummy d e f g \
pkg
2006-12-08 Charles Wilson <...>
* bin/cygport.in (custom_dummy_core): new function, used to test
custom-command framework
(custom_dummy): ditto
(main): add implentation for custom-show) and customN-*)
--
Chuck
--------------060002060609030009050909
Content-Type: text/plain;
name="cygport-custom-cmds.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="cygport-custom-cmds.patch"
--- cygport.in 2006-11-28 02:16:51.093750000 -0500
+++ cygport.in 2006-12-07 23:20:27.953125000 -0500
@@ -1856,11 +1856,38 @@
################################################################################
#
+# test target for custom command hooks
+#
+################################################################################
+custom_dummy_core() {
+ local -i my_c=0
+ local -i my_argc=$#
+
+ while (( my_c < my_argc ))
+ do
+ my_c+=1
+ echo "${my_c}: $1"
+ shift
+ done
+}
+custom_dummy() {
+ inform "custom_dummy called with $# args"
+ custom_dummy_core "$@"
+}
+export -f custom_dummy_core custom_dummy
+readonly -f custom_dummy_core custom_dummy
+
+################################################################################
+#
# End of functions
#
################################################################################
declare -i arg_n=2
+declare -i custom_arg_n
+declare -i custom_argc
+declare -a custom_args
+declare -x custom_cmd
while (( arg_n < argc ))
do
@@ -1933,6 +1960,46 @@
finish;
_status=$?;
;;
+ custom-show)
+ for fnc in $(set | sed -n '/()/s/()//p')
+ do
+ if test "$(type -t ${fnc})" == "function"
+ then
+ echo " ${fnc}"
+ fi
+ done
+ ;;
+ custom0-* | custom1-* | custom2-* | custom3-* | custom4-* | \
+ custom5-* | custom6-* | custom7-* | custom8-* | custom9-* )
+ custom_argc=${argv[${arg_n}]:6:1}
+ custom_cmd=${argv[${arg_n}]:8}
+ if [ -z "${custom_cmd}" ]
+ then
+ error "${argv[${arg_n}]}* command has no target following the 'custom${custom_argc}-'"
+ fi
+
+ # consume arguments
+ custom_arg_n=0
+ while (( custom_arg_n < custom_argc )) && (( arg_n+1 < argc ))
+ do
+ arg_n+=1
+ custom_args[${custom_arg_n}]="${argv[${arg_n}]}"
+ custom_arg_n+=1
+ done
+ if (( custom_arg_n < custom_argc ))
+ then
+ error "custom${custom_argc} command ${custom_cmd}: not enough arguments"
+ fi
+
+ if test "$(type -t ${custom_cmd})" == "function"
+ then
+ __stage ${custom_cmd} && eval "${custom_cmd} ${custom_args[@]}"
+ _status=$?;
+ else
+ error "${custom_cmd} is not a shell function"
+ fi
+ unset custom_args
+ ;;
help)
__show_help;
exit 0;
--------------060002060609030009050909
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--------------060002060609030009050909--
- Raw text -