passenger 5.0.30 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +30 -1
  3. data/CONTRIBUTING.md +1 -1
  4. data/CONTRIBUTORS +2 -0
  5. data/bin/passenger-install-nginx-module +18 -13
  6. data/build/agent.rb +1 -0
  7. data/build/basics.rb +1 -0
  8. data/build/cxx_tests.rb +6 -1
  9. data/build/misc.rb +3 -0
  10. data/build/packaging.rb +5 -17
  11. data/build/support/cxx_dependency_map.rb +100 -0
  12. data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/builder.rb +4 -1
  13. data/build/test_basics.rb +12 -2
  14. data/dev/ci/run_travis.sh +6 -2
  15. data/doc/Users guide Apache.html +7 -2
  16. data/doc/Users guide Apache.txt +4 -0
  17. data/resources/templates/error_layout.css +70 -84
  18. data/resources/templates/error_layout.html.template +84 -93
  19. data/resources/templates/standalone/http.erb +17 -13
  20. data/resources/templates/standalone/server.erb +2 -1
  21. data/resources/templates/undisclosed_error.html.template +52 -51
  22. data/resources/update_check_client_cert.p12 +0 -0
  23. data/resources/update_check_client_cert.pem +89 -0
  24. data/resources/update_check_server_pubkey.pem +14 -0
  25. data/src/agent/Core/ApplicationPool/ErrorRenderer.h +15 -1
  26. data/src/agent/Core/Controller.h +3 -2
  27. data/src/agent/Core/Controller/CheckoutSession.cpp +5 -4
  28. data/src/agent/Core/Controller/ForwardResponse.cpp +1 -1
  29. data/src/agent/Core/Controller/InitRequest.cpp +2 -0
  30. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +1 -0
  31. data/src/agent/Core/Controller/Request.h +1 -0
  32. data/src/agent/Core/CoreMain.cpp +99 -2
  33. data/src/agent/Core/OptionParser.h +18 -1
  34. data/src/agent/Core/SecurityUpdateChecker.h +559 -0
  35. data/src/agent/Shared/Base.cpp +6 -1
  36. data/src/agent/TempDirToucher/TempDirToucherMain.cpp +52 -0
  37. data/src/agent/Watchdog/InstanceDirToucher.cpp +1 -2
  38. data/src/agent/Watchdog/WatchdogMain.cpp +31 -40
  39. data/src/apache2_module/Configuration.cpp +12 -0
  40. data/src/apache2_module/Configuration.hpp +5 -0
  41. data/src/apache2_module/ConfigurationCommands.cpp +19 -19
  42. data/src/apache2_module/ConfigurationCommands.cpp.cxxcodebuilder +2 -2
  43. data/src/apache2_module/ConfigurationFields.hpp +19 -19
  44. data/src/apache2_module/ConfigurationFields.hpp.cxxcodebuilder +2 -2
  45. data/src/apache2_module/ConfigurationSetters.cpp +19 -19
  46. data/src/apache2_module/ConfigurationSetters.cpp.cxxcodebuilder +2 -2
  47. data/src/apache2_module/CreateDirConfig.cpp +19 -19
  48. data/src/apache2_module/CreateDirConfig.cpp.cxxcodebuilder +2 -2
  49. data/src/apache2_module/Hooks.cpp +10 -1
  50. data/src/apache2_module/MergeDirConfig.cpp +19 -19
  51. data/src/apache2_module/MergeDirConfig.cpp.cxxcodebuilder +2 -2
  52. data/src/apache2_module/SetHeaders.cpp +19 -19
  53. data/src/apache2_module/SetHeaders.cpp.cxxcodebuilder +2 -2
  54. data/src/cxx_supportlib/Constants.h +22 -22
  55. data/src/cxx_supportlib/Constants.h.cxxcodebuilder +4 -1
  56. data/src/cxx_supportlib/Crypto.cpp +977 -0
  57. data/src/cxx_supportlib/Crypto.h +147 -0
  58. data/src/cxx_supportlib/InstanceDirectory.h +55 -2
  59. data/src/cxx_supportlib/Utils/Curl.h +24 -10
  60. data/src/cxx_supportlib/Utils/JsonUtils.h +1 -1
  61. data/src/cxx_supportlib/oxt/detail/spin_lock_darwin.hpp +2 -0
  62. data/src/cxx_supportlib/vendor-modified/boost/system/error_code.hpp +3 -3
  63. data/src/cxx_supportlib/vendor-modified/jsoncpp/json-forwards.h +167 -92
  64. data/src/cxx_supportlib/vendor-modified/jsoncpp/json.h +1827 -1542
  65. data/src/cxx_supportlib/vendor-modified/jsoncpp/jsoncpp.cpp +4705 -3652
  66. data/src/cxx_supportlib/vendor-modified/libev/Changes +46 -15
  67. data/src/cxx_supportlib/vendor-modified/libev/LICENSE +1 -1
  68. data/src/cxx_supportlib/vendor-modified/libev/Makefile.in +215 -128
  69. data/src/cxx_supportlib/vendor-modified/libev/aclocal.m4 +466 -275
  70. data/src/cxx_supportlib/vendor-modified/libev/config.guess +312 -418
  71. data/src/cxx_supportlib/vendor-modified/libev/config.sub +246 -105
  72. data/src/cxx_supportlib/vendor-modified/libev/configure +276 -72
  73. data/src/cxx_supportlib/vendor-modified/libev/configure.ac +2 -1
  74. data/src/cxx_supportlib/vendor-modified/libev/depcomp +346 -185
  75. data/src/cxx_supportlib/vendor-modified/libev/ev++.h +1 -1
  76. data/src/cxx_supportlib/vendor-modified/libev/ev.c +530 -190
  77. data/src/cxx_supportlib/vendor-modified/libev/ev.h +23 -14
  78. data/src/cxx_supportlib/vendor-modified/libev/ev_epoll.c +12 -6
  79. data/src/cxx_supportlib/vendor-modified/libev/ev_kqueue.c +9 -5
  80. data/src/cxx_supportlib/vendor-modified/libev/ev_poll.c +6 -3
  81. data/src/cxx_supportlib/vendor-modified/libev/ev_port.c +8 -4
  82. data/src/cxx_supportlib/vendor-modified/libev/ev_select.c +4 -2
  83. data/src/cxx_supportlib/vendor-modified/libev/ev_vars.h +3 -2
  84. data/src/cxx_supportlib/vendor-modified/libev/ev_win32.c +3 -4
  85. data/src/cxx_supportlib/vendor-modified/libev/install-sh +433 -219
  86. data/src/cxx_supportlib/vendor-modified/libev/libev.m4 +6 -6
  87. data/src/cxx_supportlib/vendor-modified/libev/ltmain.sh +2 -2
  88. data/src/cxx_supportlib/vendor-modified/libev/missing +167 -288
  89. data/src/cxx_supportlib/vendor-modified/libev/mkinstalldirs +72 -21
  90. data/src/cxx_supportlib/vendor-modified/modp_b64.cpp +4 -106
  91. data/src/cxx_supportlib/vendor-modified/modp_b64_data.h +37 -1
  92. data/src/cxx_supportlib/vendor-modified/modp_b64_strict_aliasing.cpp +119 -0
  93. data/src/helper-scripts/node-loader.js +72 -1
  94. data/src/nginx_module/CacheLocationConfig.c +52 -19
  95. data/src/nginx_module/CacheLocationConfig.c.cxxcodebuilder +2 -2
  96. data/src/nginx_module/Configuration.c +26 -1
  97. data/src/nginx_module/Configuration.h +2 -0
  98. data/src/nginx_module/ConfigurationCommands.c +35 -19
  99. data/src/nginx_module/ConfigurationCommands.c.cxxcodebuilder +2 -2
  100. data/src/nginx_module/ContentHandler.c +1 -1
  101. data/src/nginx_module/CreateLocationConfig.c +22 -19
  102. data/src/nginx_module/CreateLocationConfig.c.cxxcodebuilder +2 -2
  103. data/src/nginx_module/LocationConfig.h +21 -19
  104. data/src/nginx_module/LocationConfig.h.cxxcodebuilder +2 -2
  105. data/src/nginx_module/MergeLocationConfig.c +25 -19
  106. data/src/nginx_module/MergeLocationConfig.c.cxxcodebuilder +2 -2
  107. data/src/nginx_module/ngx_http_passenger_module.c +8 -4
  108. data/src/ruby_supportlib/phusion_passenger.rb +9 -4
  109. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +2 -2
  110. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance_registry.rb +1 -1
  111. data/src/ruby_supportlib/phusion_passenger/common_library.rb +13 -0
  112. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +5 -2
  113. data/src/ruby_supportlib/phusion_passenger/constants.rb +1 -1
  114. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +15 -3
  115. data/src/ruby_supportlib/phusion_passenger/platform_info/crypto.rb +51 -0
  116. data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +7 -0
  117. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +17 -0
  118. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +4 -2
  119. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +4 -0
  120. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +5 -0
  121. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/app.rb +19 -10
  122. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/base.rb +25 -0
  123. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/gdb_controller.rb +38 -103
  124. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/lldb_controller.rb +178 -0
  125. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/utils.rb +94 -0
  126. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/version.rb +2 -2
  127. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +2 -2
  128. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +2 -2
  129. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +5 -3
  130. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +9 -7
  131. metadata +14 -4
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev native API header
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -42,12 +42,16 @@
42
42
 
