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