rice2 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +23 -0
- data/Doxyfile +2268 -0
- data/Makefile.am +26 -0
- data/Makefile.in +929 -0
- data/README.md +1054 -0
- data/README.mingw +8 -0
- data/Rakefile +24 -0
- data/aclocal.m4 +1090 -0
- data/bootstrap +8 -0
- data/config.guess +1667 -0
- data/config.sub +1793 -0
- data/configure +8209 -0
- data/configure.ac +55 -0
- data/depcomp +791 -0
- data/doxygen.ac +314 -0
- data/doxygen.am +186 -0
- data/extconf.rb +66 -0
- data/install-sh +529 -0
- data/missing +215 -0
- data/post-autoconf.rb +22 -0
- data/post-automake.rb +28 -0
- data/rice/Address_Registration_Guard.cpp +22 -0
- data/rice/Address_Registration_Guard.hpp +7 -0
- data/rice/Address_Registration_Guard.ipp +37 -0
- data/rice/Address_Registration_Guard_defn.hpp +75 -0
- data/rice/Arg.hpp +8 -0
- data/rice/Arg_impl.hpp +129 -0
- data/rice/Arg_operators.cpp +21 -0
- data/rice/Arg_operators.hpp +19 -0
- data/rice/Array.hpp +214 -0
- data/rice/Array.ipp +256 -0
- data/rice/Builtin_Object.hpp +8 -0
- data/rice/Builtin_Object.ipp +50 -0
- data/rice/Builtin_Object_defn.hpp +50 -0
- data/rice/Class.cpp +57 -0
- data/rice/Class.hpp +8 -0
- data/rice/Class.ipp +6 -0
- data/rice/Class_defn.hpp +83 -0
- data/rice/Constructor.hpp +47 -0
- data/rice/Data_Object.hpp +8 -0
- data/rice/Data_Object.ipp +133 -0
- data/rice/Data_Object_defn.hpp +138 -0
- data/rice/Data_Type.cpp +54 -0
- data/rice/Data_Type.hpp +8 -0
- data/rice/Data_Type.ipp +365 -0
- data/rice/Data_Type_defn.hpp +261 -0
- data/rice/Data_Type_fwd.hpp +12 -0
- data/rice/Director.cpp +13 -0
- data/rice/Director.hpp +39 -0
- data/rice/Enum.hpp +117 -0
- data/rice/Enum.ipp +246 -0
- data/rice/Exception.cpp +59 -0
- data/rice/Exception.hpp +13 -0
- data/rice/Exception_Base.hpp +8 -0
- data/rice/Exception_Base.ipp +13 -0
- data/rice/Exception_Base_defn.hpp +27 -0
- data/rice/Exception_defn.hpp +69 -0
- data/rice/Hash.hpp +227 -0
- data/rice/Hash.ipp +329 -0
- data/rice/Identifier.cpp +8 -0
- data/rice/Identifier.hpp +50 -0
- data/rice/Identifier.ipp +33 -0
- data/rice/Jump_Tag.hpp +24 -0
- data/rice/Makefile.am +122 -0
- data/rice/Makefile.in +885 -0
- data/rice/Module.cpp +84 -0
- data/rice/Module.hpp +8 -0
- data/rice/Module.ipp +6 -0
- data/rice/Module_defn.hpp +88 -0
- data/rice/Module_impl.hpp +281 -0
- data/rice/Module_impl.ipp +345 -0
- data/rice/Object.cpp +169 -0
- data/rice/Object.hpp +8 -0
- data/rice/Object.ipp +33 -0
- data/rice/Object_defn.hpp +214 -0
- data/rice/Require_Guard.hpp +21 -0
- data/rice/String.cpp +94 -0
- data/rice/String.hpp +91 -0
- data/rice/Struct.cpp +117 -0
- data/rice/Struct.hpp +162 -0
- data/rice/Struct.ipp +26 -0
- data/rice/Symbol.cpp +25 -0
- data/rice/Symbol.hpp +66 -0
- data/rice/Symbol.ipp +44 -0
- data/rice/config.hpp +47 -0
- data/rice/config.hpp.in +46 -0
- data/rice/detail/Arguments.hpp +118 -0
- data/rice/detail/Auto_Function_Wrapper.hpp +898 -0
- data/rice/detail/Auto_Function_Wrapper.ipp +3694 -0
- data/rice/detail/Auto_Member_Function_Wrapper.hpp +897 -0
- data/rice/detail/Auto_Member_Function_Wrapper.ipp +2774 -0
- data/rice/detail/Caster.hpp +103 -0
- data/rice/detail/Exception_Handler.hpp +8 -0
- data/rice/detail/Exception_Handler.ipp +68 -0
- data/rice/detail/Exception_Handler_defn.hpp +96 -0
- data/rice/detail/Iterator.hpp +93 -0
- data/rice/detail/Not_Copyable.hpp +25 -0
- data/rice/detail/Wrapped_Function.hpp +33 -0
- data/rice/detail/cfp.hpp +24 -0
- data/rice/detail/cfp.ipp +51 -0
- data/rice/detail/check_ruby_type.cpp +27 -0
- data/rice/detail/check_ruby_type.hpp +23 -0
- data/rice/detail/creation_funcs.hpp +37 -0
- data/rice/detail/creation_funcs.ipp +36 -0
- data/rice/detail/default_allocation_func.hpp +23 -0
- data/rice/detail/default_allocation_func.ipp +11 -0
- data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
- data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
- data/rice/detail/demangle.cpp +56 -0
- data/rice/detail/demangle.hpp +19 -0
- data/rice/detail/env.hpp +11 -0
- data/rice/detail/from_ruby.hpp +43 -0
- data/rice/detail/from_ruby.ipp +60 -0
- data/rice/detail/method_data.cpp +92 -0
- data/rice/detail/method_data.hpp +21 -0
- data/rice/detail/node.hpp +13 -0
- data/rice/detail/protect.cpp +29 -0
- data/rice/detail/protect.hpp +34 -0
- data/rice/detail/ruby.hpp +74 -0
- data/rice/detail/ruby_version_code.hpp +6 -0
- data/rice/detail/ruby_version_code.hpp.in +6 -0
- data/rice/detail/st.hpp +22 -0
- data/rice/detail/to_ruby.hpp +22 -0
- data/rice/detail/to_ruby.ipp +36 -0
- data/rice/detail/traits.hpp +43 -0
- data/rice/detail/win32.hpp +16 -0
- data/rice/detail/wrap_function.hpp +66 -0
- data/rice/global_function.hpp +33 -0
- data/rice/global_function.ipp +22 -0
- data/rice/protect.hpp +38 -0
- data/rice/protect.ipp +1134 -0
- data/rice/ruby_mark.hpp +13 -0
- data/rice/ruby_try_catch.hpp +86 -0
- data/rice/rubypp.rb +97 -0
- data/rice/to_from_ruby.hpp +8 -0
- data/rice/to_from_ruby.ipp +418 -0
- data/rice/to_from_ruby_defn.hpp +70 -0
- data/ruby.ac +135 -0
- data/ruby/Makefile.am +1 -0
- data/ruby/Makefile.in +628 -0
- data/ruby/lib/Makefile.am +3 -0
- data/ruby/lib/Makefile.in +506 -0
- data/ruby/lib/mkmf-rice.rb.in +217 -0
- data/ruby/lib/version.rb +3 -0
- data/sample/Makefile.am +47 -0
- data/sample/Makefile.in +489 -0
- data/sample/enum/extconf.rb +3 -0
- data/sample/enum/sample_enum.cpp +54 -0
- data/sample/enum/test.rb +8 -0
- data/sample/inheritance/animals.cpp +98 -0
- data/sample/inheritance/extconf.rb +3 -0
- data/sample/inheritance/test.rb +7 -0
- data/sample/map/extconf.rb +3 -0
- data/sample/map/map.cpp +81 -0
- data/sample/map/test.rb +7 -0
- data/test/Makefile.am +72 -0
- data/test/Makefile.in +1213 -0
- data/test/ext/Makefile.am +41 -0
- data/test/ext/Makefile.in +483 -0
- data/test/ext/t1/Foo.hpp +10 -0
- data/test/ext/t1/extconf.rb +2 -0
- data/test/ext/t1/t1.cpp +15 -0
- data/test/ext/t2/extconf.rb +2 -0
- data/test/ext/t2/t2.cpp +11 -0
- data/test/test_Address_Registration_Guard.cpp +43 -0
- data/test/test_Array.cpp +248 -0
- data/test/test_Builtin_Object.cpp +71 -0
- data/test/test_Class.cpp +496 -0
- data/test/test_Constructor.cpp +128 -0
- data/test/test_Data_Object.cpp +275 -0
- data/test/test_Data_Type.cpp +348 -0
- data/test/test_Director.cpp +308 -0
- data/test/test_Enum.cpp +215 -0
- data/test/test_Exception.cpp +47 -0
- data/test/test_Hash.cpp +212 -0
- data/test/test_Identifier.cpp +70 -0
- data/test/test_Jump_Tag.cpp +17 -0
- data/test/test_Memory_Management.cpp +50 -0
- data/test/test_Module.cpp +497 -0
- data/test/test_Object.cpp +159 -0
- data/test/test_String.cpp +107 -0
- data/test/test_Struct.cpp +205 -0
- data/test/test_Symbol.cpp +63 -0
- data/test/test_To_From_Ruby.cpp +428 -0
- data/test/test_global_functions.cpp +114 -0
- data/test/test_rice.rb +41 -0
- data/test/unittest.cpp +136 -0
- data/test/unittest.hpp +294 -0
- metadata +297 -0
data/extconf.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# To allow Rice to be installed on non-system installs of Ruby (rbenv or rvm),
|
2
|
+
# the rice gem uses the extconf version of deployment
|
3
|
+
# rather than configure. This file will get the appropriate values from CONFIG
|
4
|
+
# for the Ruby that this library is being installed into and generate
|
5
|
+
# the proper arguments to ./configure.
|
6
|
+
#
|
7
|
+
# With this, installing on any of the Ruby versions installed on a machine is as
|
8
|
+
# easy as /path/to/the/gem install rice.
|
9
|
+
|
10
|
+
$:.unshift File.expand_path(File.dirname(__FILE__))
|
11
|
+
|
12
|
+
require 'rbconfig'
|
13
|
+
require 'ruby/lib/version.rb'
|
14
|
+
|
15
|
+
prefix_dir = File.join(File.dirname(File.expand_path(__FILE__)), "ruby", "lib")
|
16
|
+
with_ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["RUBY_INSTALL_NAME"])
|
17
|
+
|
18
|
+
other_opts = ""
|
19
|
+
env = ""
|
20
|
+
|
21
|
+
if RbConfig::CONFIG["ENABLE_SHARED"] == "no"
|
22
|
+
abort <<EOC.chomp
|
23
|
+
Unfortunately Rice does not build against a staticly linked Ruby.
|
24
|
+
You'll need to rebuild Ruby with --enable-shared to use this library.
|
25
|
+
|
26
|
+
If you're on rvm: rvm reinstall [version] -- --enable-shared
|
27
|
+
If you're on rbenv: CONFIGURE_OPTS="--enable-shared" rbenv install [version]
|
28
|
+
If you're on Heroku: upgrade your stack to heroku-16 or later
|
29
|
+
EOC
|
30
|
+
end
|
31
|
+
|
32
|
+
if RUBY_PLATFORM =~ /darwin(\d+)/
|
33
|
+
check_iconv = 'echo "#include <iconv.h>" | g++ -xc -fsyntax-only -'
|
34
|
+
if !system(check_iconv)
|
35
|
+
abort <<EOM.chomp
|
36
|
+
-----
|
37
|
+
The file "/usr/include/iconv.h" is missing in your build environment,
|
38
|
+
which means you haven't installed Xcode Command Line Tools properly.
|
39
|
+
To install Command Line Tools, try running `xcode-select --install` on
|
40
|
+
terminal and follow the instructions. If it fails, open Xcode.app,
|
41
|
+
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
|
42
|
+
Tools" to open the developer site, download the installer for your OS
|
43
|
+
version and run it.
|
44
|
+
-----
|
45
|
+
EOM
|
46
|
+
end
|
47
|
+
|
48
|
+
darwin_version = $1.to_i
|
49
|
+
|
50
|
+
if darwin_version >= 10
|
51
|
+
arch = RbConfig::CONFIG["arch"].split("-")[0]
|
52
|
+
|
53
|
+
if arch == "universal"
|
54
|
+
arch = `uname -m`.strip
|
55
|
+
end
|
56
|
+
|
57
|
+
other_opts = "--disable-dependency-tracking"
|
58
|
+
env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
|
59
|
+
else
|
60
|
+
arch = `uname -p`.chomp
|
61
|
+
env = "ARCHFLAGS='-arch #{arch}' CPPFLAGS='-arch #{arch}'"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
system "sh bootstrap"
|
66
|
+
system "#{env} sh configure --with-ruby=#{with_ruby} --prefix=#{prefix_dir} #{other_opts}"
|
data/install-sh
ADDED
@@ -0,0 +1,529 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# install - install a program, script, or datafile
|
3
|
+
|
4
|
+
scriptversion=2018-03-11.20; # UTC
|
5
|
+
|
6
|
+
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
7
|
+
# later released in X11R6 (xc/config/util/install.sh) with the
|
8
|
+
# following copyright and license.
|
9
|
+
#
|
10
|
+
# Copyright (C) 1994 X Consortium
|
11
|
+
#
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
+
# of this software and associated documentation files (the "Software"), to
|
14
|
+
# deal in the Software without restriction, including without limitation the
|
15
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
17
|
+
# furnished to do so, subject to the following conditions:
|
18
|
+
#
|
19
|
+
# The above copyright notice and this permission notice shall be included in
|
20
|
+
# all copies or substantial portions of the Software.
|
21
|
+
#
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
+
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
26
|
+
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
27
|
+
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
#
|
29
|
+
# Except as contained in this notice, the name of the X Consortium shall not
|
30
|
+
# be used in advertising or otherwise to promote the sale, use or other deal-
|
31
|
+
# ings in this Software without prior written authorization from the X Consor-
|
32
|
+
# tium.
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# FSF changes to this file are in the public domain.
|
36
|
+
#
|
37
|
+
# Calling this script install-sh is preferred over install.sh, to prevent
|
38
|
+
# 'make' implicit rules from creating a file called install from it
|
39
|
+
# when there is no Makefile.
|
40
|
+
#
|
41
|
+
# This script is compatible with the BSD install script, but was written
|
42
|
+
# from scratch.
|
43
|
+
|
44
|
+
tab=' '
|
45
|
+
nl='
|
46
|
+
'
|
47
|
+
IFS=" $tab$nl"
|
48
|
+
|
49
|
+
# Set DOITPROG to "echo" to test this script.
|
50
|
+
|
51
|
+
doit=${DOITPROG-}
|
52
|
+
doit_exec=${doit:-exec}
|
53
|
+
|
54
|
+
# Put in absolute file names if you don't have them in your path;
|
55
|
+
# or use environment vars.
|
56
|
+
|
57
|
+
chgrpprog=${CHGRPPROG-chgrp}
|
58
|
+
chmodprog=${CHMODPROG-chmod}
|
59
|
+
chownprog=${CHOWNPROG-chown}
|
60
|
+
cmpprog=${CMPPROG-cmp}
|
61
|
+
cpprog=${CPPROG-cp}
|
62
|
+
mkdirprog=${MKDIRPROG-mkdir}
|
63
|
+
mvprog=${MVPROG-mv}
|
64
|
+
rmprog=${RMPROG-rm}
|
65
|
+
stripprog=${STRIPPROG-strip}
|
66
|
+
|
67
|
+
posix_mkdir=
|
68
|
+
|
69
|
+
# Desired mode of installed file.
|
70
|
+
mode=0755
|
71
|
+
|
72
|
+
chgrpcmd=
|
73
|
+
chmodcmd=$chmodprog
|
74
|
+
chowncmd=
|
75
|
+
mvcmd=$mvprog
|
76
|
+
rmcmd="$rmprog -f"
|
77
|
+
stripcmd=
|
78
|
+
|
79
|
+
src=
|
80
|
+
dst=
|
81
|
+
dir_arg=
|
82
|
+
dst_arg=
|
83
|
+
|
84
|
+
copy_on_change=false
|
85
|
+
is_target_a_directory=possibly
|
86
|
+
|
87
|
+
usage="\
|
88
|
+
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
89
|
+
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
90
|
+
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
91
|
+
or: $0 [OPTION]... -d DIRECTORIES...
|
92
|
+
|
93
|
+
In the 1st form, copy SRCFILE to DSTFILE.
|
94
|
+
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
95
|
+
In the 4th, create DIRECTORIES.
|
96
|
+
|
97
|
+
Options:
|
98
|
+
--help display this help and exit.
|
99
|
+
--version display version info and exit.
|
100
|
+
|
101
|
+
-c (ignored)
|
102
|
+
-C install only if different (preserve the last data modification time)
|
103
|
+
-d create directories instead of installing files.
|
104
|
+
-g GROUP $chgrpprog installed files to GROUP.
|
105
|
+
-m MODE $chmodprog installed files to MODE.
|
106
|
+
-o USER $chownprog installed files to USER.
|
107
|
+
-s $stripprog installed files.
|
108
|
+
-t DIRECTORY install into DIRECTORY.
|
109
|
+
-T report an error if DSTFILE is a directory.
|
110
|
+
|
111
|
+
Environment variables override the default commands:
|
112
|
+
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
113
|
+
RMPROG STRIPPROG
|
114
|
+
"
|
115
|
+
|
116
|
+
while test $# -ne 0; do
|
117
|
+
case $1 in
|
118
|
+
-c) ;;
|
119
|
+
|
120
|
+
-C) copy_on_change=true;;
|
121
|
+
|
122
|
+
-d) dir_arg=true;;
|
123
|
+
|
124
|
+
-g) chgrpcmd="$chgrpprog $2"
|
125
|
+
shift;;
|
126
|
+
|
127
|
+
--help) echo "$usage"; exit $?;;
|
128
|
+
|
129
|
+
-m) mode=$2
|
130
|
+
case $mode in
|
131
|
+
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
132
|
+
echo "$0: invalid mode: $mode" >&2
|
133
|
+
exit 1;;
|
134
|
+
esac
|
135
|
+
shift;;
|
136
|
+
|
137
|
+
-o) chowncmd="$chownprog $2"
|
138
|
+
shift;;
|
139
|
+
|
140
|
+
-s) stripcmd=$stripprog;;
|
141
|
+
|
142
|
+
-t)
|
143
|
+
is_target_a_directory=always
|
144
|
+
dst_arg=$2
|
145
|
+
# Protect names problematic for 'test' and other utilities.
|
146
|
+
case $dst_arg in
|
147
|
+
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
148
|
+
esac
|
149
|
+
shift;;
|
150
|
+
|
151
|
+
-T) is_target_a_directory=never;;
|
152
|
+
|
153
|
+
--version) echo "$0 $scriptversion"; exit $?;;
|
154
|
+
|
155
|
+
--) shift
|
156
|
+
break;;
|
157
|
+
|
158
|
+
-*) echo "$0: invalid option: $1" >&2
|
159
|
+
exit 1;;
|
160
|
+
|
161
|
+
*) break;;
|
162
|
+
esac
|
163
|
+
shift
|
164
|
+
done
|
165
|
+
|
166
|
+
# We allow the use of options -d and -T together, by making -d
|
167
|
+
# take the precedence; this is for compatibility with GNU install.
|
168
|
+
|
169
|
+
if test -n "$dir_arg"; then
|
170
|
+
if test -n "$dst_arg"; then
|
171
|
+
echo "$0: target directory not allowed when installing a directory." >&2
|
172
|
+
exit 1
|
173
|
+
fi
|
174
|
+
fi
|
175
|
+
|
176
|
+
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
177
|
+
# When -d is used, all remaining arguments are directories to create.
|
178
|
+
# When -t is used, the destination is already specified.
|
179
|
+
# Otherwise, the last argument is the destination. Remove it from $@.
|
180
|
+
for arg
|
181
|
+
do
|
182
|
+
if test -n "$dst_arg"; then
|
183
|
+
# $@ is not empty: it contains at least $arg.
|
184
|
+
set fnord "$@" "$dst_arg"
|
185
|
+
shift # fnord
|
186
|
+
fi
|
187
|
+
shift # arg
|
188
|
+
dst_arg=$arg
|
189
|
+
# Protect names problematic for 'test' and other utilities.
|
190
|
+
case $dst_arg in
|
191
|
+
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
192
|
+
esac
|
193
|
+
done
|
194
|
+
fi
|
195
|
+
|
196
|
+
if test $# -eq 0; then
|
197
|
+
if test -z "$dir_arg"; then
|
198
|
+
echo "$0: no input file specified." >&2
|
199
|
+
exit 1
|
200
|
+
fi
|
201
|
+
# It's OK to call 'install-sh -d' without argument.
|
202
|
+
# This can happen when creating conditional directories.
|
203
|
+
exit 0
|
204
|
+
fi
|
205
|
+
|
206
|
+
if test -z "$dir_arg"; then
|
207
|
+
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
208
|
+
if test ! -d "$dst_arg"; then
|
209
|
+
echo "$0: $dst_arg: Is not a directory." >&2
|
210
|
+
exit 1
|
211
|
+
fi
|
212
|
+
fi
|
213
|
+
fi
|
214
|
+
|
215
|
+
if test -z "$dir_arg"; then
|
216
|
+
do_exit='(exit $ret); exit $ret'
|
217
|
+
trap "ret=129; $do_exit" 1
|
218
|
+
trap "ret=130; $do_exit" 2
|
219
|
+
trap "ret=141; $do_exit" 13
|
220
|
+
trap "ret=143; $do_exit" 15
|
221
|
+
|
222
|
+
# Set umask so as not to create temps with too-generous modes.
|
223
|
+
# However, 'strip' requires both read and write access to temps.
|
224
|
+
case $mode in
|
225
|
+
# Optimize common cases.
|
226
|
+
*644) cp_umask=133;;
|
227
|
+
*755) cp_umask=22;;
|
228
|
+
|
229
|
+
*[0-7])
|
230
|
+
if test -z "$stripcmd"; then
|
231
|
+
u_plus_rw=
|
232
|
+
else
|
233
|
+
u_plus_rw='% 200'
|
234
|
+
fi
|
235
|
+
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
236
|
+
*)
|
237
|
+
if test -z "$stripcmd"; then
|
238
|
+
u_plus_rw=
|
239
|
+
else
|
240
|
+
u_plus_rw=,u+rw
|
241
|
+
fi
|
242
|
+
cp_umask=$mode$u_plus_rw;;
|
243
|
+
esac
|
244
|
+
fi
|
245
|
+
|
246
|
+
for src
|
247
|
+
do
|
248
|
+
# Protect names problematic for 'test' and other utilities.
|
249
|
+
case $src in
|
250
|
+
-* | [=\(\)!]) src=./$src;;
|
251
|
+
esac
|
252
|
+
|
253
|
+
if test -n "$dir_arg"; then
|
254
|
+
dst=$src
|
255
|
+
dstdir=$dst
|
256
|
+
test -d "$dstdir"
|
257
|
+
dstdir_status=$?
|
258
|
+
else
|
259
|
+
|
260
|
+
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
261
|
+
# might cause directories to be created, which would be especially bad
|
262
|
+
# if $src (and thus $dsttmp) contains '*'.
|
263
|
+
if test ! -f "$src" && test ! -d "$src"; then
|
264
|
+
echo "$0: $src does not exist." >&2
|
265
|
+
exit 1
|
266
|
+
fi
|
267
|
+
|
268
|
+
if test -z "$dst_arg"; then
|
269
|
+
echo "$0: no destination specified." >&2
|
270
|
+
exit 1
|
271
|
+
fi
|
272
|
+
dst=$dst_arg
|
273
|
+
|
274
|
+
# If destination is a directory, append the input filename.
|
275
|
+
if test -d "$dst"; then
|
276
|
+
if test "$is_target_a_directory" = never; then
|
277
|
+
echo "$0: $dst_arg: Is a directory" >&2
|
278
|
+
exit 1
|
279
|
+
fi
|
280
|
+
dstdir=$dst
|
281
|
+
dstbase=`basename "$src"`
|
282
|
+
case $dst in
|
283
|
+
*/) dst=$dst$dstbase;;
|
284
|
+
*) dst=$dst/$dstbase;;
|
285
|
+
esac
|
286
|
+
dstdir_status=0
|
287
|
+
else
|
288
|
+
dstdir=`dirname "$dst"`
|
289
|
+
test -d "$dstdir"
|
290
|
+
dstdir_status=$?
|
291
|
+
fi
|
292
|
+
fi
|
293
|
+
|
294
|
+
case $dstdir in
|
295
|
+
*/) dstdirslash=$dstdir;;
|
296
|
+
*) dstdirslash=$dstdir/;;
|
297
|
+
esac
|
298
|
+
|
299
|
+
obsolete_mkdir_used=false
|
300
|
+
|
301
|
+
if test $dstdir_status != 0; then
|
302
|
+
case $posix_mkdir in
|
303
|
+
'')
|
304
|
+
# Create intermediate dirs using mode 755 as modified by the umask.
|
305
|
+
# This is like FreeBSD 'install' as of 1997-10-28.
|
306
|
+
umask=`umask`
|
307
|
+
case $stripcmd.$umask in
|
308
|
+
# Optimize common cases.
|
309
|
+
*[2367][2367]) mkdir_umask=$umask;;
|
310
|
+
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
311
|
+
|
312
|
+
*[0-7])
|
313
|
+
mkdir_umask=`expr $umask + 22 \
|
314
|
+
- $umask % 100 % 40 + $umask % 20 \
|
315
|
+
- $umask % 10 % 4 + $umask % 2
|
316
|
+
`;;
|
317
|
+
*) mkdir_umask=$umask,go-w;;
|
318
|
+
esac
|
319
|
+
|
320
|
+
# With -d, create the new directory with the user-specified mode.
|
321
|
+
# Otherwise, rely on $mkdir_umask.
|
322
|
+
if test -n "$dir_arg"; then
|
323
|
+
mkdir_mode=-m$mode
|
324
|
+
else
|
325
|
+
mkdir_mode=
|
326
|
+
fi
|
327
|
+
|
328
|
+
posix_mkdir=false
|
329
|
+
case $umask in
|
330
|
+
*[123567][0-7][0-7])
|
331
|
+
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
332
|
+
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
333
|
+
;;
|
334
|
+
*)
|
335
|
+
# Note that $RANDOM variable is not portable (e.g. dash); Use it
|
336
|
+
# here however when possible just to lower collision chance.
|
337
|
+
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
338
|
+
|
339
|
+
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
|
340
|
+
|
341
|
+
# Because "mkdir -p" follows existing symlinks and we likely work
|
342
|
+
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
343
|
+
# directory is successfully created first before we actually test
|
344
|
+
# 'mkdir -p' feature.
|
345
|
+
if (umask $mkdir_umask &&
|
346
|
+
$mkdirprog $mkdir_mode "$tmpdir" &&
|
347
|
+
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
348
|
+
then
|
349
|
+
if test -z "$dir_arg" || {
|
350
|
+
# Check for POSIX incompatibilities with -m.
|
351
|
+
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
352
|
+
# other-writable bit of parent directory when it shouldn't.
|
353
|
+
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
354
|
+
test_tmpdir="$tmpdir/a"
|
355
|
+
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
356
|
+
case $ls_ld_tmpdir in
|
357
|
+
d????-?r-*) different_mode=700;;
|
358
|
+
d????-?--*) different_mode=755;;
|
359
|
+
*) false;;
|
360
|
+
esac &&
|
361
|
+
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
362
|
+
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
363
|
+
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
364
|
+
}
|
365
|
+
}
|
366
|
+
then posix_mkdir=:
|
367
|
+
fi
|
368
|
+
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
369
|
+
else
|
370
|
+
# Remove any dirs left behind by ancient mkdir implementations.
|
371
|
+
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
372
|
+
fi
|
373
|
+
trap '' 0;;
|
374
|
+
esac;;
|
375
|
+
esac
|
376
|
+
|
377
|
+
if
|
378
|
+
$posix_mkdir && (
|
379
|
+
umask $mkdir_umask &&
|
380
|
+
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
381
|
+
)
|
382
|
+
then :
|
383
|
+
else
|
384
|
+
|
385
|
+
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
386
|
+
# or it failed possibly due to a race condition. Create the
|
387
|
+
# directory the slow way, step by step, checking for races as we go.
|
388
|
+
|
389
|
+
case $dstdir in
|
390
|
+
/*) prefix='/';;
|
391
|
+
[-=\(\)!]*) prefix='./';;
|
392
|
+
*) prefix='';;
|
393
|
+
esac
|
394
|
+
|
395
|
+
oIFS=$IFS
|
396
|
+
IFS=/
|
397
|
+
set -f
|
398
|
+
set fnord $dstdir
|
399
|
+
shift
|
400
|
+
set +f
|
401
|
+
IFS=$oIFS
|
402
|
+
|
403
|
+
prefixes=
|
404
|
+
|
405
|
+
for d
|
406
|
+
do
|
407
|
+
test X"$d" = X && continue
|
408
|
+
|
409
|
+
prefix=$prefix$d
|
410
|
+
if test -d "$prefix"; then
|
411
|
+
prefixes=
|
412
|
+
else
|
413
|
+
if $posix_mkdir; then
|
414
|
+
(umask=$mkdir_umask &&
|
415
|
+
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
416
|
+
# Don't fail if two instances are running concurrently.
|
417
|
+
test -d "$prefix" || exit 1
|
418
|
+
else
|
419
|
+
case $prefix in
|
420
|
+
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
421
|
+
*) qprefix=$prefix;;
|
422
|
+
esac
|
423
|
+
prefixes="$prefixes '$qprefix'"
|
424
|
+
fi
|
425
|
+
fi
|
426
|
+
prefix=$prefix/
|
427
|
+
done
|
428
|
+
|
429
|
+
if test -n "$prefixes"; then
|
430
|
+
# Don't fail if two instances are running concurrently.
|
431
|
+
(umask $mkdir_umask &&
|
432
|
+
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
433
|
+
test -d "$dstdir" || exit 1
|
434
|
+
obsolete_mkdir_used=true
|
435
|
+
fi
|
436
|
+
fi
|
437
|
+
fi
|
438
|
+
|
439
|
+
if test -n "$dir_arg"; then
|
440
|
+
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
441
|
+
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
442
|
+
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
443
|
+
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
444
|
+
else
|
445
|
+
|
446
|
+
# Make a couple of temp file names in the proper directory.
|
447
|
+
dsttmp=${dstdirslash}_inst.$$_
|
448
|
+
rmtmp=${dstdirslash}_rm.$$_
|
449
|
+
|
450
|
+
# Trap to clean up those temp files at exit.
|
451
|
+
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
452
|
+
|
453
|
+
# Copy the file name to the temp name.
|
454
|
+
(umask $cp_umask &&
|
455
|
+
{ test -z "$stripcmd" || {
|
456
|
+
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
457
|
+
# which would cause strip to fail.
|
458
|
+
if test -z "$doit"; then
|
459
|
+
: >"$dsttmp" # No need to fork-exec 'touch'.
|
460
|
+
else
|
461
|
+
$doit touch "$dsttmp"
|
462
|
+
fi
|
463
|
+
}
|
464
|
+
} &&
|
465
|
+
$doit_exec $cpprog "$src" "$dsttmp") &&
|
466
|
+
|
467
|
+
# and set any options; do chmod last to preserve setuid bits.
|
468
|
+
#
|
469
|
+
# If any of these fail, we abort the whole thing. If we want to
|
470
|
+
# ignore errors from any of these, just make sure not to ignore
|
471
|
+
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
472
|
+
#
|
473
|
+
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
474
|
+
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
475
|
+
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
476
|
+
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
477
|
+
|
478
|
+
# If -C, don't bother to copy if it wouldn't change the file.
|
479
|
+
if $copy_on_change &&
|
480
|
+
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
481
|
+
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
482
|
+
set -f &&
|
483
|
+
set X $old && old=:$2:$4:$5:$6 &&
|
484
|
+
set X $new && new=:$2:$4:$5:$6 &&
|
485
|
+
set +f &&
|
486
|
+
test "$old" = "$new" &&
|
487
|
+
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
488
|
+
then
|
489
|
+
rm -f "$dsttmp"
|
490
|
+
else
|
491
|
+
# Rename the file to the real destination.
|
492
|
+
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
493
|
+
|
494
|
+
# The rename failed, perhaps because mv can't rename something else
|
495
|
+
# to itself, or perhaps because mv is so ancient that it does not
|
496
|
+
# support -f.
|
497
|
+
{
|
498
|
+
# Now remove or move aside any old file at destination location.
|
499
|
+
# We try this two ways since rm can't unlink itself on some
|
500
|
+
# systems and the destination file might be busy for other
|
501
|
+
# reasons. In this case, the final cleanup might fail but the new
|
502
|
+
# file should still install successfully.
|
503
|
+
{
|
504
|
+
test ! -f "$dst" ||
|
505
|
+
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
506
|
+
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
507
|
+
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
508
|
+
} ||
|
509
|
+
{ echo "$0: cannot unlink or rename $dst" >&2
|
510
|
+
(exit 1); exit 1
|
511
|
+
}
|
512
|
+
} &&
|
513
|
+
|
514
|
+
# Now rename the file to the real destination.
|
515
|
+
$doit $mvcmd "$dsttmp" "$dst"
|
516
|
+
}
|
517
|
+
fi || exit 1
|
518
|
+
|
519
|
+
trap '' 0
|
520
|
+
fi
|
521
|
+
done
|
522
|
+
|
523
|
+
# Local variables:
|
524
|
+
# eval: (add-hook 'before-save-hook 'time-stamp)
|
525
|
+
# time-stamp-start: "scriptversion="
|
526
|
+
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
527
|
+
# time-stamp-time-zone: "UTC0"
|
528
|
+
# time-stamp-end: "; # UTC"
|
529
|
+
# End:
|