43
43
  #ifdef __cplusplus
44
44
  # define EV_CPP(x) x
45
+ # if __cplusplus >= 201103L
46
+ # define EV_THROW noexcept
47
+ # else
48
+ # define EV_THROW throw ()
49
+ # endif
45
50
  #else
46
51
  # define EV_CPP(x)
52
+ # define EV_THROW
47
53
  #endif
48
54
 
49
- #define EV_THROW EV_CPP(throw())
50
-
51
55
  EV_CPP(extern "C" {)
52
56
 
53
57
  /*****************************************************************************/
@@ -148,6 +152,8 @@ EV_CPP(extern "C" {)
148
152
 
149
153
  typedef double ev_tstamp;
150
154
 
155
+ #include <string.h> /* for memmove */
156
+
151
157
  #ifndef EV_ATOMIC_T
152
158
  # include <signal.h>
153
159
  # define EV_ATOMIC_T sig_atomic_t volatile
@@ -205,7 +211,7 @@ struct ev_loop;
205
211
  /*****************************************************************************/
206
212
 
207
213
  #define EV_VERSION_MAJOR 4
208
- #define EV_VERSION_MINOR 15
214
+ #define EV_VERSION_MINOR 22
209
215
 
210
216
  /* eventmask, revents, events... */
211
217
  enum {
@@ -509,10 +515,10 @@ enum {
509
515
 
510
516
  /* method bits to be ored together */
511
517
  enum {
512
- EVBACKEND_SELECT = 0x00000001U, /* about anywhere */
513
- EVBACKEND_POLL = 0x00000002U, /* !win */
518
+ EVBACKEND_SELECT = 0x00000001U, /* available just about anywhere */
519
+ EVBACKEND_POLL = 0x00000002U, /* !win, !aix, broken on osx */
514
520
  EVBACKEND_EPOLL = 0x00000004U, /* linux */
515
- EVBACKEND_KQUEUE = 0x00000008U, /* bsd */
521
+ EVBACKEND_KQUEUE = 0x00000008U, /* bsd, broken on osx */
516
522
  EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
517
523
  EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
518
524
  EVBACKEND_ALL = 0x0000003FU, /* all known backends */
@@ -605,11 +611,11 @@ EV_API_DECL void ev_loop_fork (EV_P) EV_THROW;
605
611
 
606
612
  EV_API_DECL unsigned int ev_backend (EV_P) EV_THROW; /* backend in use by loop */
607
613
 
614
+ EV_API_DECL void ev_now_update (EV_P) EV_THROW; /* update event loop time */
615
+
608
616
  EV_API_DECL int ev_backend_fd (EV_P) EV_THROW;
609
617
  EV_API_DECL int ev_loop_get_pipe (EV_P_ unsigned int index) EV_THROW;
610
618
 
611
- EV_API_DECL void ev_now_update (EV_P) EV_THROW; /* update event loop time */
612
-
613
619
  #if EV_WALK_ENABLE
614
620
  /* walk (almost) all watchers in the loop of a given type, invoking the */
615
621
  /* callback on every such watcher. The callback might stop the watcher, */
@@ -661,8 +667,10 @@ EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_T
661
667
  /* advanced stuff for threading etc. support, see docs */
662
668
  EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW;
663
669
  EV_API_DECL void *ev_userdata (EV_P) EV_THROW;
664
- EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) EV_THROW;
665
- EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P) EV_THROW) EV_THROW;
670
+ typedef void (*ev_loop_callback)(EV_P);
671
+ EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW;
672
+ /* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */
673
+ EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW;
666
674
 
667
675
  EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */
668
676
  EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */
@@ -716,7 +724,8 @@ EV_API_DECL void ev_resume (EV_P) EV_THROW;
716
724
  #define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
717
725
  #define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
718
726
 
719
- #define ev_cb(ev) (ev)->cb /* rw */
727
+ #define ev_cb_(ev) (ev)->cb /* rw */
728
+ #define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb)
720
729
 
721
730
  #if EV_MINPRI == EV_MAXPRI
722
731
  # define ev_priority(ev) ((ev), EV_MINPRI)
@@ -729,11 +738,11 @@ EV_API_DECL void ev_resume (EV_P) EV_THROW;
729
738
  #define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at)
730
739
 
731
740
  #ifndef ev_set_cb
732
- # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_)
741
+ # define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev))))
733
742
  #endif
734
743
 
735
744
  /* stopping (enabling, adding) a watcher does nothing if it is already running */
736
- /* stopping (disabling, deleting) a watcher does nothing unless its already running */
745
+ /* stopping (disabling, deleting) a watcher does nothing unless it's already running */
737
746
  #if EV_PROTOTYPES
738
747
 
739
748
  /* feeds an event into a watcher as if the event actually occurred */
@@ -179,7 +179,7 @@ epoll_poll (EV_P_ ev_tstamp timeout)
179
179
  if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32)))
