1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
3 NAMEBASE= autoselect-ruby
7 SDESC[standard]= Dynamic links to the latest installed ruby
12 SPKGS[standard]= single
14 OPTIONS_AVAILABLE= none
15 OPTIONS_STANDARD= none
18 LICENSE_FILE= ISCL:{{FILESDIR}}/LICENSE_ISC
21 SUB_FILES= autoselect.c
28 ${CP} ${WRKDIR}/autoselect.c ${WRKSRC}
31 (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c)
34 .for prog in ruby gem erb irb rdoc ri racc racc2y y2racc
35 ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog}
38 [FILE:544:descriptions/desc.single]
39 This package provides:
47 It automatically selects the latest version of ruby available.
48 For example, if ruby 2.3, 2.4, and 2.5 are all installed,
49 bin/ruby executes bin/ruby25 with the same arguments. If
50 ruby 2.5 is then deinstalled, the linkage will automatically
51 adjust to ruby 2.4. The ruby 2.3 binaries will only be
52 executed if no other ruby packages are installed.
54 The priority check can be overridden by setting AUTORUBY=<python version>
55 in the environment, e.g. AUTORUBY=24.
58 [FILE:58:manifests/plist.single]
71 [FILE:747:files/LICENSE_ISC]
72 Copyright (c) 2018-2022, The Ravenports Project.
74 Permission to use, copy, modify, and/or distribute this software for any
75 purpose with or without fee is hereby granted, provided that the above
76 copyright notice and this permission notice appear in all copies.
78 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
79 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
80 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
81 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
82 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
83 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
84 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
87 [FILE:2014:files/autoselect.c.in]
89 * This program will determine the latest version of ruby
90 * installed by checking %%PREFIX%%/bin/ruby-<x> where <x> checks
91 * all possible versions.
93 * If no version is present, an error message will be displayed,
94 * otherwise the versioned counterpart of the ruby command
95 * requested will be will be executed with the same arguments
96 * provided to this one. If the versioned command isn't present, an
97 * error message will be provided as a fallback.
107 main(int argc, char **argv)
112 char recommand[1024];
114 char *RUBY_A = "%%PREFIX%%/bin/ruby%%ALPHA%%";
115 char *RUBY_B = "%%PREFIX%%/bin/ruby%%BRAVO%%";
116 char *RUBY_C = "%%PREFIX%%/bin/ruby%%CHARLIE%%";
117 char *ALPHA = "%%ALPHA%%";
118 char *BRAVO = "%%BRAVO%%";
119 char *CHARLIE = "%%CHARLIE%%";
121 override = getenv("AUTORUBY");
122 if (override != NULL) {
123 if (strcmp (override, ALPHA) == 0) {
125 } else if (strcmp (override, BRAVO) == 0) {
127 } else if (strcmp (override, CHARLIE) == 0) {
132 if (access(RUBY_A, F_OK) != -1) {
134 } else if (access(RUBY_B, F_OK) != -1) {
136 } else if (access(RUBY_C, F_OK) != -1) {
139 /* no versions of ruby are installed */
140 printf ("There are no versions of ruby installed at %%PREFIX%%/bin\n");
146 * Get the last path element of the program name being executed
148 cmd = strrchr(argv[0], '/');
154 snprintf(recommand, 1024, "%%PREFIX%%/bin/%s%s", cmd, rbver);
156 execv(recommand, argv);
159 * Execution failed, so write out an error message
161 printf ("Command execution failed: %s\n", recommand);
162 printf (" arguments:");
163 for (x = 1; x < argc; x++)
164 printf (" %s", argv[x]);