Ravenports generated: 22 Apr 2019 10:04
[ravenports.git] / bucket_9B / autoselect-perl
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               autoselect-perl
4 VERSION=                1
5 REVISION=               1
6 KEYWORDS=               lang
7 VARIANTS=               standard
8 SDESC[standard]=        Dynamic links to the latest installed perl
9 HOMEPAGE=               none
10 CONTACT=                nobody
11
12 DOWNLOAD_GROUPS=        none
13 SPKGS[standard]=        single
14
15 OPTIONS_AVAILABLE=      none
16 OPTIONS_STANDARD=       none
17
18 LICENSE=                ISCL:single
19 LICENSE_FILE=           ISCL:{{FILESDIR}}/LICENSE_ISC
20 LICENSE_SCHEME=         solo
21
22 SUB_FILES=              autoselect.c
23 SUB_LIST=               ALPHA=5.28
24                         ALPHA_FULL=5.28.2
25                         BRAVO=5.26
26                         BRAVO_FULL=5.26.3
27
28 post-patch:
29         @${MKDIR} ${WRKSRC}
30         ${CP} ${WRKDIR}/autoselect.c ${WRKSRC}
31
32 do-build:
33         (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c)
34
35 do-install:
36 .for prog in perl perl5 corelist cpan enc2xs encguess h2ph h2xs \
37         instmodsh json_pp libnetcfg perlbug perldoc perlivp perlthanks \
38         piconv pl2pm pod2html pod2man pod2text pod2usage podchecker \
39         podselect prove ptar ptardiff ptargrep shasum splain xsubpp zipdetails
40         ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog}
41 .endfor
42
43 [FILE:913:descriptions/desc.single]
44 This package provides:
45   bin/perl         bin/instmodsh    bin/pl2pm        bin/ptar
46   bin/perl5        bin/json_pp      bin/pod2html     bin/ptardiff         
47   bin/corelist     bin/libnetcfg    bin/pod2man      bin/ptargrep
48   bin/cpan         bin/perlbug      bin/pod2text     bin/shasum
49   bin/enc2xs       bin/perldoc      bin/pod2usage    bin/splain
50   bin/encguess     bin/perlivp      bin/podchecker   bin/xsubpp
51   bin/h2ph         bin/perlthanks   bin/podselect    bin/zipdetails
52   bin/h2xs         bin/piconv       bin/prove
53
54 It automatically selects the latest version of perl available.
55 For example, if perl 5.26 and perl 5.28 are both installed,
56 bin/perl executes bin/perl5.28 with the same arguments.  If
57 perl 5.28 is then deinstalled, the linkage will automatically
58 adjust to perl 5.26. 
59
60 The priority check can be overridden by setting AUTOPERL=<perl version>
61 in the environment, e.g. AUTOPERL=5.26.
62
63
64 [FILE:281:manifests/plist.single]
65 bin/
66  corelist
67  cpan
68  enc2xs
69  encguess
70  h2ph
71  h2xs
72  instmodsh
73  json_pp
74  libnetcfg
75  perl
76  perl5
77  perlbug
78  perldoc
79  perlivp
80  perlthanks
81  piconv
82  pl2pm
83  pod2html
84  pod2man
85  pod2text
86  pod2usage
87  podchecker
88  podselect
89  prove
90  ptar
91  ptardiff
92  ptargrep
93  shasum
94  splain
95  xsubpp
96  zipdetails
97
98
99 [FILE:742:files/LICENSE_ISC]
100 Copyright (c) 2018, The Ravenports Project.
101
102 Permission to use, copy, modify, and/or distribute this software for any
103 purpose with or without fee is hereby granted, provided that the above
104 copyright notice and this permission notice appear in all copies.
105
106 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
107 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
108 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
109 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
110 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
111 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
112 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
113
114
115 [FILE:2068:files/autoselect.c.in]
116 /*
117  * This program will determine the latest version of perl
118  * installed by checking %%PREFIX%%/bin/perl<x> where <x> checks
119  * all possible versions.
120  * 
121  * If no version is present, an error message will be displayed,
122  * otherwise the versioned counterpart of the perl command
123  * requested will be will be executed with the same arguments
124  * provided to this one.  If the versioned command isn't present, an
125  * error message will be provided as a fallback.
126  */
127
128 #include <stdio.h>
129 #include <stdlib.h>
130 #include <string.h>
131 #include <unistd.h>
132
133
134 int
135 main(int argc, char **argv)
136 {
137         int x;
138         char *cmd;
139         char *override;
140         char recommand[1024];
141         char *plver   = NULL;
142         char *PERL_A  = "%%PREFIX%%/bin/perl%%ALPHA_FULL%%";
143         char *PERL_B  = "%%PREFIX%%/bin/perl%%BRAVO_FULL%%";
144         char *ALPHA   = "%%ALPHA_FULL%%";
145         char *BRAVO   = "%%BRAVO_FULL%%";
146         char *A_SHORT = "%%ALPHA%%";
147         char *B_SHORT = "%%BRAVO%%";
148         char *perl5   = "perl5";
149
150         override = getenv("AUTOPERL");
151         if (override != NULL) {
152                 if (strcmp (override, A_SHORT) == 0) {
153                         plver = ALPHA;
154                 } else if (strcmp (override, B_SHORT) == 0) {
155                         plver = BRAVO;
156                 }
157         }
158         if (plver == NULL) {
159                 if (access(PERL_A, F_OK) != -1) {
160                         plver = ALPHA;
161                 } else if (access(PERL_B, F_OK) != -1) {
162                         plver = BRAVO;
163                 } else {
164                         /* no versions of perl are installed */
165                         printf ("There are no versions of perl installed at %%PREFIX%%/bin\n");
166                         exit (1);
167                 }
168         }
169
170         /*
171          * Get the last path element of the program name being executed
172          */
173         cmd = strrchr(argv[0], '/');
174         if (cmd != NULL)
175                 cmd++;
176         else
177                 cmd = argv[0];
178
179         /*
180          * special case, cmd of perl5 transforms to perl
181          */
182         if (strcmp (cmd, perl5) == 0)
183                 snprintf(recommand, 1024, "%%PREFIX%%/bin/perl%s", plver);
184         else
185                 snprintf(recommand, 1024, "%%PREFIX%%/bin/%s%s", cmd, plver);
186
187         argv[0] = recommand;
188         execv(recommand, argv);
189
190         /*
191          * Execution failed, so write out an error message
192          */
193         printf ("Command execution failed: %s\n", recommand);
194         printf ("               arguments:");
195         for (x = 1; x < argc; x++)
196                 printf (" %s", argv[x]);
197         printf ("\n");
198         exit (1);
199 }
200