180
180
  {
181
181
  /* recreate kernel state */
182
- postfork = 1;
182
+ postfork |= 2;
183
183
  continue;
184
184
  }
185
185
 
@@ -203,7 +203,7 @@ epoll_poll (EV_P_ ev_tstamp timeout)
203
203
  /* which is fortunately easy to do for us. */
204
204
  if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev))
205
205
  {
206
- postfork = 1; /* an error occurred, recreate kernel state */
206
+ postfork |= 2; /* an error occurred, recreate kernel state */
207
207
  continue;
208
208
  }
209
209
  }
@@ -228,11 +228,15 @@ epoll_poll (EV_P_ ev_tstamp timeout)
228
228
  if (anfds [fd].emask & EV_EMASK_EPERM && events)
229
229
  fd_event (EV_A_ fd, events);
230
230
  else
231
- epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
231
+ {
232
+ epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
233
+ anfds [fd].emask = 0;
234
+ }
232
235
  }
233
236
  }
234
237
 
235
- int inline_size
238
+ inline_size
239
+ int
236
240
  epoll_init (EV_P_ int flags)
237
241
  {
238
242
  #ifdef EPOLL_CLOEXEC
@@ -257,14 +261,16 @@ epoll_init (EV_P_ int flags)
257
261
  return EVBACKEND_EPOLL;
258
262
  }
