# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= autoselect-ruby VERSION= 6 KEYWORDS= lang VARIANTS= standard SDESC[standard]= Dynamic links to the latest installed ruby HOMEPAGE= none CONTACT= nobody DOWNLOAD_GROUPS= none SPKGS[standard]= single OPTIONS_AVAILABLE= none OPTIONS_STANDARD= none LICENSE= ISCL:single LICENSE_FILE= ISCL:{{FILESDIR}}/LICENSE_ISC LICENSE_SCHEME= solo SUB_FILES= autoselect.c SUB_LIST= ALPHA=33 BRAVO=32 CHARLIE=31 post-patch: @${MKDIR} ${WRKSRC} ${CP} ${WRKDIR}/autoselect.c ${WRKSRC} do-build: (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c) do-install: .for prog in ruby gem erb irb rdoc ri racc racc2y y2racc ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog} .endfor [FILE:544:descriptions/desc.single] This package provides: bin/ruby bin/gem bin/erb bin/irb bin/rdoc bin/ri It automatically selects the latest version of ruby available. For example, if ruby 2.3, 2.4, and 2.5 are all installed, bin/ruby executes bin/ruby25 with the same arguments. If ruby 2.5 is then deinstalled, the linkage will automatically adjust to ruby 2.4. The ruby 2.3 binaries will only be executed if no other ruby packages are installed. The priority check can be overridden by setting AUTORUBY= in the environment, e.g. AUTORUBY=24. [FILE:58:manifests/plist.single] bin/ erb gem irb racc racc2y rdoc ri ruby y2racc [FILE:747:files/LICENSE_ISC] Copyright (c) 2018-2022, The Ravenports Project. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. [FILE:2014:files/autoselect.c.in] /* * This program will determine the latest version of ruby * installed by checking %%PREFIX%%/bin/ruby- where checks * all possible versions. * * If no version is present, an error message will be displayed, * otherwise the versioned counterpart of the ruby command * requested will be will be executed with the same arguments * provided to this one. If the versioned command isn't present, an * error message will be provided as a fallback. */ #include #include #include #include int main(int argc, char **argv) { int x; char *cmd; char *override; char recommand[1024]; char *rbver = NULL; char *RUBY_A = "%%PREFIX%%/bin/ruby%%ALPHA%%"; char *RUBY_B = "%%PREFIX%%/bin/ruby%%BRAVO%%"; char *RUBY_C = "%%PREFIX%%/bin/ruby%%CHARLIE%%"; char *ALPHA = "%%ALPHA%%"; char *BRAVO = "%%BRAVO%%"; char *CHARLIE = "%%CHARLIE%%"; override = getenv("AUTORUBY"); if (override != NULL) { if (strcmp (override, ALPHA) == 0) { rbver = ALPHA; } else if (strcmp (override, BRAVO) == 0) { rbver = BRAVO; } else if (strcmp (override, CHARLIE) == 0) { rbver = CHARLIE; } } if (rbver == NULL) { if (access(RUBY_A, F_OK) != -1) { rbver = ALPHA; } else if (access(RUBY_B, F_OK) != -1) { rbver = BRAVO; } else if (access(RUBY_C, F_OK) != -1) { rbver = CHARLIE; } else { /* no versions of ruby are installed */ printf ("There are no versions of ruby installed at %%PREFIX%%/bin\n"); exit (1); } } /* * Get the last path element of the program name being executed */ cmd = strrchr(argv[0], '/'); if (cmd != NULL) cmd++; else cmd = argv[0]; snprintf(recommand, 1024, "%%PREFIX%%/bin/%s%s", cmd, rbver); argv[0] = recommand; execv(recommand, argv); /* * Execution failed, so write out an error message */ printf ("Command execution failed: %s\n", recommand); printf (" arguments:"); for (x = 1; x < argc; x++) printf (" %s", argv[x]); printf ("\n"); exit (1); }