259
263
 
260
- void inline_size
264
+ inline_size
265
+ void
261
266
  epoll_destroy (EV_P)
262
267
  {
263
268
  ev_free (epoll_events);
264
269
  array_free (epoll_eperm, EMPTY);
265
270
  }
266
271
 
267
- void inline_size
272
+ inline_size
273
+ void
268
274
  epoll_fork (EV_P)
269
275
  {
270
276
  close (backend_fd);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev kqueue backend
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -43,7 +43,8 @@
43
43
  #include <string.h>
44
44
  #include <errno.h>
45
45
 
46
- void inline_speed
46
+ inline_speed
47
+ void
47
48
  kqueue_change (EV_P_ int fd, int filter, int flags, int fflags)
48
49
  {
49
50
  ++kqueue_changecnt;
@@ -152,7 +153,8 @@ kqueue_poll (EV_P_ ev_tstamp timeout)
152
153
  }
153
154
  }
154
155
 
155
- int inline_size
156
+ inline_size
157
+ int
156
158
  kqueue_init (EV_P_ int flags)
157
159
  {
158
160
  /* initialize the kernel queue */
@@ -176,14 +178,16 @@ kqueue_init (EV_P_ int flags)
176
178
  return EVBACKEND_KQUEUE;
177
179
  }
178
180
 
179
- void inline_size
181
+ inline_size
182
+ void
180
183
  kqueue_destroy (EV_P)
181
184
  {
182
185
  ev_free (kqueue_events);
183
186
  ev_free (kqueue_changes);
184
187
  }
185
188
 
186
- void inline_size
189
+ inline_size
190
+ void
187
191
  kqueue_fork (EV_P)
188
192
  {
189
193
  /* some BSD kernels don't just destroy the kqueue itself,
@@ -39,7 +39,8 @@
39
39
 
40
40
  #include <poll.h>
41
41
 
42
- void inline_size
42
+ inline_size
43
+ void
43
44
  pollidx_init (int *base, int count)
44
45
  {
45
46
  /* consider using memset (.., -1, ...), which is practically guaranteed
@@ -126,7 +127,8 @@ poll_poll (EV_P_ ev_tstamp timeout)
126
127
  }
127
128
  }
128
129
 
129
- int inline_size
130
+ inline_size
131
+ int
130
132
  poll_init (EV_P_ int flags)
131
133
  {
132
134
  backend_mintime = 1e-3;
@@ -139,7 +141,8 @@ poll_init (EV_P_ int flags)
139
141
  return EVBACKEND_POLL;
140
142
  }
141
143
 
142
- void inline_size
144
+ inline_size
145
+ void
143
146
  poll_destroy (EV_P)
144
147
  {
145
148
  ev_free (pollidxs);
@@ -55,7 +55,8 @@
55
55
  #include <string.h>
56
56
  #include <errno.h>
57
57
 
58
- void inline_speed
58
+ inline_speed
59
+ void
59
60
  port_associate_and_check (EV_P_ int fd, int ev)
60
61
  {
61
62
  if (0 >
@@ -136,7 +137,8 @@ port_poll (EV_P_ ev_tstamp timeout)
136
137
  }
137
138
  }
138
139
 
139
- int inline_size
140
+ inline_size
141
+ int
140
142
  port_init (EV_P_ int flags)
141
143
  {
142
144
  /* Initialize the kernel queue */
@@ -163,13 +165,15 @@ port_init (EV_P_ int flags)
163
165
  return EVBACKEND_PORT;
164
166
  }
165
167
 
166
- void inline_size
168
+ inline_size
169
+ void
167
170
  port_destroy (EV_P)
168
171
  {
169
172
  ev_free (port_events);
170
173
  }
171
174
 
172
- void inline_size
175
+ inline_size
176
+ void
173
177
  port_fork (EV_P)
174
178
  {
175
179
  close (backend_fd);
@@ -271,7 +271,8 @@ select_poll (EV_P_ ev_tstamp timeout)
271
271
  #endif
272
272
  }
273
273
 
274
- int inline_size
274
+ inline_size
275
+ int
275
276
  select_init (EV_P_ int flags)
276
277
  {
277
278
  backend_mintime = 1e-6;
@@ -300,7 +301,8 @@ select_init (EV_P_ int flags)
300
301
  return EVBACKEND_SELECT;
301
302
  }
302
303
 
303
- void inline_size
304
+ inline_size
305
+ void
304
306
  select_destroy (EV_P)
305
307
  {
306
308
  ev_free (vec_ri);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * loop member variable declarations
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -194,9 +194,10 @@ VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
194
194
  VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */
195
195
 
196
196
  VARx(void *, userdata)
197
+ /* C++ doesn't support the ev_loop_callback typedef here. stinks. */
197
198
  VAR (release_cb, void (*release_cb)(EV_P) EV_THROW)
198
199
  VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_THROW)
199
- VAR (invoke_cb , void (*invoke_cb) (EV_P))
200
+ VAR (invoke_cb , ev_loop_callback invoke_cb)
200
201
  #endif
201
202
 
202
203
  #undef VARx
@@ -39,9 +39,6 @@
39
39
 
40
40
  #ifdef _WIN32
41
41
 
42
- /* timeb.h is actually xsi legacy functionality */
43
- #include <sys/timeb.h>
44
-
45
42
  /* note: the comment below could not be substantiated, but what would I care */
46
43
  /* MSDN says this is required to handle SIGFPE */
47
44
  /* my wild guess would be that using something floating-pointy is required */
@@ -91,6 +88,8 @@ ev_pipe (int filedes [2])
91
88
  if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
92
89
  goto fail;
93
90
 
91
+ /* TODO: returns INVALID_SOCKET on winsock accept, not < 0. fix it */
92
+ /* when convenient, probably by just removing error checking altogether? */
94
93
  if ((sock [1] = accept (listener, 0, 0)) < 0)
95
94
  goto fail;
96
95
 
@@ -143,7 +142,7 @@ fail:
143
142
 
144
143
  #undef pipe
145
144
  #define pipe(filedes) ev_pipe (filedes)
146
-
145
+
147
146
  #define EV_HAVE_EV_TIME 1
148
147
  ev_tstamp
149
148
  ev_time (void)
@@ -1,7 +1,8 @@
1
1
  #!/bin/sh
2
- #
3
2
  # install - install a program, script, or datafile
4
- #
3
+
4
+ scriptversion=2014-09-12.12; # UTC
5
+
5
6
  # This originates from X11R5 (mit/util/scripts/install.sh), which was
6
7
  # later released in X11R6 (xc/config/util/install.sh) with the
7
8
  # following copyright and license.
@@ -34,261 +35,474 @@
34
35
  # FSF changes to this file are in the public domain.
35
36
  #
36
37
  # Calling this script install-sh is preferred over install.sh, to prevent
37
- # `make' implicit rules from creating a file called install from it
38
+ # 'make' implicit rules from creating a file called install from it
38
39
  # when there is no Makefile.
39
40
  #
40
41
  # This script is compatible with the BSD install script, but was written
41
- # from scratch. It can only install one file at a time, a restriction
42
- # shared with many OS's install programs.
42
+ # from scratch.
43
43
 
44
+ tab=' '
45
+ nl='
46
+ '
47
+ IFS=" $tab$nl"
44
48
 
45
- # set DOITPROG to echo to test this script
49
+ # Set DOITPROG to "echo" to test this script.
46
50
 
47
- # Don't use :- since 4.3BSD and earlier shells don't like it.
48
- doit="${DOITPROG-}"
51
+ doit=${DOITPROG-}
52
+ doit_exec=${doit:-exec}
49
53
 
54
+ # Put in absolute file names if you don't have them in your path;
55
+ # or use environment vars.
50
56
 
51
- # put in absolute paths if you don't have them in your path; or use env. vars.
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}
52
66
 
53
- mvprog="${MVPROG-mv}"
54
- cpprog="${CPPROG-cp}"
55
- chmodprog="${CHMODPROG-chmod}"
56
- chownprog="${CHOWNPROG-chown}"
57
- chgrpprog="${CHGRPPROG-chgrp}"
58
- stripprog="${STRIPPROG-strip}"
59
- rmprog="${RMPROG-rm}"
60
- mkdirprog="${MKDIRPROG-mkdir}"
67
+ posix_mkdir=
61
68
 
62
- transformbasename=""
63
- transform_arg=""
64
- instcmd="$mvprog"
65
- chmodcmd="$chmodprog 0755"
66
- chowncmd=""
67
- chgrpcmd=""
68
- stripcmd=""
69
- rmcmd="$rmprog -f"
70
- mvcmd="$mvprog"
71
- src=""
72
- dst=""
73
- dir_arg=""
74
-
75
- while [ x"$1" != x ]; do
76
- case $1 in
77
- -c) instcmd=$cpprog
78
- shift
79
- continue;;
80
-
81
- -d) dir_arg=true
82
- shift
83
- continue;;
84
-
85
- -m) chmodcmd="$chmodprog $2"
86
- shift
87
- shift
88
- continue;;
89
-
90
- -o) chowncmd="$chownprog $2"
91
- shift
92
- shift
93
- continue;;
94
-
95
- -g) chgrpcmd="$chgrpprog $2"
96
- shift
97
- shift
98
- continue;;
99
-
100
- -s) stripcmd=$stripprog
101
- shift
102
- continue;;
103
-
104
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
105
- shift
106
- continue;;
107
-
108
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
109
- shift
110
- continue;;
111
-
112
- *) if [ x"$src" = x ]
113
- then
114
- src=$1
115
- else
116
- # this colon is to work around a 386BSD /bin/sh bug
117
- :
118
- dst=$1
119
- fi
120
- shift
121
- continue;;
122
- esac
123
- done
124
-
125
- if [ x"$src" = x ]
126
- then
127
- echo "$0: no input file specified" >&2
128
- exit 1
129
- else
130
- :
131
- fi
69
+ # Desired mode of installed file.
70
+ mode=0755
132
71
 
133
- if [ x"$dir_arg" != x ]; then
134
- dst=$src
135
- src=""
136
-
137
- if [ -d "$dst" ]; then
138
- instcmd=:
139
- chmodcmd=""
140
- else
141
- instcmd=$mkdirprog
142
- fi
143
- else
144
-
145
- # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
146
- # might cause directories to be created, which would be especially bad
147
- # if $src (and thus $dsttmp) contains '*'.
148
-
149
- if [ -f "$src" ] || [ -d "$src" ]
150
- then
151
- :
152
- else
153
- echo "$0: $src does not exist" >&2
154
- exit 1
155
- fi
156
-
157
- if [ x"$dst" = x ]
158
- then
159
- echo "$0: no destination specified" >&2
160
- exit 1
161
- else
162
- :
163
- fi
164
-
165
- # If destination is a directory, append the input filename; if your system
166
- # does not like double slashes in filenames, you may need to add some logic
167
-
168
- if [ -d "$dst" ]
169
- then
170
- dst=$dst/`basename "$src"`
171
- else
172
- :
173
- fi
174
- fi
72
+ chgrpcmd=
73
+ chmodcmd=$chmodprog
74
+ chowncmd=
75
+ mvcmd=$mvprog
76
+ rmcmd="$rmprog -f"
77
+ stripcmd=
175
78
 
176
- ## this sed command emulates the dirname command
177
- dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
79
+ src=
80
+ dst=
81
+ dir_arg=
82
+ dst_arg=
178
83
 
179
- # Make sure that the destination directory exists.
180
- # this part is taken from Noah Friedman's mkinstalldirs script
84
+ copy_on_change=false
85
+ is_target_a_directory=possibly
181
86
 
182
- # Skip lots of stat calls in the usual case.
183
- if [ ! -d "$dstdir" ]; then
184
- defaultIFS='
185
- '
186
- IFS="${IFS-$defaultIFS}"
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...
187
92
 
188
- oIFS=$IFS
189
- # Some sh's can't handle IFS=/ for some reason.
190
- IFS='%'
191
- set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
192
- IFS=$oIFS
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.
193
96
 
194
- pathcomp=''
97
+ Options:
98
+ --help display this help and exit.
99
+ --version display version info and exit.
195
100
 
196
- while [ $# -ne 0 ] ; do
197
- pathcomp=$pathcomp$1
198
- shift
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.
199
110
 
200
- if [ ! -d "$pathcomp" ] ;
201
- then
202
- $mkdirprog "$pathcomp"
203
- else
204
- :
205
- fi
111
+ Environment variables override the default commands:
112
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
113
+ RMPROG STRIPPROG
114
+ "
206
115
 
207
- pathcomp=$pathcomp/
208
- done
209
- fi
116
+ while test $# -ne 0; do
117
+ case $1 in
118
+ -c) ;;
210
119
 
211
- if [ x"$dir_arg" != x ]
212
- then
213
- $doit $instcmd "$dst" &&
120
+ -C) copy_on_change=true;;
214
121
 
215
- if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
216
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
217
- if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
218
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
219
- else
122
+ -d) dir_arg=true;;
220
123
 
221
- # If we're going to rename the final executable, determine the name now.
124
+ -g) chgrpcmd="$chgrpprog $2"
125
+ shift;;
222
126
 
223
- if [ x"$transformarg" = x ]
224
- then
225
- dstfile=`basename "$dst"`
226
- else
227
- dstfile=`basename "$dst" $transformbasename |
228
- sed $transformarg`$transformbasename
229
- fi
127
+ --help) echo "$usage"; exit $?;;
230
128
 
231
- # don't allow the sed command to completely eliminate the filename
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;;
232
136
 
233
- if [ x"$dstfile" = x ]
234
- then
235
- dstfile=`basename "$dst"`
236
- else
237
- :
238
- fi
137
+ -o) chowncmd="$chownprog $2"
138
+ shift;;
239
139
 
240
- # Make a couple of temp file names in the proper directory.
140
+ -s) stripcmd=$stripprog;;
241
141
 
242
- dsttmp=$dstdir/_inst.$$_
243
- rmtmp=$dstdir/_rm.$$_
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;;
244
150
 
245
- # Trap to clean up temp files at exit.
151
+ -T) is_target_a_directory=never;;
246
152
 
247
- trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
248
- trap '(exit $?); exit' 1 2 13 15
153
+ --version) echo "$0 $scriptversion"; exit $?;;
249
154
 
250
- # Move or copy the file name to the temp name
155
+ --) shift
156
+ break;;
251
157
 
252
- $doit $instcmd "$src" "$dsttmp" &&
158
+ -*) echo "$0: invalid option: $1" >&2
159
+ exit 1;;
253
160
 
254
- # and set any options; do chmod last to preserve setuid bits
161
+ *) break;;
162
+ esac
163
+ shift
164
+ done
255
165
 
256
- # If any of these fail, we abort the whole thing. If we want to
257
- # ignore errors from any of these, just make sure not to ignore
258
- # errors from the above "$doit $instcmd $src $dsttmp" command.
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.
259
168
 
260
- if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
261
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
262
- if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
263
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
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
264
175
 
265
- # Now remove or move aside any old file at destination location. We try this
266
- # two ways since rm can't unlink itself on some systems and the destination
267
- # file might be busy for other reasons. In this case, the final cleanup
268
- # might fail but the new file should still install successfully.
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
269
195
 
270
- {
271
- if [ -f "$dstdir/$dstfile" ]
272
- then
273
- $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
274
- $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
275
- {
276
- echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
277
- (exit 1); exit
278
- }
279
- else
280
- :
281
- fi
282
- } &&
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
283
205
 
284
- # Now rename the file to the real destination.
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
285
214
 
286
- $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
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
287
245
 
288
- fi &&
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; won't work
275
+ # if double slashes aren't ignored.
276
+ if test -d "$dst"; then
277
+ if test "$is_target_a_directory" = never; then
278
+ echo "$0: $dst_arg: Is a directory" >&2
279
+ exit 1
280
+ fi
281
+ dstdir=$dst
282
+ dst=$dstdir/`basename "$src"`
283
+ dstdir_status=0
284
+ else
285
+ dstdir=`dirname "$dst"`
286
+ test -d "$dstdir"
287
+ dstdir_status=$?
288
+ fi
289
+ fi
290
+
291
+ obsolete_mkdir_used=false
292
+
293
+ if test $dstdir_status != 0; then
294
+ case $posix_mkdir in
295
+ '')
296
+ # Create intermediate dirs using mode 755 as modified by the umask.
297
+ # This is like FreeBSD 'install' as of 1997-10-28.
298
+ umask=`umask`
299
+ case $stripcmd.$umask in
300
+ # Optimize common cases.
301
+ *[2367][2367]) mkdir_umask=$umask;;
302
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
303
+
304
+ *[0-7])
305
+ mkdir_umask=`expr $umask + 22 \
306
+ - $umask % 100 % 40 + $umask % 20 \
307
+ - $umask % 10 % 4 + $umask % 2
308
+ `;;
309
+ *) mkdir_umask=$umask,go-w;;
310
+ esac
311
+
312
+ # With -d, create the new directory with the user-specified mode.
313
+ # Otherwise, rely on $mkdir_umask.
314
+ if test -n "$dir_arg"; then
315
+ mkdir_mode=-m$mode
316
+ else
317
+ mkdir_mode=
318
+ fi
319
+
320
+ posix_mkdir=false
321
+ case $umask in
322
+ *[123567][0-7][0-7])
323
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
324
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
325
+ ;;
326
+ *)
327
+ # $RANDOM is not portable (e.g. dash); use it when possible to
328
+ # lower collision chance
329
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
330
+ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
331
+
332
+ # As "mkdir -p" follows symlinks and we work in /tmp possibly; so
333
+ # create the $tmpdir first (and fail if unsuccessful) to make sure
334
+ # that nobody tries to guess the $tmpdir name.
335
+ if (umask $mkdir_umask &&
336
+ $mkdirprog $mkdir_mode "$tmpdir" &&
337
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
338
+ then
339
+ if test -z "$dir_arg" || {
340
+ # Check for POSIX incompatibilities with -m.
341
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
342
+ # other-writable bit of parent directory when it shouldn't.
343
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
344
+ test_tmpdir="$tmpdir/a"
345
+ ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
346
+ case $ls_ld_tmpdir in
347
+ d????-?r-*) different_mode=700;;
348
+ d????-?--*) different_mode=755;;
349
+ *) false;;
350
+ esac &&
351
+ $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
352
+ ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
353
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
354
+ }
355
+ }
356
+ then posix_mkdir=:
357
+ fi
358
+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
359
+ else
360
+ # Remove any dirs left behind by ancient mkdir implementations.
361
+ rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
362
+ fi
363
+ trap '' 0;;
364
+ esac;;
365
+ esac
289
366
 
290
- # The final little trick to "correctly" pass the exit status to the exit trap.
367
+ if
368
+ $posix_mkdir && (
369
+ umask $mkdir_umask &&
370
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
371
+ )
372
+ then :
373
+ else
374
+
375
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
376
+ # or it failed possibly due to a race condition. Create the
377
+ # directory the slow way, step by step, checking for races as we go.
378
+
379
+ case $dstdir in
380
+ /*) prefix='/';;
381
+ [-=\(\)!]*) prefix='./';;
382
+ *) prefix='';;
383
+ esac
384
+
385
+ oIFS=$IFS
386
+ IFS=/
387
+ set -f
388
+ set fnord $dstdir
389
+ shift
390
+ set +f
391
+ IFS=$oIFS
392
+
393
+ prefixes=
394
+
395
+ for d
396
+ do
397
+ test X"$d" = X && continue
398
+
399
+ prefix=$prefix$d
400
+ if test -d "$prefix"; then
401
+ prefixes=
402
+ else
403
+ if $posix_mkdir; then
404
+ (umask=$mkdir_umask &&
405
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
406
+ # Don't fail if two instances are running concurrently.
407
+ test -d "$prefix" || exit 1
408
+ else
409
+ case $prefix in
410
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
411
+ *) qprefix=$prefix;;
412
+ esac
413
+ prefixes="$prefixes '$qprefix'"
414
+ fi
415
+ fi
416
+ prefix=$prefix/
417
+ done
418
+
419
+ if test -n "$prefixes"; then
420
+ # Don't fail if two instances are running concurrently.
421
+ (umask $mkdir_umask &&
422
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
423
+ test -d "$dstdir" || exit 1
424
+ obsolete_mkdir_used=true
425
+ fi
426
+ fi
427
+ fi
428
+
429
+ if test -n "$dir_arg"; then
430
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
431
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
432
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
433
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
434
+ else
435
+
436
+ # Make a couple of temp file names in the proper directory.
437
+ dsttmp=$dstdir/_inst.$$_
438
+ rmtmp=$dstdir/_rm.$$_
439
+
440
+ # Trap to clean up those temp files at exit.
441
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
442
+
443
+ # Copy the file name to the temp name.
444
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
445
+
446
+ # and set any options; do chmod last to preserve setuid bits.
447
+ #
448
+ # If any of these fail, we abort the whole thing. If we want to
449
+ # ignore errors from any of these, just make sure not to ignore
450
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
451
+ #
452
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
453
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
454
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
455
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
456
+
457
+ # If -C, don't bother to copy if it wouldn't change the file.
458
+ if $copy_on_change &&
459
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
460
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
461
+ set -f &&
462
+ set X $old && old=:$2:$4:$5:$6 &&
463
+ set X $new && new=:$2:$4:$5:$6 &&
464
+ set +f &&
465
+ test "$old" = "$new" &&
466
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
467
+ then
468
+ rm -f "$dsttmp"
469
+ else
470
+ # Rename the file to the real destination.
471
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
472
+
473
+ # The rename failed, perhaps because mv can't rename something else
474
+ # to itself, or perhaps because mv is so ancient that it does not
475
+ # support -f.
476
+ {
477
+ # Now remove or move aside any old file at destination location.
478
+ # We try this two ways since rm can't unlink itself on some
479
+ # systems and the destination file might be busy for other
480
+ # reasons. In this case, the final cleanup might fail but the new
481
+ # file should still install successfully.
482
+ {
483
+ test ! -f "$dst" ||
484
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
485
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
486
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
487
+ } ||
488
+ { echo "$0: cannot unlink or rename $dst" >&2
489
+ (exit 1); exit 1
490
+ }
491
+ } &&
492
+
493
+ # Now rename the file to the real destination.
494
+ $doit $mvcmd "$dsttmp" "$dst"
495
+ }
496
+ fi || exit 1
497
+
498
+ trap '' 0
499
+ fi
500
+ done
291
501
 
292
- {
293
- (exit 0); exit
294
- }
502
+ # Local variables:
503
+ # eval: (add-hook 'write-file-hooks 'time-stamp)
504
+ # time-stamp-start: "scriptversion="
505
+ # time-stamp-format: "%:y-%02m-%02d.%02H"
506
+ # time-stamp-time-zone: "UTC"
507
+ # time-stamp-end: "; # UTC"
508
+ # End: